mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 20:05:29 +08:00
Merge branch 'master' into editor-bottom-bar-new-design
This commit is contained in:
commit
818b344c2b
@ -40,7 +40,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
typeof(DashboardOverlay),
|
typeof(DashboardOverlay),
|
||||||
typeof(NewsOverlay),
|
typeof(NewsOverlay),
|
||||||
typeof(ChannelManager),
|
typeof(ChannelManager),
|
||||||
typeof(ChatOverlay),
|
typeof(ChatOverlayV2),
|
||||||
typeof(SettingsOverlay),
|
typeof(SettingsOverlay),
|
||||||
typeof(UserProfileOverlay),
|
typeof(UserProfileOverlay),
|
||||||
typeof(BeatmapSetOverlay),
|
typeof(BeatmapSetOverlay),
|
||||||
|
@ -86,9 +86,9 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestOverlaysAlwaysClosed()
|
public void TestOverlaysAlwaysClosed()
|
||||||
{
|
{
|
||||||
ChatOverlay chat = null;
|
ChatOverlayV2 chat = null;
|
||||||
AddUntilStep("is at menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
|
AddUntilStep("is at menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
|
||||||
AddUntilStep("wait for chat load", () => (chat = Game.ChildrenOfType<ChatOverlay>().SingleOrDefault()) != null);
|
AddUntilStep("wait for chat load", () => (chat = Game.ChildrenOfType<ChatOverlayV2>().SingleOrDefault()) != null);
|
||||||
|
|
||||||
AddStep("show chat", () => InputManager.Key(Key.F8));
|
AddStep("show chat", () => InputManager.Key(Key.F8));
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Overlays;
|
|
||||||
using osu.Game.Overlays.Chat;
|
using osu.Game.Overlays.Chat;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -22,12 +21,10 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
public class TestSceneChatLink : OsuTestScene
|
public class TestSceneChatLink : OsuTestScene
|
||||||
{
|
{
|
||||||
private readonly TestChatLineContainer textContainer;
|
private readonly TestChatLineContainer textContainer;
|
||||||
private readonly DialogOverlay dialogOverlay;
|
|
||||||
private Color4 linkColour;
|
private Color4 linkColour;
|
||||||
|
|
||||||
public TestSceneChatLink()
|
public TestSceneChatLink()
|
||||||
{
|
{
|
||||||
Add(dialogOverlay = new DialogOverlay { Depth = float.MinValue });
|
|
||||||
Add(textContainer = new TestChatLineContainer
|
Add(textContainer = new TestChatLineContainer
|
||||||
{
|
{
|
||||||
Padding = new MarginPadding { Left = 20, Right = 20 },
|
Padding = new MarginPadding { Left = 20, Right = 20 },
|
||||||
@ -47,9 +44,6 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
availableChannels.Add(new Channel { Name = "#english" });
|
availableChannels.Add(new Channel { Name = "#english" });
|
||||||
availableChannels.Add(new Channel { Name = "#japanese" });
|
availableChannels.Add(new Channel { Name = "#japanese" });
|
||||||
Dependencies.Cache(chatManager);
|
Dependencies.Cache(chatManager);
|
||||||
|
|
||||||
Dependencies.Cache(new ChatOverlay());
|
|
||||||
Dependencies.CacheAs<IDialogOverlay>(dialogOverlay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
|
@ -12,6 +12,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -63,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
channelManager,
|
channelManager,
|
||||||
chatOverlay = new TestChatOverlayV2 { RelativeSizeAxes = Axes.Both },
|
chatOverlay = new TestChatOverlayV2(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -417,6 +418,67 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddAssert("Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
|
AddAssert("Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestKeyboardCloseAndRestoreChannel()
|
||||||
|
{
|
||||||
|
AddStep("Show overlay with channel 1", () =>
|
||||||
|
{
|
||||||
|
channelManager.JoinChannel(testChannel1);
|
||||||
|
chatOverlay.Show();
|
||||||
|
});
|
||||||
|
AddAssert("Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
|
||||||
|
|
||||||
|
AddStep("Press document close keys", () => InputManager.Keys(PlatformAction.DocumentClose));
|
||||||
|
AddAssert("Listing is visible", () => listingIsVisible);
|
||||||
|
|
||||||
|
AddStep("Press tab restore keys", () => InputManager.Keys(PlatformAction.TabRestore));
|
||||||
|
AddAssert("Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestKeyboardNewChannel()
|
||||||
|
{
|
||||||
|
AddStep("Show overlay with channel 1", () =>
|
||||||
|
{
|
||||||
|
channelManager.JoinChannel(testChannel1);
|
||||||
|
chatOverlay.Show();
|
||||||
|
});
|
||||||
|
AddAssert("Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
|
||||||
|
|
||||||
|
AddStep("Press tab new keys", () => InputManager.Keys(PlatformAction.TabNew));
|
||||||
|
AddAssert("Listing is visible", () => listingIsVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestKeyboardNextChannel()
|
||||||
|
{
|
||||||
|
Channel pmChannel1 = createPrivateChannel();
|
||||||
|
Channel pmChannel2 = createPrivateChannel();
|
||||||
|
|
||||||
|
AddStep("Show overlay with channels", () =>
|
||||||
|
{
|
||||||
|
channelManager.JoinChannel(testChannel1);
|
||||||
|
channelManager.JoinChannel(testChannel2);
|
||||||
|
channelManager.JoinChannel(pmChannel1);
|
||||||
|
channelManager.JoinChannel(pmChannel2);
|
||||||
|
chatOverlay.Show();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
|
||||||
|
|
||||||
|
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
||||||
|
AddAssert("Channel 2 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel2);
|
||||||
|
|
||||||
|
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
||||||
|
AddAssert("PM Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == pmChannel1);
|
||||||
|
|
||||||
|
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
||||||
|
AddAssert("PM Channel 2 displayed", () => channelIsVisible && currentDrawableChannel.Channel == pmChannel2);
|
||||||
|
|
||||||
|
AddStep("Press document next keys", () => InputManager.Keys(PlatformAction.DocumentNext));
|
||||||
|
AddAssert("Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
|
||||||
|
}
|
||||||
|
|
||||||
private bool listingIsVisible =>
|
private bool listingIsVisible =>
|
||||||
chatOverlay.ChildrenOfType<ChannelListing>().Single().State.Value == Visibility.Visible;
|
chatOverlay.ChildrenOfType<ChannelListing>().Single().State.Value == Visibility.Visible;
|
||||||
|
|
||||||
@ -467,6 +529,16 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Type = ChannelType.Public,
|
Type = ChannelType.Public,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private Channel createPrivateChannel()
|
||||||
|
{
|
||||||
|
int id = RNG.Next(0, 10000);
|
||||||
|
return new Channel(new APIUser
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Username = $"test user {id}",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private class TestChatOverlayV2 : ChatOverlayV2
|
private class TestChatOverlayV2 : ChatOverlayV2
|
||||||
{
|
{
|
||||||
public bool SlowLoading { get; set; }
|
public bool SlowLoading { get; set; }
|
||||||
|
@ -208,7 +208,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
};
|
};
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
public ChatOverlay ChatOverlay { get; } = new ChatOverlay();
|
public ChatOverlayV2 ChatOverlay { get; } = new ChatOverlayV2();
|
||||||
|
|
||||||
private readonly MessageNotifier messageNotifier = new MessageNotifier();
|
private readonly MessageNotifier messageNotifier = new MessageNotifier();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Configuration
|
|||||||
|
|
||||||
SetDefault(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation);
|
SetDefault(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation);
|
||||||
|
|
||||||
SetDefault(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2f, 1f);
|
SetDefault(OsuSetting.ChatDisplayHeight, ChatOverlayV2.DEFAULT_HEIGHT, 0.2f, 1f);
|
||||||
|
|
||||||
SetDefault(OsuSetting.BeatmapListingCardSize, BeatmapCardSize.Normal);
|
SetDefault(OsuSetting.BeatmapListingCardSize, BeatmapCardSize.Normal);
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Online.Chat
|
|||||||
private INotificationOverlay notifications { get; set; }
|
private INotificationOverlay notifications { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private ChatOverlay chatOverlay { get; set; }
|
private ChatOverlayV2 chatOverlay { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private ChannelManager channelManager { get; set; }
|
private ChannelManager channelManager { get; set; }
|
||||||
@ -170,7 +170,7 @@ namespace osu.Game.Online.Chat
|
|||||||
public override bool IsImportant => false;
|
public override bool IsImportant => false;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay)
|
private void load(OsuColour colours, ChatOverlayV2 chatOverlay, INotificationOverlay notificationOverlay)
|
||||||
{
|
{
|
||||||
IconBackground.Colour = colours.PurpleDark;
|
IconBackground.Colour = colours.PurpleDark;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
public Toolbar Toolbar;
|
public Toolbar Toolbar;
|
||||||
|
|
||||||
private ChatOverlay chatOverlay;
|
private ChatOverlayV2 chatOverlay;
|
||||||
|
|
||||||
private ChannelManager channelManager;
|
private ChannelManager channelManager;
|
||||||
|
|
||||||
@ -848,7 +848,7 @@ namespace osu.Game
|
|||||||
loadComponentSingleFile(news = new NewsOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(news = new NewsOverlay(), overlayContent.Add, true);
|
||||||
var rankingsOverlay = loadComponentSingleFile(new RankingsOverlay(), overlayContent.Add, true);
|
var rankingsOverlay = loadComponentSingleFile(new RankingsOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
|
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
|
||||||
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(chatOverlay = new ChatOverlayV2(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(new MessageNotifier(), AddInternal, true);
|
loadComponentSingleFile(new MessageNotifier(), AddInternal, true);
|
||||||
loadComponentSingleFile(Settings = new SettingsOverlay(), leftFloatingOverlayContent.Add, true);
|
loadComponentSingleFile(Settings = new SettingsOverlay(), leftFloatingOverlayContent.Add, true);
|
||||||
loadComponentSingleFile(changelogOverlay = new ChangelogOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(changelogOverlay = new ChangelogOverlay(), overlayContent.Add, true);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -22,10 +23,13 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
public Action<Channel>? OnRequestSelect;
|
public Action<Channel>? OnRequestSelect;
|
||||||
public Action<Channel>? OnRequestLeave;
|
public Action<Channel>? OnRequestLeave;
|
||||||
|
|
||||||
|
public IEnumerable<Channel> Channels => publicChannelFlow.Channels.Concat(privateChannelFlow.Channels);
|
||||||
|
|
||||||
public readonly ChannelListing.ChannelListingChannel ChannelListingChannel = new ChannelListing.ChannelListingChannel();
|
public readonly ChannelListing.ChannelListingChannel ChannelListingChannel = new ChannelListing.ChannelListingChannel();
|
||||||
|
|
||||||
private readonly Dictionary<Channel, ChannelListItem> channelMap = new Dictionary<Channel, ChannelListItem>();
|
private readonly Dictionary<Channel, ChannelListItem> channelMap = new Dictionary<Channel, ChannelListItem>();
|
||||||
|
|
||||||
|
private OsuScrollContainer scroll = null!;
|
||||||
private ChannelListItemFlow publicChannelFlow = null!;
|
private ChannelListItemFlow publicChannelFlow = null!;
|
||||||
private ChannelListItemFlow privateChannelFlow = null!;
|
private ChannelListItemFlow privateChannelFlow = null!;
|
||||||
private ChannelListItem selector = null!;
|
private ChannelListItem selector = null!;
|
||||||
@ -40,7 +44,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colourProvider.Background6,
|
Colour = colourProvider.Background6,
|
||||||
},
|
},
|
||||||
new OsuScrollContainer
|
scroll = new OsuScrollContainer
|
||||||
{
|
{
|
||||||
Padding = new MarginPadding { Vertical = 7 },
|
Padding = new MarginPadding { Vertical = 7 },
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -53,12 +57,14 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
publicChannelFlow = new ChannelListItemFlow("CHANNELS"),
|
new ChannelListLabel("CHANNELS"),
|
||||||
|
publicChannelFlow = new ChannelListItemFlow(),
|
||||||
selector = new ChannelListItem(ChannelListingChannel)
|
selector = new ChannelListItem(ChannelListingChannel)
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Bottom = 10 },
|
Margin = new MarginPadding { Bottom = 10 },
|
||||||
},
|
},
|
||||||
privateChannelFlow = new ChannelListItemFlow("DIRECT MESSAGES"),
|
new ChannelListLabel("DIRECT MESSAGES"),
|
||||||
|
privateChannelFlow = new ChannelListItemFlow(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -101,6 +107,8 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
return channelMap[channel];
|
return channelMap[channel];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ScrollChannelIntoView(Channel channel) => scroll.ScrollIntoView(GetItem(channel));
|
||||||
|
|
||||||
private ChannelListItemFlow getFlowForChannel(Channel channel)
|
private ChannelListItemFlow getFlowForChannel(Channel channel)
|
||||||
{
|
{
|
||||||
switch (channel.Type)
|
switch (channel.Type)
|
||||||
@ -112,24 +120,29 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
|||||||
return privateChannelFlow;
|
return privateChannelFlow;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
return publicChannelFlow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChannelListItemFlow : FillFlowContainer
|
private class ChannelListLabel : OsuSpriteText
|
||||||
{
|
{
|
||||||
public ChannelListItemFlow(string label)
|
public ChannelListLabel(string label)
|
||||||
|
{
|
||||||
|
Text = label;
|
||||||
|
Margin = new MarginPadding { Left = 18, Bottom = 5 };
|
||||||
|
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.SemiBold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ChannelListItemFlow : FillFlowContainer<ChannelListItem>
|
||||||
|
{
|
||||||
|
public IEnumerable<Channel> Channels => Children.Select(c => c.Channel);
|
||||||
|
|
||||||
|
public ChannelListItemFlow()
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Vertical;
|
Direction = FillDirection.Vertical;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
Add(new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = label,
|
|
||||||
Margin = new MarginPadding { Left = 18, Bottom = 5 },
|
|
||||||
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.SemiBold),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -13,6 +12,8 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -26,7 +27,7 @@ using osu.Game.Overlays.Chat.Listing;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class ChatOverlayV2 : OsuFocusedOverlayContainer, INamedOverlayComponent
|
public class ChatOverlayV2 : OsuFocusedOverlayContainer, INamedOverlayComponent, IKeyBindingHandler<PlatformAction>
|
||||||
{
|
{
|
||||||
public string IconTexture => "Icons/Hexacons/messaging";
|
public string IconTexture => "Icons/Hexacons/messaging";
|
||||||
public LocalisableString Title => ChatStrings.HeaderTitle;
|
public LocalisableString Title => ChatStrings.HeaderTitle;
|
||||||
@ -47,8 +48,9 @@ namespace osu.Game.Overlays
|
|||||||
private bool isDraggingTopBar;
|
private bool isDraggingTopBar;
|
||||||
private float dragStartChatHeight;
|
private float dragStartChatHeight;
|
||||||
|
|
||||||
|
public const float DEFAULT_HEIGHT = 0.4f;
|
||||||
|
|
||||||
private const int transition_length = 500;
|
private const int transition_length = 500;
|
||||||
private const float default_chat_height = 0.4f;
|
|
||||||
private const float top_bar_height = 40;
|
private const float top_bar_height = 40;
|
||||||
private const float side_bar_width = 190;
|
private const float side_bar_width = 190;
|
||||||
private const float chat_bar_height = 60;
|
private const float chat_bar_height = 60;
|
||||||
@ -70,7 +72,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public ChatOverlayV2()
|
public ChatOverlayV2()
|
||||||
{
|
{
|
||||||
Height = default_chat_height;
|
Height = DEFAULT_HEIGHT;
|
||||||
|
|
||||||
Masking = true;
|
Masking = true;
|
||||||
|
|
||||||
@ -82,6 +84,7 @@ namespace osu.Game.Overlays
|
|||||||
Margin = new MarginPadding { Bottom = -corner_radius };
|
Margin = new MarginPadding { Bottom = -corner_radius };
|
||||||
Padding = new MarginPadding { Bottom = corner_radius };
|
Padding = new MarginPadding { Bottom = corner_radius };
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
Anchor = Anchor.BottomCentre;
|
Anchor = Anchor.BottomCentre;
|
||||||
Origin = Anchor.BottomCentre;
|
Origin = Anchor.BottomCentre;
|
||||||
}
|
}
|
||||||
@ -153,13 +156,15 @@ namespace osu.Game.Overlays
|
|||||||
chatHeight.BindValueChanged(height => { Height = height.NewValue; }, true);
|
chatHeight.BindValueChanged(height => { Height = height.NewValue; }, true);
|
||||||
|
|
||||||
currentChannel.BindTo(channelManager.CurrentChannel);
|
currentChannel.BindTo(channelManager.CurrentChannel);
|
||||||
currentChannel.BindValueChanged(currentChannelChanged, true);
|
|
||||||
|
|
||||||
joinedChannels.BindTo(channelManager.JoinedChannels);
|
joinedChannels.BindTo(channelManager.JoinedChannels);
|
||||||
joinedChannels.BindCollectionChanged(joinedChannelsChanged, true);
|
|
||||||
|
|
||||||
availableChannels.BindTo(channelManager.AvailableChannels);
|
availableChannels.BindTo(channelManager.AvailableChannels);
|
||||||
availableChannels.BindCollectionChanged(availableChannelsChanged, true);
|
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
currentChannel.BindValueChanged(currentChannelChanged, true);
|
||||||
|
joinedChannels.BindCollectionChanged(joinedChannelsChanged, true);
|
||||||
|
availableChannels.BindCollectionChanged(availableChannelsChanged, true);
|
||||||
|
});
|
||||||
|
|
||||||
channelList.OnRequestSelect += channel => channelManager.CurrentChannel.Value = channel;
|
channelList.OnRequestSelect += channel => channelManager.CurrentChannel.Value = channel;
|
||||||
channelList.OnRequestLeave += channel => channelManager.LeaveChannel(channel);
|
channelList.OnRequestLeave += channel => channelManager.LeaveChannel(channel);
|
||||||
@ -193,6 +198,39 @@ namespace osu.Game.Overlays
|
|||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
|
||||||
|
{
|
||||||
|
switch (e.Action)
|
||||||
|
{
|
||||||
|
case PlatformAction.TabNew:
|
||||||
|
currentChannel.Value = channelList.ChannelListingChannel;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case PlatformAction.DocumentClose:
|
||||||
|
channelManager.LeaveChannel(currentChannel.Value);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case PlatformAction.TabRestore:
|
||||||
|
channelManager.JoinLastClosedChannel();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case PlatformAction.DocumentPrevious:
|
||||||
|
cycleChannel(-1);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case PlatformAction.DocumentNext:
|
||||||
|
cycleChannel(1);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(KeyBindingReleaseEvent<PlatformAction> e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnDragStart(DragStartEvent e)
|
protected override bool OnDragStart(DragStartEvent e)
|
||||||
{
|
{
|
||||||
isDraggingTopBar = topBar.IsHovered;
|
isDraggingTopBar = topBar.IsHovered;
|
||||||
@ -294,6 +332,10 @@ namespace osu.Game.Overlays
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mark channel as read when channel switched
|
||||||
|
if (newChannel.Messages.Any())
|
||||||
|
channelManager.MarkChannelAsRead(newChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual ChatOverlayDrawableChannel CreateDrawableChannel(Channel newChannel) => new ChatOverlayDrawableChannel(newChannel);
|
protected virtual ChatOverlayDrawableChannel CreateDrawableChannel(Channel newChannel) => new ChatOverlayDrawableChannel(newChannel);
|
||||||
@ -303,7 +345,7 @@ namespace osu.Game.Overlays
|
|||||||
switch (args.Action)
|
switch (args.Action)
|
||||||
{
|
{
|
||||||
case NotifyCollectionChangedAction.Add:
|
case NotifyCollectionChangedAction.Add:
|
||||||
IEnumerable<Channel> newChannels = filterChannels(args.NewItems);
|
IEnumerable<Channel> newChannels = args.NewItems.OfType<Channel>().Where(isChatChannel);
|
||||||
|
|
||||||
foreach (var channel in newChannels)
|
foreach (var channel in newChannels)
|
||||||
channelList.AddChannel(channel);
|
channelList.AddChannel(channel);
|
||||||
@ -311,7 +353,7 @@ namespace osu.Game.Overlays
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Remove:
|
case NotifyCollectionChangedAction.Remove:
|
||||||
IEnumerable<Channel> leftChannels = filterChannels(args.OldItems);
|
IEnumerable<Channel> leftChannels = args.OldItems.OfType<Channel>().Where(isChatChannel);
|
||||||
|
|
||||||
foreach (var channel in leftChannels)
|
foreach (var channel in leftChannels)
|
||||||
{
|
{
|
||||||
@ -333,9 +375,6 @@ namespace osu.Game.Overlays
|
|||||||
private void availableChannelsChanged(object sender, NotifyCollectionChangedEventArgs args)
|
private void availableChannelsChanged(object sender, NotifyCollectionChangedEventArgs args)
|
||||||
=> channelListing.UpdateAvailableChannels(channelManager.AvailableChannels);
|
=> channelListing.UpdateAvailableChannels(channelManager.AvailableChannels);
|
||||||
|
|
||||||
private IEnumerable<Channel> filterChannels(IList channels)
|
|
||||||
=> channels.Cast<Channel>().Where(c => c.Type == ChannelType.Public || c.Type == ChannelType.PM);
|
|
||||||
|
|
||||||
private void handleChatMessage(string message)
|
private void handleChatMessage(string message)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(message))
|
if (string.IsNullOrWhiteSpace(message))
|
||||||
@ -346,5 +385,36 @@ namespace osu.Game.Overlays
|
|||||||
else
|
else
|
||||||
channelManager.PostMessage(message);
|
channelManager.PostMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cycleChannel(int direction)
|
||||||
|
{
|
||||||
|
List<Channel> overlayChannels = channelList.Channels.ToList();
|
||||||
|
|
||||||
|
if (overlayChannels.Count < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int currentIndex = overlayChannels.IndexOf(currentChannel.Value);
|
||||||
|
|
||||||
|
currentChannel.Value = overlayChannels[(currentIndex + direction + overlayChannels.Count) % overlayChannels.Count];
|
||||||
|
|
||||||
|
channelList.ScrollChannelIntoView(currentChannel.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether a channel should be displayed in this overlay, based on its type.
|
||||||
|
/// </summary>
|
||||||
|
private static bool isChatChannel(Channel channel)
|
||||||
|
{
|
||||||
|
switch (channel.Type)
|
||||||
|
{
|
||||||
|
case ChannelType.Multiplayer:
|
||||||
|
case ChannelType.Spectator:
|
||||||
|
case ChannelType.Temporary:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
private UserProfileOverlay userOverlay { get; set; }
|
private UserProfileOverlay userOverlay { get; set; }
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private ChatOverlay chatOverlay { get; set; }
|
private ChatOverlayV2 chatOverlay { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider apiProvider { get; set; }
|
private IAPIProvider apiProvider { get; set; }
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(ChatOverlay chat)
|
private void load(ChatOverlayV2 chat)
|
||||||
{
|
{
|
||||||
StateContainer = chat;
|
StateContainer = chat;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user