1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 04:02:59 +08:00

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.Collections.Generic;
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.Chat;
using osu.Game.Overlays;
using osu.Game.Overlays.Chat;
using osu.Game.Overlays.Chat.Tabs;
@ -26,12 +29,17 @@ namespace osu.Game.Tests.Visual
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 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>
/// Opens a channel or switches to the channel if already opened.
/// </summary>
@ -79,17 +90,6 @@ namespace osu.Game.Online.Chat
?? 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)
{
if (!JoinedChannels.Contains(channel))

View File

@ -31,6 +31,7 @@ using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets;
using osu.Game.Screens.Play;
using osu.Game.Input.Bindings;
using osu.Game.Online.Chat;
using osu.Game.Rulesets.Mods;
using osu.Game.Skinning;
using OpenTK.Graphics;
@ -339,6 +340,11 @@ namespace osu.Game
//overlay elements
loadComponentSingleFile(direct = new DirectOverlay { 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(settings = new MainSettings
{

View File

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