mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Untested Ctrl+Shift+T shortcut prototype
Added a list to the ChannelManager class that tracks which tabs I closed. Works like a stack, where it adds to the end every time I close a tab. Then added a function that uses this list to open the last closed channel, and added a shortcut inside of ChatOverlay, similar to how jmeng implemented shortcuts. Code is currently untested.
This commit is contained in:
@ -33,6 +33,19 @@ namespace osu.Game.Online.Chat
|
||||
private readonly BindableList<Channel> availableChannels = new BindableList<Channel>();
|
||||
private readonly BindableList<Channel> joinedChannels = new BindableList<Channel>();
|
||||
|
||||
// Prototype for keeping a list of closed channels in an
|
||||
// order so we can figure out the reverse order of how channels
|
||||
// were close
|
||||
// Bindable list supports an insert at indexc function and a
|
||||
// remove function. If the list re-indexes after each remove (I can
|
||||
// check the behaviour of the C# List System.Collections.Generic library to confirm this, since that
|
||||
// library appears to be what is used underneath), then I can just always add at the end
|
||||
// of the list and always remove index 0 (if size > 0)
|
||||
// A stack exchange post indicates that List remove will decrement all the
|
||||
// indeces after the node we removed
|
||||
|
||||
private readonly BindableList<Channel> closedChannels = new BindableList<Channel>();
|
||||
|
||||
/// <summary>
|
||||
/// The currently opened channel
|
||||
/// </summary>
|
||||
@ -48,6 +61,11 @@ namespace osu.Game.Online.Chat
|
||||
/// </summary>
|
||||
public IBindableList<Channel> AvailableChannels => availableChannels;
|
||||
|
||||
/// <summary>
|
||||
/// The channels available for the player to join
|
||||
/// </summary>
|
||||
public IBindableList<Channel> ClosedChannels => ClosedChannels;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
@ -407,6 +425,8 @@ namespace osu.Game.Online.Chat
|
||||
CurrentChannel.Value = null;
|
||||
|
||||
joinedChannels.Remove(channel);
|
||||
// insert at the end of the list
|
||||
closedChannels.Insert(closedChannels.Count, channel);
|
||||
|
||||
if (channel.Joined.Value)
|
||||
{
|
||||
@ -415,6 +435,16 @@ namespace osu.Game.Online.Chat
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void JoinLastClosedChannel()
|
||||
{
|
||||
if(joinedChannels.Count == 0)
|
||||
return;
|
||||
Channel lastClosedChannel = joinedChannels[joinedChannels.Count - 1];
|
||||
JoinChannel(lastClosedChannel);
|
||||
joinedChannels.Remove(lastClosedChannel);
|
||||
}
|
||||
|
||||
private long lastMessageId;
|
||||
|
||||
private bool channelsInitialised;
|
||||
|
Reference in New Issue
Block a user