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:
Joseph-Ramos-CMU
2020-12-13 13:21:50 -05:00
parent 084e4ce50b
commit 2d98da0d61
2 changed files with 49 additions and 7 deletions

View File

@ -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;