mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 00:02:54 +08:00
Merge pull request #8 from angelaz1/jcramos/ctrl_shift_t
Ctrl+Shift+t Chat Shortcut
This commit is contained in:
commit
456c0751fd
@ -33,6 +33,14 @@ namespace osu.Game.Online.Chat
|
||||
private readonly BindableList<Channel> availableChannels = new BindableList<Channel>();
|
||||
private readonly BindableList<Channel> joinedChannels = new BindableList<Channel>();
|
||||
|
||||
// Keeps a list of closed channels. More recently closed channels appear at higher indeces
|
||||
private readonly BindableList<Channel> closedChannels = new BindableList<Channel>();
|
||||
|
||||
// For efficiency purposes, this constant bounds the number of closed channels we store.
|
||||
// This number is somewhat arbitrary; future developers are free to modify it.
|
||||
// Must be a positive number.
|
||||
private const int closed_channels_max_size = 50;
|
||||
|
||||
/// <summary>
|
||||
/// The currently opened channel
|
||||
/// </summary>
|
||||
@ -408,6 +416,16 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
joinedChannels.Remove(channel);
|
||||
|
||||
// Prevent the closedChannel list from exceeding the max size
|
||||
// by removing the oldest element
|
||||
if (closedChannels.Count >= closed_channels_max_size)
|
||||
{
|
||||
closedChannels.RemoveAt(0);
|
||||
}
|
||||
|
||||
// insert at the end of the closedChannels list
|
||||
closedChannels.Insert(closedChannels.Count, channel);
|
||||
|
||||
if (channel.Joined.Value)
|
||||
{
|
||||
api.Queue(new LeaveChannelRequest(channel));
|
||||
@ -415,6 +433,34 @@ namespace osu.Game.Online.Chat
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the most recently closed channel that has not
|
||||
/// already been reopened
|
||||
/// Works similarly to reopening the last closed tab on a web browser.
|
||||
/// </summary>
|
||||
public void JoinLastClosedChannel()
|
||||
{
|
||||
if (closedChannels.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Channel lastClosedChannel = closedChannels.Last();
|
||||
|
||||
closedChannels.Remove(lastClosedChannel);
|
||||
|
||||
// If the user already joined the channel, try the next
|
||||
// channel in the list
|
||||
if (joinedChannels.IndexOf(lastClosedChannel) >= 0)
|
||||
{
|
||||
JoinLastClosedChannel();
|
||||
}
|
||||
else
|
||||
{
|
||||
JoinChannel(lastClosedChannel);
|
||||
}
|
||||
}
|
||||
|
||||
private long lastMessageId;
|
||||
|
||||
private bool channelsInitialised;
|
||||
|
@ -359,15 +359,27 @@ namespace osu.Game.Overlays
|
||||
|
||||
if (e.ControlPressed)
|
||||
{
|
||||
switch (e.Key)
|
||||
if (e.ShiftPressed)
|
||||
{
|
||||
case Key.W:
|
||||
channelManager.LeaveChannel(channelManager.CurrentChannel.Value);
|
||||
return true;
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.T:
|
||||
channelManager.JoinLastClosedChannel();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.W:
|
||||
channelManager.LeaveChannel(channelManager.CurrentChannel.Value);
|
||||
return true;
|
||||
|
||||
case Key.T:
|
||||
ChannelTabControl.SelectChannelSelectorTab();
|
||||
return true;
|
||||
case Key.T:
|
||||
ChannelTabControl.SelectChannelSelectorTab();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user