-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve multiplayer room status handling #30838
base: master
Are you sure you want to change the base?
Changes from 4 commits
82a6322
5ebaab7
1b8db7c
1410e88
af0c6fc
4c7976b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Localisation; | ||
|
||
namespace osu.Game.Localisation | ||
{ | ||
public static class RoomStatusPillStrings | ||
{ | ||
private const string prefix = @"osu.Game.Resources.Localisation.RoomStatusPill"; | ||
|
||
/// <summary> | ||
/// "Ended" | ||
/// </summary> | ||
public static LocalisableString Ended => new TranslatableString(getKey(@"ended"), @"Ended"); | ||
|
||
/// <summary> | ||
/// "Playing" | ||
/// </summary> | ||
public static LocalisableString Playing => new TranslatableString(getKey(@"playing"), @"Playing"); | ||
|
||
/// <summary> | ||
/// "Open (Private)" | ||
/// </summary> | ||
public static LocalisableString OpenPrivate => new TranslatableString(getKey(@"open_private"), @"Open (Private)"); | ||
|
||
/// <summary> | ||
/// "Open" | ||
/// </summary> | ||
public static LocalisableString Open => new TranslatableString(getKey(@"open"), @"Open"); | ||
|
||
private static string getKey(string key) => $@"{prefix}:{key}"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
#nullable disable | ||
|
||
using osu.Game.Graphics; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Game.Online.Rooms | ||
{ | ||
public abstract class RoomStatus | ||
public enum RoomStatus | ||
{ | ||
public abstract string Message { get; } | ||
public abstract Color4 GetAppropriateColour(OsuColour colours); | ||
|
||
public override int GetHashCode() => GetType().GetHashCode(); | ||
public override bool Equals(object obj) => GetType() == obj?.GetType(); | ||
Idle, | ||
Playing, | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,18 +29,27 @@ protected override void LoadComplete() | |
base.LoadComplete(); | ||
|
||
room.PropertyChanged += onRoomPropertyChanged; | ||
|
||
Scheduler.AddDelayed(updateRoomStatus, 5000, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm intent - are these schedules supposed to handle the passage of time in relation to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. I thought of doing something similar to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a bit weird. Depending on the load time of individual components, the 5 second poll may occur at different times, causing some elements to update at different times, even on the same room display. I don't have an immediate better solution in mind though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general I expect these schedules to be triggered on the same frame for the same As I said the future solution here is realtime updates from the multiplayer server. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use this for now? diff --git a/osu.Game/Screens/OnlinePlay/Components/StatusColouredContainer.cs b/osu.Game/Screens/OnlinePlay/Components/StatusColouredContainer.cs
index a811ee3371..379dc65bcd 100644
--- a/osu.Game/Screens/OnlinePlay/Components/StatusColouredContainer.cs
+++ b/osu.Game/Screens/OnlinePlay/Components/StatusColouredContainer.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@@ -30,7 +31,8 @@ protected override void LoadComplete()
room.PropertyChanged += onRoomPropertyChanged;
- Scheduler.AddDelayed(updateRoomStatus, 5000, true);
+ if (room.EndDate > DateTimeOffset.Now)
+ Scheduler.AddDelayed(updateRoomStatus, (room.EndDate.Value - DateTimeOffset.Now).TotalMilliseconds + 500, true);
updateRoomStatus();
}
diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomStatusPill.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomStatusPill.cs
index 6da8f3ecbd..7007e6c8b8 100644
--- a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomStatusPill.cs
+++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomStatusPill.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@@ -37,7 +38,8 @@ protected override void LoadComplete()
room.PropertyChanged += onRoomPropertyChanged;
- Scheduler.AddDelayed(updateDisplay, 5000, true);
+ if (room.EndDate > DateTimeOffset.Now)
+ Scheduler.AddDelayed(updateDisplay, (room.EndDate.Value - DateTimeOffset.Now).TotalMilliseconds + 500, true);
updateDisplay();
FinishTransforms(true);
}
It would at least mean that various elements would have their state changes synced up closer than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I guess not since |
||
updateRoomStatus(); | ||
} | ||
|
||
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName == nameof(Room.Status)) | ||
updateRoomStatus(); | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(Room.Category): | ||
case nameof(Room.Status): | ||
case nameof(Room.EndDate): | ||
case nameof(Room.HasPassword): | ||
updateRoomStatus(); | ||
break; | ||
} | ||
} | ||
|
||
private void updateRoomStatus() | ||
{ | ||
this.FadeColour(colours.ForRoomCategory(room.Category) ?? room.Status.GetAppropriateColour(colours), transitionDuration); | ||
this.FadeColour(colours.ForRoomCategory(room.Category) ?? colours.ForRoomStatus(room), transitionDuration); | ||
} | ||
|
||
protected override void Dispose(bool isDisposing) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having this logic in
OsuColour
also weirds me out a bit. Maybe it's fine, but it's not really where I'd expect to find a date check.Maybe it'll feel better if moved to a property on
Room
?if (room.HasEnded)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of a weird one because it needs to be queried periodically. But okay I'll do this for now as a pure code quality improvement.