-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add ability to close playlists within grace period after creation #30793
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a679f07
Add ability to close playlists within grace period after creation
bdach 3b2f430
Merge branch 'master' into close-playlists
bdach 69c2c98
Add extra check to ensure closed rooms can't be closed harder
bdach cfc38df
Add close button to playlists footer
bdach 8b68859
Fix `Room.CopyFrom()` skipping a field
bdach 70eee88
Remove unnecessary null check
peppy 2e6f43a
Merge branch 'master' into close-playlists
bdach ac2c4e8
Use switch
bdach 9926ffd
Make button a little narrower
bdach c93c549
Fix ready button not disabling on playlist close
bdach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 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.Net.Http; | ||
using osu.Framework.IO.Network; | ||
|
||
namespace osu.Game.Online.API.Requests | ||
{ | ||
public class ClosePlaylistRequest : APIRequest | ||
{ | ||
private readonly long roomId; | ||
|
||
public ClosePlaylistRequest(long roomId) | ||
{ | ||
this.roomId = roomId; | ||
} | ||
|
||
protected override WebRequest CreateWebRequest() | ||
{ | ||
var request = base.CreateWebRequest(); | ||
request.Method = HttpMethod.Delete; | ||
return request; | ||
} | ||
|
||
protected override string Target => $@"rooms/{roomId}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.Collections.Generic; | ||
using System.ComponentModel; | ||
using osu.Framework.Allocation; | ||
|
@@ -22,9 +23,14 @@ | |
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Graphics.UserInterfaceV2; | ||
using osu.Game.Input.Bindings; | ||
using osu.Game.Online.API; | ||
using osu.Game.Online.API.Requests; | ||
using osu.Game.Online.Rooms; | ||
using osu.Game.Online.Rooms.RoomStatuses; | ||
using osu.Game.Overlays; | ||
using osu.Game.Screens.OnlinePlay.Components; | ||
using osu.Game.Screens.OnlinePlay.Lounge.Components; | ||
using osu.Game.Screens.OnlinePlay.Playlists; | ||
using osuTK; | ||
using osuTK.Graphics; | ||
using Container = osu.Framework.Graphics.Containers.Container; | ||
|
@@ -48,6 +54,12 @@ public required Bindable<Room?> SelectedRoom | |
[Resolved(canBeNull: true)] | ||
private LoungeSubScreen? lounge { get; set; } | ||
|
||
[Resolved] | ||
private IDialogOverlay? dialogOverlay { get; set; } | ||
|
||
[Resolved] | ||
private IAPIProvider api { get; set; } = null!; | ||
|
||
private readonly BindableWithCurrent<Room?> selectedRoom = new BindableWithCurrent<Room?>(); | ||
private Sample? sampleSelect; | ||
private Sample? sampleJoin; | ||
|
@@ -144,13 +156,34 @@ public bool MatchingFilter | |
|
||
public Popover GetPopover() => new PasswordEntryPopover(Room); | ||
|
||
public MenuItem[] ContextMenuItems => new MenuItem[] | ||
public MenuItem[] ContextMenuItems | ||
{ | ||
new OsuMenuItem("Create copy", MenuItemType.Standard, () => | ||
get | ||
{ | ||
lounge?.OpenCopy(Room); | ||
}) | ||
}; | ||
var items = new List<MenuItem> | ||
{ | ||
new OsuMenuItem("Create copy", MenuItemType.Standard, () => | ||
{ | ||
lounge?.OpenCopy(Room); | ||
}) | ||
}; | ||
|
||
if (Room.Type == MatchType.Playlists && Room.Host?.Id == api.LocalUser.Value.Id && Room.StartDate?.AddMinutes(5) >= DateTimeOffset.Now && Room.Status is not RoomStatusEnded) | ||
{ | ||
items.Add(new OsuMenuItem("Close playlist", MenuItemType.Destructive, () => | ||
{ | ||
dialogOverlay?.Push(new ClosePlaylistDialog(Room, () => | ||
{ | ||
var request = new ClosePlaylistRequest(Room.RoomID!.Value); | ||
request.Success += () => lounge?.RefreshRooms(); | ||
api.Queue(request); | ||
})); | ||
})); | ||
} | ||
|
||
return items.ToArray(); | ||
} | ||
} | ||
|
||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
osu.Game/Screens/OnlinePlay/Playlists/ClosePlaylistDialog.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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 osu.Game.Online.Rooms; | ||
using osu.Game.Overlays.Dialog; | ||
|
||
namespace osu.Game.Screens.OnlinePlay.Playlists | ||
{ | ||
public partial class ClosePlaylistDialog : DeletionDialog | ||
{ | ||
public ClosePlaylistDialog(Room room, Action closeAction) | ||
{ | ||
HeaderText = "Are you sure you want to close the following playlist:"; | ||
BodyText = room.Name; | ||
DangerousAction = closeAction; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I hesitantly mentioned this in my other comment, but we could just expose this to the user as "deleting" and not require custom terminology for closing. I think to the user they expect to "delete" a playlist, not "close" it.. but I can swing both ways.
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.
Am neither here or there, fine with either personally.