-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement LOCKER_SPEC packet handler
- Loading branch information
1 parent
817e9d2
commit 5d1ccc5
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using AutomaticTypeMapper; | ||
|
||
namespace EOLib.Domain.Notifiers | ||
{ | ||
public interface ILockerEventNotifier | ||
{ | ||
void NotifyLockerFull(int maxItems); | ||
} | ||
|
||
[AutoMappedType] | ||
public class NoOpLockerEventNotifier : ILockerEventNotifier | ||
{ | ||
public void NotifyLockerFull(int maxItems) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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.Locker | ||
{ | ||
[AutoMappedType] | ||
public class LockerSpecHandler : InGameOnlyPacketHandler<LockerSpecServerPacket> | ||
{ | ||
private readonly IEnumerable<ILockerEventNotifier> _lockerEventNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.Locker; | ||
|
||
public override PacketAction Action => PacketAction.Spec; | ||
|
||
public LockerSpecHandler(IPlayerInfoProvider playerInfoProvider, | ||
IEnumerable<ILockerEventNotifier> lockerEventNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_lockerEventNotifiers = lockerEventNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(LockerSpecServerPacket packet) | ||
{ | ||
foreach (var notifier in _lockerEventNotifiers) | ||
{ | ||
notifier.NotifyLockerFull(packet.LockerMaxItems); | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using AutomaticTypeMapper; | ||
using EndlessClient.Dialogs.Factories; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.Localization; | ||
|
||
namespace EndlessClient.Subscribers | ||
{ | ||
[AutoMappedType] | ||
public class LockerEventSubscriber : ILockerEventNotifier | ||
{ | ||
private readonly IEOMessageBoxFactory _messageBoxFactory; | ||
private readonly ILocalizedStringFinder _localizedStringFinder; | ||
|
||
public LockerEventSubscriber(IEOMessageBoxFactory messageBoxFactory, | ||
ILocalizedStringFinder localizedStringFinder) | ||
{ | ||
_messageBoxFactory = messageBoxFactory; | ||
_localizedStringFinder = localizedStringFinder; | ||
} | ||
|
||
public void NotifyLockerFull(int maxItems) | ||
{ | ||
var message = _localizedStringFinder.GetString(DialogResourceID.LOCKER_FULL_DIFF_ITEMS_MAX + 1); | ||
var caption = _localizedStringFinder.GetString(DialogResourceID.LOCKER_FULL_DIFF_ITEMS_MAX); | ||
|
||
var dlg = _messageBoxFactory.CreateMessageBox(message.Replace("25", $"{maxItems}"), caption); | ||
dlg.ShowDialog(); | ||
} | ||
} | ||
} |