-
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 Guild_Request packet handler * Remove GuildCreationRequest type Fix formatting on CreateMessageBox Use member initialization syntax for packet
- Loading branch information
Showing
5 changed files
with
114 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Interact.Guild; | ||
|
||
namespace EOLib.Domain.Notifiers | ||
{ | ||
public interface IGuildNotifier | ||
{ | ||
void NotifyGuildCreationRequest(int creatorPlayerID, string guildIdentity); | ||
} | ||
|
||
[AutoMappedType] | ||
public class NoOpGuildNotifier : IGuildNotifier | ||
{ | ||
public void NotifyGuildCreationRequest(int creatorPlayerID, string guildIdentity) { } | ||
} | ||
} |
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,38 @@ | ||
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.Guild | ||
{ | ||
[AutoMappedType] | ||
|
||
public class GuildRequestHandler : InGameOnlyPacketHandler<GuildRequestServerPacket> | ||
{ | ||
private readonly IEnumerable<IGuildNotifier> _guildNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.Guild; | ||
|
||
public override PacketAction Action => PacketAction.Request; | ||
|
||
public GuildRequestHandler(IPlayerInfoProvider playerInfoProvider, | ||
IEnumerable<IGuildNotifier> guildNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_guildNotifiers = guildNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(GuildRequestServerPacket packet) | ||
{ | ||
foreach(var notifier in _guildNotifiers) | ||
{ | ||
notifier.NotifyGuildCreationRequest(packet.PlayerId, packet.GuildIdentity); | ||
} | ||
|
||
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,55 @@ | ||
using AutomaticTypeMapper; | ||
using EndlessClient.Audio; | ||
using EndlessClient.Dialogs.Factories; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.Localization; | ||
using EOLib.Net.Communication; | ||
using Moffat.EndlessOnline.SDK.Protocol.Net.Client; | ||
|
||
namespace EndlessClient.Subscribers | ||
{ | ||
[AutoMappedType] | ||
public class GuildEventSubscriber : IGuildNotifier | ||
{ | ||
private readonly IEOMessageBoxFactory _messageBoxFactory; | ||
private readonly ILocalizedStringFinder _localizedStringFinder; | ||
private readonly IPacketSendService _packetSendService; | ||
private readonly ISfxPlayer _sfxPlayer; | ||
|
||
public GuildEventSubscriber(IEOMessageBoxFactory messageBoxFactory, ILocalizedStringFinder localizedStringFinder, IPacketSendService packetSendService, ISfxPlayer sfxPlayer) | ||
{ | ||
_messageBoxFactory = messageBoxFactory; | ||
_localizedStringFinder = localizedStringFinder; | ||
_packetSendService = packetSendService; | ||
_sfxPlayer = sfxPlayer; | ||
} | ||
|
||
public void NotifyGuildCreationRequest(int creatorPlayerID, string guildIdentity) | ||
{ | ||
_sfxPlayer.PlaySfx(SoundEffectID.ServerMessage); | ||
|
||
var dlg = _messageBoxFactory.CreateMessageBox( | ||
$"{guildIdentity}" + | ||
" " + _localizedStringFinder.GetString(DialogResourceID.GUILD_INVITES_YOU_TO_JOIN) + | ||
" " + _localizedStringFinder.GetString(EOResourceID.GUILD_JOINING_A_GUILD_IS_FREE) + | ||
" " + _localizedStringFinder.GetString(EOResourceID.GUILD_PLEASE_CONSIDER_CAREFULLY) + | ||
" " + _localizedStringFinder.GetString(EOResourceID.GUILD_DO_YOU_ACCEPT), | ||
caption: _localizedStringFinder.GetString(DialogResourceID.GUILD_INVITATION), | ||
whichButtons: Dialogs.EODialogButtons.OkCancel, | ||
style: Dialogs.EOMessageBoxStyle.LargeDialogSmallHeader); | ||
|
||
dlg.DialogClosing += (_, e) => | ||
{ | ||
if (e.Result == XNAControls.XNADialogResult.OK) | ||
{ | ||
_packetSendService.SendPacket(new GuildAcceptClientPacket() | ||
{ | ||
InviterPlayerId = creatorPlayerID | ||
}); | ||
} | ||
}; | ||
|
||
dlg.ShowDialog(); | ||
} | ||
} | ||
} |