-
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 MESSAGE_ACCEPT handler. Allows for more player commands to …
…work on BU Note that the dialog text is currently hacked into multiple lines based on observations from BU using spaces to pad messages into multiple lines
- Loading branch information
1 parent
4f9842d
commit 482bc66
Showing
6 changed files
with
155 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,16 @@ | ||
using AutomaticTypeMapper; | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.Domain.Notifiers | ||
{ | ||
public interface IUserInterfaceNotifier | ||
{ | ||
void NotifyMessageDialog(string title, IReadOnlyList<string> messages); | ||
} | ||
|
||
[AutoMappedType] | ||
public class NoOpUserInterfaceNotifier : IUserInterfaceNotifier | ||
{ | ||
public void NotifyMessageDialog(string title, IReadOnlyList<string> messages) { } | ||
} | ||
} |
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,42 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Login; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.PacketHandlers.Message | ||
{ | ||
/// <summary> | ||
/// Shows a message dialog (ScrollingListDialogSize.Large, ScrollingListDialog.ListItemStyle.Small) | ||
/// </summary> | ||
[AutoMappedType] | ||
public class MessageAcceptHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly IEnumerable<IUserInterfaceNotifier> _userInterfaceNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.Message; | ||
|
||
public override PacketAction Action => PacketAction.Accept; | ||
|
||
public MessageAcceptHandler(IPlayerInfoProvider playerInfoProvider, | ||
IEnumerable<IUserInterfaceNotifier> userInterfaceNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_userInterfaceNotifiers = userInterfaceNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var title = packet.ReadBreakString(); | ||
var messages = new List<string>(); | ||
while (packet.ReadPosition < packet.Length) | ||
messages.Add(packet.ReadBreakString()); | ||
|
||
foreach (var notifier in _userInterfaceNotifiers) | ||
notifier.NotifyMessageDialog(title, messages); | ||
|
||
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
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
30 changes: 30 additions & 0 deletions
30
EndlessClient/Dialogs/Factories/ScrollingListDialogFactory.cs
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.Services; | ||
using EOLib.Graphics; | ||
|
||
namespace EndlessClient.Dialogs.Factories | ||
{ | ||
[AutoMappedType] | ||
public class ScrollingListDialogFactory : IScrollingListDialogFactory | ||
{ | ||
private readonly INativeGraphicsManager _nativeGraphicsManager; | ||
private readonly IEODialogButtonService _dialogButtonService; | ||
|
||
public ScrollingListDialogFactory(INativeGraphicsManager nativeGraphicsManager, | ||
IEODialogButtonService dialogButtonService) | ||
{ | ||
_nativeGraphicsManager = nativeGraphicsManager; | ||
_dialogButtonService = dialogButtonService; | ||
} | ||
|
||
public ScrollingListDialog Create(ScrollingListDialogSize size) | ||
{ | ||
return new ScrollingListDialog(_nativeGraphicsManager, _dialogButtonService, size); | ||
} | ||
} | ||
|
||
public interface IScrollingListDialogFactory | ||
{ | ||
ScrollingListDialog Create(ScrollingListDialogSize size); | ||
} | ||
} |
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,23 @@ | ||
using AutomaticTypeMapper; | ||
using EndlessClient.Dialogs.Actions; | ||
using EOLib.Domain.Notifiers; | ||
using System.Collections.Generic; | ||
|
||
namespace EndlessClient.HUD | ||
{ | ||
[AutoMappedType] | ||
public class ServerMessageActions : IUserInterfaceNotifier | ||
{ | ||
private readonly IInGameDialogActions _inGameDialogActions; | ||
|
||
public ServerMessageActions(IInGameDialogActions inGameDialogActions) | ||
{ | ||
_inGameDialogActions = inGameDialogActions; | ||
} | ||
|
||
public void NotifyMessageDialog(string title, IReadOnlyList<string> messages) | ||
{ | ||
_inGameDialogActions.ShowMessageDialog(title, messages); | ||
} | ||
} | ||
} |