Move ChannelManager to OsuGame

There's no reason for it to exist at OsuGameBase
This commit is contained in:
Dean Herbert 2018-09-14 12:06:04 +09:00
parent be1365fb18
commit 3c8c7a0459
4 changed files with 29 additions and 20 deletions

View File

@ -4,7 +4,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Online.Chat;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Chat; using osu.Game.Overlays.Chat;
using osu.Game.Overlays.Chat.Tabs; using osu.Game.Overlays.Chat.Tabs;
@ -26,12 +29,17 @@ namespace osu.Game.Tests.Visual
typeof(TabCloseButton) typeof(TabCloseButton)
}; };
public TestCaseChatDisplay() [Cached]
private readonly ChannelManager channelManager = new ChannelManager();
[BackgroundDependencyLoader]
private void load()
{ {
Add(new ChatOverlay Children = new Drawable[]
{ {
State = Visibility.Visible channelManager,
}); new ChatOverlay { State = Visibility.Visible }
};
} }
} }
} }

View File

@ -52,6 +52,17 @@ namespace osu.Game.Online.Chat
private IAPIProvider api; private IAPIProvider api;
private ScheduledDelegate fetchMessagesScheduleder; private ScheduledDelegate fetchMessagesScheduleder;
public ChannelManager()
{
CurrentChannel.ValueChanged += currentChannelChanged;
channelMessagesHandler = new IncomingMessagesHandler(
lastId => new GetMessagesRequest(JoinedChannels.Where(c => c.Target == TargetType.Channel), lastId), handleChannelMessages);
privateMessagesHandler = new IncomingMessagesHandler(
lastId => new GetPrivateMessagesRequest(lastId),handleUserMessages);
}
/// <summary> /// <summary>
/// Opens a channel or switches to the channel if already opened. /// Opens a channel or switches to the channel if already opened.
/// </summary> /// </summary>
@ -79,17 +90,6 @@ namespace osu.Game.Online.Chat
?? new PrivateChannel { User = user }; ?? new PrivateChannel { User = user };
} }
public ChannelManager()
{
CurrentChannel.ValueChanged += currentChannelChanged;
channelMessagesHandler = new IncomingMessagesHandler(
lastId => new GetMessagesRequest(JoinedChannels.Where(c => c.Target == TargetType.Channel), lastId), handleChannelMessages);
privateMessagesHandler = new IncomingMessagesHandler(
lastId => new GetPrivateMessagesRequest(lastId),handleUserMessages);
}
private void currentChannelChanged(Channel channel) private void currentChannelChanged(Channel channel)
{ {
if (!JoinedChannels.Contains(channel)) if (!JoinedChannels.Contains(channel))

View File

@ -31,6 +31,7 @@ using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Online.Chat;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Skinning; using osu.Game.Skinning;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -339,6 +340,11 @@ namespace osu.Game
//overlay elements //overlay elements
loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);
loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add);
loadComponentSingleFile(new ChannelManager(), channelManager =>
{
dependencies.Cache(channelManager);
AddInternal(channelManager);
});
loadComponentSingleFile(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(chat = new ChatOverlay { Depth = -1 }, mainContent.Add);
loadComponentSingleFile(settings = new MainSettings loadComponentSingleFile(settings = new MainSettings
{ {

View File

@ -27,7 +27,6 @@ using osu.Game.Database;
using osu.Game.Input; using osu.Game.Input;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Online.Chat;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -152,10 +151,6 @@ namespace osu.Game
dependencies.Cache(api); dependencies.Cache(api);
dependencies.CacheAs<IAPIProvider>(api); dependencies.CacheAs<IAPIProvider>(api);
var channelManager = new ChannelManager();
dependencies.Cache(channelManager);
AddInternal(channelManager);
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory)); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory));
dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage));
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, api, Audio, Host)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, api, Audio, Host));