mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 04:32:53 +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> availableChannels = new BindableList<Channel>();
|
||||||
private readonly BindableList<Channel> joinedChannels = 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>
|
/// <summary>
|
||||||
/// The currently opened channel
|
/// The currently opened channel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -408,6 +416,16 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
joinedChannels.Remove(channel);
|
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)
|
if (channel.Joined.Value)
|
||||||
{
|
{
|
||||||
api.Queue(new LeaveChannelRequest(channel));
|
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 long lastMessageId;
|
||||||
|
|
||||||
private bool channelsInitialised;
|
private bool channelsInitialised;
|
||||||
|
@ -358,6 +358,17 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.ControlPressed)
|
if (e.ControlPressed)
|
||||||
|
{
|
||||||
|
if (e.ShiftPressed)
|
||||||
|
{
|
||||||
|
switch (e.Key)
|
||||||
|
{
|
||||||
|
case Key.T:
|
||||||
|
channelManager.JoinLastClosedChannel();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
@ -370,6 +381,7 @@ namespace osu.Game.Overlays
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return base.OnKeyDown(e);
|
return base.OnKeyDown(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user