Resolve merge conflicts

This commit is contained in:
Lucas A 2020-12-19 10:55:18 +01:00
commit a397db4f15
50 changed files with 313 additions and 229 deletions

View File

@ -26,7 +26,7 @@ namespace osu.Desktop
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
private Bindable<User> user;
private IBindable<User> user;
private readonly IBindable<UserStatus> status = new Bindable<UserStatus>();
private readonly IBindable<UserActivity> activity = new Bindable<UserActivity>();

View File

@ -2,10 +2,10 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Game.Replays;
using osu.Game.Rulesets.Catch.Replays;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Rulesets.Catch.UI
@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Catch.UI
{
private readonly CatchPlayfield playfield;
public CatchReplayRecorder(Replay target, CatchPlayfield playfield)
public CatchReplayRecorder(Score target, CatchPlayfield playfield)
: base(target)
{
this.playfield = playfield;

View File

@ -13,6 +13,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Catch.UI
{
@ -31,7 +32,7 @@ namespace osu.Game.Rulesets.Catch.UI
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new CatchFramedReplayInputHandler(replay);
protected override ReplayRecorder CreateReplayRecorder(Replay replay) => new CatchReplayRecorder(replay, (CatchPlayfield)Playfield);
protected override ReplayRecorder CreateReplayRecorder(Score score) => new CatchReplayRecorder(score, (CatchPlayfield)Playfield);
protected override Playfield CreatePlayfield() => new CatchPlayfield(Beatmap.BeatmapInfo.BaseDifficulty, CreateDrawableRepresentation);

View File

@ -23,6 +23,7 @@ using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mania.UI
{
@ -132,6 +133,6 @@ namespace osu.Game.Rulesets.Mania.UI
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new ManiaFramedReplayInputHandler(replay);
protected override ReplayRecorder CreateReplayRecorder(Replay replay) => new ManiaReplayRecorder(replay);
protected override ReplayRecorder CreateReplayRecorder(Score score) => new ManiaReplayRecorder(score);
}
}

View File

@ -2,18 +2,18 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Game.Replays;
using osu.Game.Rulesets.Mania.Replays;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Rulesets.Mania.UI
{
public class ManiaReplayRecorder : ReplayRecorder<ManiaAction>
{
public ManiaReplayRecorder(Replay replay)
: base(replay)
public ManiaReplayRecorder(Score score)
: base(score)
{
}

View File

@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
double multiplier = 1.12; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
if (mods.Any(m => m is OsuModNoFail))
multiplier *= 0.90;
multiplier *= Math.Max(0.90, 1.0 - 0.02 * countMiss);
if (mods.Any(m => m is OsuModSpunOut))
multiplier *= 1.0 - Math.Pow((double)Attributes.SpinnerCount / totalHits, 0.85);

View File

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osuTK;
@ -44,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.UI
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new OsuFramedReplayInputHandler(replay);
protected override ReplayRecorder CreateReplayRecorder(Replay replay) => new OsuReplayRecorder(replay);
protected override ReplayRecorder CreateReplayRecorder(Score score) => new OsuReplayRecorder(score);
public override double GameplayStartTime
{

View File

@ -2,18 +2,18 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Game.Replays;
using osu.Game.Rulesets.Osu.Replays;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Rulesets.Osu.UI
{
public class OsuReplayRecorder : ReplayRecorder<OsuAction>
{
public OsuReplayRecorder(Replay replay)
: base(replay)
public OsuReplayRecorder(Score score)
: base(score)
{
}

View File

@ -17,6 +17,7 @@ using osu.Game.Replays;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Scoring;
using osu.Game.Skinning;
using osuTK;
@ -82,6 +83,6 @@ namespace osu.Game.Rulesets.Taiko.UI
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new TaikoFramedReplayInputHandler(replay);
protected override ReplayRecorder CreateReplayRecorder(Replay replay) => new TaikoReplayRecorder(replay);
protected override ReplayRecorder CreateReplayRecorder(Score score) => new TaikoReplayRecorder(score);
}
}

View File

@ -2,18 +2,18 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Game.Replays;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Taiko.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Rulesets.Taiko.UI
{
public class TaikoReplayRecorder : ReplayRecorder<TaikoAction>
{
public TaikoReplayRecorder(Replay replay)
: base(replay)
public TaikoReplayRecorder(Score score)
: base(score)
{
}

View File

@ -19,6 +19,7 @@ using osu.Game.Replays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Tests.Visual.UserInterface;
using osuTK;
@ -53,7 +54,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{
Recorder = recorder = new TestReplayRecorder(replay)
Recorder = recorder = new TestReplayRecorder(new Score { Replay = replay })
{
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
},
@ -271,7 +272,7 @@ namespace osu.Game.Tests.Visual.Gameplay
internal class TestReplayRecorder : ReplayRecorder<TestAction>
{
public TestReplayRecorder(Replay target)
public TestReplayRecorder(Score target)
: base(target)
{
}

View File

@ -15,6 +15,7 @@ using osu.Game.Replays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Tests.Visual.UserInterface;
using osuTK;
@ -44,7 +45,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{
Recorder = new TestReplayRecorder(replay)
Recorder = new TestReplayRecorder(new Score { Replay = replay })
{
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos)
},
@ -206,7 +207,7 @@ namespace osu.Game.Tests.Visual.Gameplay
internal class TestReplayRecorder : ReplayRecorder<TestAction>
{
public TestReplayRecorder(Replay target)
public TestReplayRecorder(Score target)
: base(target)
{
}

View File

@ -17,6 +17,7 @@ using osu.Game.Replays.Legacy;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Tests.Beatmaps.IO;
using osu.Game.Users;
@ -272,7 +273,7 @@ namespace osu.Game.Tests.Visual.Gameplay
frames.Add(new LegacyReplayFrame(i * 100, RNG.Next(0, 512), RNG.Next(0, 512), buttonState));
}
var bundle = new FrameDataBundle(frames);
var bundle = new FrameDataBundle(new ScoreInfo(), frames);
((ISpectatorClient)this).UserSentFrames(StreamingUser.Id, bundle);
if (!sentState)

View File

@ -27,6 +27,7 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Replays.Types;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Tests.Visual.UserInterface;
using osuTK;
@ -348,7 +349,7 @@ namespace osu.Game.Tests.Visual.Gameplay
internal class TestReplayRecorder : ReplayRecorder<TestAction>
{
public TestReplayRecorder()
: base(new Replay())
: base(new Score())
{
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Game.Online.API;
using osu.Game.Screens.Menu;
using osu.Game.Users;
@ -16,7 +17,7 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("toggle support", () =>
{
API.LocalUser.Value = new User
((DummyAPIAccess)API).LocalUser.Value = new User
{
Username = API.LocalUser.Value.Username,
Id = API.LocalUser.Value.Id + 1,

View File

@ -4,7 +4,6 @@
using System;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.RoomStatuses;
using osu.Game.Screens.Multi.Lounge.Components;
using osu.Game.Users;
@ -14,10 +13,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
public class TestSceneLoungeRoomInfo : MultiplayerTestScene
{
[SetUp]
public void Setup() => Schedule(() =>
public new void Setup() => Schedule(() =>
{
Room = new Room();
Child = new RoomInfo
{
Anchor = Anchor.Centre,

View File

@ -24,10 +24,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
private RulesetStore rulesetStore { get; set; }
[SetUp]
public void Setup() => Schedule(() =>
public new void Setup() => Schedule(() =>
{
Room = new Room();
Child = new MatchBeatmapDetailArea
{
Anchor = Anchor.Centre,

View File

@ -1,6 +1,7 @@
// 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 NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets.Osu;
@ -14,7 +15,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
public TestSceneMatchHeader()
{
Room = new Room();
Child = new Header();
}
[SetUp]
public new void Setup() => Schedule(() =>
{
Room.Playlist.Add(new PlaylistItem
{
Beatmap =
@ -41,8 +47,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
Room.Name.Value = "A very awesome room";
Room.Host.Value = new User { Id = 2, Username = "peppy" };
Child = new Header();
}
});
}
}

View File

@ -3,10 +3,10 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Users;
using osuTK;
@ -19,8 +19,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
public TestSceneMatchLeaderboard()
{
Room = new Room { RoomID = { Value = 3 } };
Add(new MatchLeaderboard
{
Origin = Anchor.Centre,
@ -40,6 +38,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
api.Queue(req);
}
[SetUp]
public new void Setup() => Schedule(() =>
{
Room.RoomID.Value = 3;
});
private class GetRoomScoresRequest : APIRequest<List<RoomScore>>
{
protected override string Target => "rooms/3/leaderboard";

View File

@ -23,10 +23,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
private TestRoomSettings settings;
[SetUp]
public void Setup() => Schedule(() =>
public new void Setup() => Schedule(() =>
{
Room = new Room();
settings = new TestRoomSettings
{
RelativeSizeAxes = Axes.Both,

View File

@ -14,7 +14,6 @@ using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
@ -94,12 +93,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen());
}
[SetUp]
public void Setup() => Schedule(() =>
{
Room = new Room();
});
[Test]
public void TestItemAddedIfEmptyOnStart()
{

View File

@ -45,12 +45,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait();
}
[SetUp]
public void Setup() => Schedule(() =>
{
Room = new Room();
});
[SetUpSteps]
public void SetupSteps()
{

View File

@ -1,50 +0,0 @@
// 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 NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components;
using osuTK;
namespace osu.Game.Tests.Visual.Multiplayer
{
public class TestSceneOverlinedParticipants : MultiplayerTestScene
{
protected override bool UseOnlineAPI => true;
[SetUp]
public void Setup() => Schedule(() =>
{
Room = new Room { RoomID = { Value = 7 } };
});
[Test]
public void TestHorizontalLayout()
{
AddStep("create component", () =>
{
Child = new ParticipantsDisplay(Direction.Horizontal)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 500,
};
});
}
[Test]
public void TestVerticalLayout()
{
AddStep("create component", () =>
{
Child = new ParticipantsDisplay(Direction.Vertical)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(500)
};
});
}
}
}

View File

@ -1,39 +0,0 @@
// 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 osu.Framework.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Multi;
using osu.Game.Tests.Beatmaps;
using osuTK;
namespace osu.Game.Tests.Visual.Multiplayer
{
public class TestSceneOverlinedPlaylist : MultiplayerTestScene
{
protected override bool UseOnlineAPI => true;
public TestSceneOverlinedPlaylist()
{
Room = new Room { RoomID = { Value = 7 } };
for (int i = 0; i < 10; i++)
{
Room.Playlist.Add(new PlaylistItem
{
ID = i,
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
Ruleset = { Value = new OsuRuleset().RulesetInfo }
});
}
Add(new DrawableRoomPlaylist(false, false)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(500),
});
}
}
}

View File

@ -3,24 +3,55 @@
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Multiplayer
{
public class TestSceneParticipantsList : MultiplayerTestScene
{
protected override bool UseOnlineAPI => true;
[SetUp]
public void Setup() => Schedule(() =>
public new void Setup() => Schedule(() =>
{
Room = new Room { RoomID = { Value = 7 } };
Room.RoomID.Value = 7;
for (int i = 0; i < 50; i++)
{
Room.RecentParticipants.Add(new User
{
Username = "peppy",
Id = 2
});
}
});
public TestSceneParticipantsList()
[Test]
public void TestHorizontalLayout()
{
Add(new ParticipantsList { RelativeSizeAxes = Axes.Both });
AddStep("create component", () =>
{
Child = new ParticipantsDisplay(Direction.Horizontal)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 0.2f,
};
});
}
[Test]
public void TestVerticalLayout()
{
AddStep("create component", () =>
{
Child = new ParticipantsDisplay(Direction.Vertical)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 0.2f,
Height = 0.2f,
};
});
}
}
}

View File

@ -1,6 +1,7 @@
// 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;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.Multiplayer;
@ -22,18 +23,21 @@ namespace osu.Game.Tests.Visual.Multiplayer
new DrawableRoom(new Room
{
Name = { Value = "Room 1" },
Status = { Value = new RoomStatusOpen() }
}),
Status = { Value = new RoomStatusOpen() },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }
}) { MatchingFilter = true },
new DrawableRoom(new Room
{
Name = { Value = "Room 2" },
Status = { Value = new RoomStatusPlaying() }
}),
Status = { Value = new RoomStatusPlaying() },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }
}) { MatchingFilter = true },
new DrawableRoom(new Room
{
Name = { Value = "Room 3" },
Status = { Value = new RoomStatusEnded() }
}),
Status = { Value = new RoomStatusEnded() },
EndDate = { Value = DateTimeOffset.Now }
}) { MatchingFilter = true },
}
};
}

View File

@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Online
{
private readonly Container userPanelArea;
private Bindable<User> localUser;
private IBindable<User> localUser;
public TestSceneAccountCreationOverlay()
{

View File

@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.Online
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
private TestFriendDisplay display;
private FriendDisplay display;
[SetUp]
public void Setup() => Schedule(() =>
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Online
Child = new BasicScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = display = new TestFriendDisplay()
Child = display = new FriendDisplay()
};
});
@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestOnline()
{
AddStep("Fetch online", () => display?.Fetch());
// No need to do anything, fetch is performed automatically.
}
private List<User> getUsers() => new List<User>
@ -76,10 +76,5 @@ namespace osu.Game.Tests.Visual.Online
LastVisit = DateTimeOffset.Now
}
};
private class TestFriendDisplay : FriendDisplay
{
public void Fetch() => PerformFetch();
}
}
}

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.Chat;
using osu.Game.Rulesets;
using osu.Game.Users;
@ -18,6 +19,8 @@ namespace osu.Game.Tests.Visual.Online
[Cached(typeof(IChannelPostTarget))]
private PostTarget postTarget { get; set; }
private DummyAPIAccess api => (DummyAPIAccess)API;
public TestSceneNowPlayingCommand()
{
Add(postTarget = new PostTarget());
@ -26,7 +29,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestGenericActivity()
{
AddStep("Set activity", () => API.Activity.Value = new UserActivity.InLobby(null));
AddStep("Set activity", () => api.Activity.Value = new UserActivity.InLobby(null));
AddStep("Run command", () => Add(new NowPlayingCommand()));
@ -36,7 +39,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestEditActivity()
{
AddStep("Set activity", () => API.Activity.Value = new UserActivity.Editing(new BeatmapInfo()));
AddStep("Set activity", () => api.Activity.Value = new UserActivity.Editing(new BeatmapInfo()));
AddStep("Run command", () => Add(new NowPlayingCommand()));
@ -46,7 +49,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestPlayActivity()
{
AddStep("Set activity", () => API.Activity.Value = new UserActivity.SoloGame(new BeatmapInfo(), new RulesetInfo()));
AddStep("Set activity", () => api.Activity.Value = new UserActivity.SoloGame(new BeatmapInfo(), new RulesetInfo()));
AddStep("Run command", () => Add(new NowPlayingCommand()));
@ -57,7 +60,7 @@ namespace osu.Game.Tests.Visual.Online
[TestCase(false)]
public void TestLinkPresence(bool hasOnlineId)
{
AddStep("Set activity", () => API.Activity.Value = new UserActivity.InLobby(null));
AddStep("Set activity", () => api.Activity.Value = new UserActivity.InLobby(null));
AddStep("Set beatmap", () => Beatmap.Value = new DummyWorkingBeatmap(Audio, null)
{

View File

@ -39,9 +39,15 @@ namespace osu.Game.Online.API
private string password;
public Bindable<User> LocalUser { get; } = new Bindable<User>(createGuestUser());
public IBindable<User> LocalUser => localUser;
public IBindableList<User> Friends => friends;
public IBindable<UserActivity> Activity => activity;
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
private Bindable<User> localUser { get; } = new Bindable<User>(createGuestUser());
private BindableList<User> friends { get; } = new BindableList<User>();
private Bindable<UserActivity> activity { get; } = new Bindable<UserActivity>();
protected bool HasLogin => authentication.Token.Value != null || (!string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password));
@ -61,10 +67,10 @@ namespace osu.Game.Online.API
authentication.TokenString = config.Get<string>(OsuSetting.Token);
authentication.Token.ValueChanged += onTokenChanged;
LocalUser.BindValueChanged(u =>
localUser.BindValueChanged(u =>
{
u.OldValue?.Activity.UnbindFrom(Activity);
u.NewValue.Activity.BindTo(Activity);
u.OldValue?.Activity.UnbindFrom(activity);
u.NewValue.Activity.BindTo(activity);
}, true);
var thread = new Thread(run)
@ -134,23 +140,37 @@ namespace osu.Game.Online.API
}
var userReq = new GetUserRequest();
userReq.Success += u =>
{
LocalUser.Value = u;
localUser.Value = u;
// todo: save/pull from settings
LocalUser.Value.Status.Value = new UserStatusOnline();
localUser.Value.Status.Value = new UserStatusOnline();
failureCount = 0;
};
if (!handleRequest(userReq))
{
failConnectionProcess();
continue;
}
// getting user's friends is considered part of the connection process.
var friendsReq = new GetFriendsRequest();
friendsReq.Success += res =>
{
friends.AddRange(res);
//we're connected!
state.Value = APIState.Online;
};
if (!handleRequest(userReq))
if (!handleRequest(friendsReq))
{
if (State.Value == APIState.Connecting)
state.Value = APIState.Failing;
failConnectionProcess();
continue;
}
@ -186,6 +206,13 @@ namespace osu.Game.Online.API
Thread.Sleep(50);
}
void failConnectionProcess()
{
// if something went wrong during the connection process, we want to reset the state (but only if still connecting).
if (State.Value == APIState.Connecting)
state.Value = APIState.Failing;
}
}
public void Perform(APIRequest request)
@ -322,7 +349,7 @@ namespace osu.Game.Online.API
return true;
}
public bool IsLoggedIn => LocalUser.Value.Id > 1;
public bool IsLoggedIn => localUser.Value.Id > 1;
public void Queue(APIRequest request)
{
@ -352,8 +379,12 @@ namespace osu.Game.Online.API
password = null;
authentication.Clear();
// Scheduled prior to state change such that the state changed event is invoked with the correct user present
Schedule(() => LocalUser.Value = createGuestUser());
// Scheduled prior to state change such that the state changed event is invoked with the correct user and their friends present
Schedule(() =>
{
localUser.Value = createGuestUser();
friends.Clear();
});
state.Value = APIState.Offline;
}

View File

@ -18,6 +18,8 @@ namespace osu.Game.Online.API
Id = 1001,
});
public BindableList<User> Friends { get; } = new BindableList<User>();
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
public string AccessToken => "token";
@ -86,5 +88,9 @@ namespace osu.Game.Online.API
}
public void SetState(APIState newState) => state.Value = newState;
IBindable<User> IAPIProvider.LocalUser => LocalUser;
IBindableList<User> IAPIProvider.Friends => Friends;
IBindable<UserActivity> IAPIProvider.Activity => Activity;
}
}

View File

@ -13,13 +13,19 @@ namespace osu.Game.Online.API
/// The local user.
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
/// </summary>
Bindable<User> LocalUser { get; }
IBindable<User> LocalUser { get; }
/// <summary>
/// The user's friends.
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
/// </summary>
IBindableList<User> Friends { get; }
/// <summary>
/// The current user's activity.
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
/// </summary>
Bindable<UserActivity> Activity { get; }
IBindable<UserActivity> Activity { get; }
/// <summary>
/// Retrieve the OAuth access token.

View File

@ -18,13 +18,20 @@ namespace osu.Game.Online.RealtimeMultiplayer
public int RulesetID { get; set; }
public string BeatmapChecksum { get; set; } = string.Empty;
public string Name { get; set; } = "Unnamed room";
[NotNull]
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
public bool Equals(MultiplayerRoomSettings other) => BeatmapID == other.BeatmapID && Mods.SequenceEqual(other.Mods) && RulesetID == other.RulesetID && Name.Equals(other.Name, StringComparison.Ordinal);
public bool Equals(MultiplayerRoomSettings other)
=> BeatmapID == other.BeatmapID
&& BeatmapChecksum == other.BeatmapChecksum
&& Mods.SequenceEqual(other.Mods)
&& RulesetID == other.RulesetID
&& Name.Equals(other.Name, StringComparison.Ordinal);
public override string ToString() => $"Name:{Name} Beatmap:{BeatmapID} Mods:{string.Join(',', Mods)} Ruleset:{RulesetID}";
public override string ToString() => $"Name:{Name} Beatmap:{BeatmapID} ({BeatmapChecksum}) Mods:{string.Join(',', Mods)} Ruleset:{RulesetID}";
}
}

View File

@ -1,20 +1,34 @@
// 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 enable
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Replays.Legacy;
using osu.Game.Scoring;
namespace osu.Game.Online.Spectator
{
[Serializable]
public class FrameDataBundle
{
public FrameHeader Header { get; set; }
public IEnumerable<LegacyReplayFrame> Frames { get; set; }
public FrameDataBundle(IEnumerable<LegacyReplayFrame> frames)
public FrameDataBundle(ScoreInfo score, IEnumerable<LegacyReplayFrame> frames)
{
Frames = frames;
Header = new FrameHeader(score);
}
[JsonConstructor]
public FrameDataBundle(FrameHeader header, IEnumerable<LegacyReplayFrame> frames)
{
Header = header;
Frames = frames;
}
}
}

View File

@ -0,0 +1,59 @@
// 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 enable
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Online.Spectator
{
[Serializable]
public class FrameHeader
{
/// <summary>
/// The current combo of the score.
/// </summary>
public int Combo { get; set; }
/// <summary>
/// The maximum combo achieved up to the current point in time.
/// </summary>
public int MaxCombo { get; set; }
/// <summary>
/// Cumulative hit statistics.
/// </summary>
public Dictionary<HitResult, int> Statistics { get; set; }
/// <summary>
/// The time at which this frame was received by the server.
/// </summary>
public DateTimeOffset ReceivedTime { get; set; }
/// <summary>
/// Construct header summary information from a point-in-time reference to a score which is actively being played.
/// </summary>
/// <param name="score">The score for reference.</param>
public FrameHeader(ScoreInfo score)
{
Combo = score.Combo;
MaxCombo = score.MaxCombo;
// copy for safety
Statistics = new Dictionary<HitResult, int>(score.Statistics);
}
[JsonConstructor]
public FrameHeader(int combo, int maxCombo, Dictionary<HitResult, int> statistics, DateTimeOffset receivedTime)
{
Combo = combo;
MaxCombo = maxCombo;
Statistics = statistics;
ReceivedTime = receivedTime;
}
}
}

View File

@ -21,6 +21,7 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Replays.Types;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
namespace osu.Game.Online.Spectator
@ -52,6 +53,9 @@ namespace osu.Game.Online.Spectator
[CanBeNull]
private IBeatmap currentBeatmap;
[CanBeNull]
private Score currentScore;
[Resolved]
private IBindable<RulesetInfo> currentRuleset { get; set; }
@ -203,7 +207,7 @@ namespace osu.Game.Online.Spectator
return Task.CompletedTask;
}
public void BeginPlaying(GameplayBeatmap beatmap)
public void BeginPlaying(GameplayBeatmap beatmap, Score score)
{
if (isPlaying)
throw new InvalidOperationException($"Cannot invoke {nameof(BeginPlaying)} when already playing");
@ -216,6 +220,8 @@ namespace osu.Game.Online.Spectator
currentState.Mods = currentMods.Value.Select(m => new APIMod(m));
currentBeatmap = beatmap.PlayableBeatmap;
currentScore = score;
beginPlaying();
}
@ -308,7 +314,9 @@ namespace osu.Game.Online.Spectator
pendingFrames.Clear();
SendFrames(new FrameDataBundle(frames));
Debug.Assert(currentScore != null);
SendFrames(new FrameDataBundle(currentScore.ScoreInfo, frames));
lastSendTime = Time.Current;
}

View File

@ -976,7 +976,7 @@ namespace osu.Game
if (newScreen is IOsuScreen newOsuScreen)
{
OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode);
((IBindable<UserActivity>)API.Activity).BindTo(newOsuScreen.Activity);
API.Activity.BindTo(newOsuScreen.Activity);
MusicController.AllowRateAdjustments = newOsuScreen.AllowRateAdjustments;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private PostBeatmapFavouriteRequest request;
private LoadingLayer loading;
private readonly Bindable<User> localUser = new Bindable<User>();
private readonly IBindable<User> localUser = new Bindable<User>();
public string TooltipText
{

View File

@ -26,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private readonly Bindable<BeatmapLeaderboardScope> scope = new Bindable<BeatmapLeaderboardScope>(BeatmapLeaderboardScope.Global);
private readonly Bindable<User> user = new Bindable<User>();
private readonly IBindable<User> user = new Bindable<User>();
private readonly Box background;
private readonly ScoreTable scoreTable;

View File

@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Comments
public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
public readonly BindableBool ShowDeleted = new BindableBool();
protected readonly Bindable<User> User = new Bindable<User>();
protected readonly IBindable<User> User = new Bindable<User>();
[Resolved]
private IAPIProvider api { get; set; }

View File

@ -5,18 +5,18 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Overlays.Dashboard.Friends
{
public class FriendDisplay : OverlayView<List<User>>
public class FriendDisplay : CompositeDrawable
{
private List<User> users = new List<User>();
@ -41,8 +41,16 @@ namespace osu.Game.Overlays.Dashboard.Friends
private Container itemsPlaceholder;
private LoadingLayer loading;
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
private readonly IBindableList<User> apiFriends = new BindableList<User>();
public FriendDisplay()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
}
[BackgroundDependencyLoader(true)]
private void load(OverlayColourProvider colourProvider, IAPIProvider api)
{
InternalChild = new FillFlowContainer
{
@ -132,6 +140,9 @@ namespace osu.Game.Overlays.Dashboard.Friends
background.Colour = colourProvider.Background4;
controlBackground.Colour = colourProvider.Background5;
apiFriends.BindTo(api.Friends);
apiFriends.BindCollectionChanged((_, __) => Schedule(() => Users = apiFriends.ToList()), true);
}
protected override void LoadComplete()
@ -143,13 +154,6 @@ namespace osu.Game.Overlays.Dashboard.Friends
userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels());
}
protected override APIRequest<List<User>> CreateRequest() => new GetFriendsRequest();
protected override void OnSuccess(List<User> response)
{
Users = response;
}
private void recreatePanels()
{
if (!users.Any())

View File

@ -50,6 +50,8 @@ namespace osu.Game.Overlays.Profile.Header.Components
}
};
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
User.BindValueChanged(user => updateFollowers(user.NewValue), true);
}

View File

@ -268,12 +268,12 @@ namespace osu.Game.Rulesets.UI
return false;
}
public override void SetRecordTarget(Replay recordingReplay)
public sealed override void SetRecordTarget(Score score)
{
if (!(KeyBindingInputManager is IHasRecordingHandler recordingInputManager))
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports recording is not available");
var recorder = CreateReplayRecorder(recordingReplay);
var recorder = CreateReplayRecorder(score);
if (recorder == null)
return;
@ -327,7 +327,7 @@ namespace osu.Game.Rulesets.UI
protected virtual ReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
protected virtual ReplayRecorder CreateReplayRecorder(Replay replay) => null;
protected virtual ReplayRecorder CreateReplayRecorder(Score score) => null;
/// <summary>
/// Creates a Playfield.
@ -516,8 +516,8 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// Sets a replay to be used to record gameplay.
/// </summary>
/// <param name="recordingReplay">The target to be recorded to.</param>
public abstract void SetRecordTarget(Replay recordingReplay);
/// <param name="score">The target to be recorded to.</param>
public abstract void SetRecordTarget(Score score);
/// <summary>
/// Invoked when the interactive user requests resuming from a paused state.

View File

@ -10,8 +10,8 @@ using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Online.Spectator;
using osu.Game.Replays;
using osu.Game.Rulesets.Replays;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osuTK;
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.UI
public abstract class ReplayRecorder<T> : ReplayRecorder, IKeyBindingHandler<T>
where T : struct
{
private readonly Replay target;
private readonly Score target;
private readonly List<T> pressedActions = new List<T>();
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.UI
[Resolved]
private GameplayBeatmap gameplayBeatmap { get; set; }
protected ReplayRecorder(Replay target)
protected ReplayRecorder(Score target)
{
this.target = target;
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.UI
inputManager = GetContainingInputManager();
spectatorStreaming?.BeginPlaying(gameplayBeatmap);
spectatorStreaming?.BeginPlaying(gameplayBeatmap, target);
}
protected override void Dispose(bool isDisposing)
@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.UI
private void recordFrame(bool important)
{
var last = target.Frames.LastOrDefault();
var last = target.Replay.Frames.LastOrDefault();
if (!important && last != null && Time.Current - last.Time < (1000d / RecordFrameRate))
return;
@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.UI
if (frame != null)
{
target.Frames.Add(frame);
target.Replay.Frames.Add(frame);
spectatorStreaming?.HandleFrame(frame);
}

View File

@ -22,7 +22,7 @@ namespace osu.Game.Screens.Backgrounds
private int currentDisplay;
private const int background_count = 7;
private Bindable<User> user;
private IBindable<User> user;
private Bindable<Skin> skin;
private Bindable<BackgroundSource> mode;
private Bindable<IntroSequence> introSequence;

View File

@ -147,7 +147,7 @@ namespace osu.Game.Screens.Menu
if (nextScreen != null)
LoadComponentAsync(nextScreen);
currentUser.BindTo(api.LocalUser);
((IBindable<User>)currentUser).BindTo(api.LocalUser);
}
public override void OnEntering(IScreen last)

View File

@ -12,7 +12,7 @@ namespace osu.Game.Screens.Menu
{
internal class MenuLogoVisualisation : LogoVisualisation
{
private Bindable<User> user;
private IBindable<User> user;
private Bindable<Skin> skin;
[BackgroundDependencyLoader]

View File

@ -35,7 +35,7 @@ namespace osu.Game.Screens.Menu
private const double box_fade_in_time = 65;
private const int box_width = 200;
private Bindable<User> user;
private IBindable<User> user;
private Bindable<Skin> skin;
[Resolved]

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -21,7 +22,6 @@ using osu.Game.Graphics.Containers;
using osu.Game.IO.Archives;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Replays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
@ -157,14 +157,17 @@ namespace osu.Game.Screens.Play
PrepareReplay();
}
private Replay recordingReplay;
[CanBeNull]
private Score recordingScore;
/// <summary>
/// Run any recording / playback setup for replays.
/// </summary>
protected virtual void PrepareReplay()
{
DrawableRuleset.SetRecordTarget(recordingReplay = new Replay());
DrawableRuleset.SetRecordTarget(recordingScore = new Score());
ScoreProcessor.NewJudgement += result => ScoreProcessor.PopulateScore(recordingScore.ScoreInfo);
}
[BackgroundDependencyLoader(true)]
@ -758,9 +761,9 @@ namespace osu.Game.Screens.Play
var score = new Score { ScoreInfo = CreateScore() };
if (recordingReplay?.Frames.Count > 0)
if (recordingScore?.Replay.Frames.Count > 0)
{
score.Replay = recordingReplay;
score.Replay = recordingScore.Replay;
using (var stream = new MemoryStream())
{

View File

@ -1,6 +1,7 @@
// 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 NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Online.Multiplayer;
@ -12,11 +13,7 @@ namespace osu.Game.Tests.Visual
[Cached]
private readonly Bindable<Room> currentRoom = new Bindable<Room>();
protected Room Room
{
get => currentRoom.Value;
set => currentRoom.Value = value;
}
protected Room Room => currentRoom.Value;
private CachedModelDependencyContainer<Room> dependencies;
@ -26,5 +23,11 @@ namespace osu.Game.Tests.Visual
dependencies.Model.BindTo(currentRoom);
return dependencies;
}
[SetUp]
public void Setup() => Schedule(() =>
{
currentRoom.Value = new Room();
});
}
}