diff --git a/EOLib/Domain/Interact/Jukebox/JukeboxActions.cs b/EOLib/Domain/Interact/Jukebox/JukeboxActions.cs index 444aeba55..2aa3c265b 100644 --- a/EOLib/Domain/Interact/Jukebox/JukeboxActions.cs +++ b/EOLib/Domain/Interact/Jukebox/JukeboxActions.cs @@ -1,9 +1,7 @@ using AutomaticTypeMapper; using EOLib.Domain.Character; -using EOLib.Domain.Map; using EOLib.IO; using EOLib.IO.Repositories; -using EOLib.Net; using EOLib.Net.Communication; using Moffat.EndlessOnline.SDK.Protocol.Net.Client; using Optional.Collections; diff --git a/EOLib/Domain/Notifiers/IJukeboxNotifier.cs b/EOLib/Domain/Notifiers/IJukeboxNotifier.cs new file mode 100644 index 000000000..16f29bc9e --- /dev/null +++ b/EOLib/Domain/Notifiers/IJukeboxNotifier.cs @@ -0,0 +1,16 @@ +using AutomaticTypeMapper; + +namespace EOLib.Domain.Notifiers +{ + public interface IJukeboxNotifier + { + void JukeboxUnavailable(); + } + + [AutoMappedType] + public class NoOpJukeboxNotifier : IJukeboxNotifier + { + public void JukeboxUnavailable() { } + } + +} \ No newline at end of file diff --git a/EOLib/PacketHandlers/Jukebox/JukeboxReplyHandler.cs b/EOLib/PacketHandlers/Jukebox/JukeboxReplyHandler.cs new file mode 100644 index 000000000..76dbb3bd5 --- /dev/null +++ b/EOLib/PacketHandlers/Jukebox/JukeboxReplyHandler.cs @@ -0,0 +1,34 @@ +using AutomaticTypeMapper; +using EOLib.Domain.Login; +using EOLib.Domain.Notifiers; +using EOLib.Net.Handlers; +using Moffat.EndlessOnline.SDK.Protocol.Net; +using Moffat.EndlessOnline.SDK.Protocol.Net.Server; +using System.Collections.Generic; + +namespace EOLib.PacketHandlers.Jukebox +{ + [AutoMappedType] + public class JukeboxReplyHandler : InGameOnlyPacketHandler + { + private readonly IEnumerable _jukeboxNotifiers; + + public override PacketFamily Family => PacketFamily.Jukebox; + + public override PacketAction Action => PacketAction.Reply; + + public JukeboxReplyHandler(IPlayerInfoProvider playerInfoProvider, + IEnumerable jukeboxNotifiers) + : base(playerInfoProvider) + { + _jukeboxNotifiers = jukeboxNotifiers; + } + + public override bool HandlePacket(JukeboxReplyServerPacket packet) + { + foreach (var notifier in _jukeboxNotifiers) + notifier.JukeboxUnavailable(); + return true; + } + } +} diff --git a/EndlessClient/Subscribers/JukeboxEventSubscriber.cs b/EndlessClient/Subscribers/JukeboxEventSubscriber.cs new file mode 100644 index 000000000..bdf194b66 --- /dev/null +++ b/EndlessClient/Subscribers/JukeboxEventSubscriber.cs @@ -0,0 +1,24 @@ +using AutomaticTypeMapper; +using EndlessClient.Dialogs.Factories; +using EOLib.Domain.Notifiers; +using EOLib.Localization; + +namespace EndlessClient.Subscribers +{ + [AutoMappedType] + public class JukeboxEventSubscriber : IJukeboxNotifier + { + private readonly IEOMessageBoxFactory _messageBoxFactory; + + public JukeboxEventSubscriber(IEOMessageBoxFactory messageBoxFactory) + { + _messageBoxFactory = messageBoxFactory; + } + + public void JukeboxUnavailable() + { + var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.JUKEBOX_REQUESTED_RECENTLY); + dlg.ShowDialog(); + } + } +}