Skip to content

Commit

Permalink
Resolved: Missing Sound Effect on Gold Drop Warning #319 (#343)
Browse files Browse the repository at this point in the history
- Added "Login" sound effect to gold drop warning dialog.
- Ensured single occurrence of warning message and sound, aligning with Vanilla EO.
- Limit button click sound to only the "cancel" button of ItemTransferDialog, aligning with Vanilla EO.
  • Loading branch information
sjbmcg authored Apr 23, 2024
1 parent 7711215 commit 7722bc2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
29 changes: 21 additions & 8 deletions EndlessClient/Controllers/InventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using EndlessClient.HUD.Panels;
using EndlessClient.Rendering.Character;
using EndlessClient.Rendering.Map;
using EndlessClient.Audio;
using EOLib;
using EOLib.Domain.Chat;
using EOLib.Domain.Character;
Expand All @@ -26,7 +27,7 @@

namespace EndlessClient.Controllers
{
[AutoMappedType]
[AutoMappedType(IsSingleton = true)]
public class InventoryController : IInventoryController
{
private readonly IItemActions _itemActions;
Expand All @@ -50,6 +51,9 @@ public class InventoryController : IInventoryController
private readonly IEOMessageBoxFactory _eoMessageBoxFactory;
private readonly IChatRepository _chatRepository;
private readonly ILocalizedStringFinder _localizedStringFinder;
private readonly ISfxPlayer _sfxPlayer;

private bool _goldWarningShown = false;

public InventoryController(IItemActions itemActions,
IInGameDialogActions inGameDialogActions,
Expand All @@ -71,7 +75,8 @@ public InventoryController(IItemActions itemActions,
IItemTransferDialogFactory itemTransferDialogFactory,
IEOMessageBoxFactory eoMessageBoxFactory,
IChatRepository chatRepository,
ILocalizedStringFinder localizedStringFinder)
ILocalizedStringFinder localizedStringFinder,
ISfxPlayer sfxPlayer)
{
_itemActions = itemActions;
_inGameDialogActions = inGameDialogActions;
Expand All @@ -94,6 +99,7 @@ public InventoryController(IItemActions itemActions,
_eoMessageBoxFactory = eoMessageBoxFactory;
_chatRepository = chatRepository;
_localizedStringFinder = localizedStringFinder;
_sfxPlayer = sfxPlayer;
}

public void ShowPaperdollDialog()
Expand Down Expand Up @@ -238,7 +244,7 @@ public void DropItem(EIFRecord itemData, InventoryItem inventoryItem)
else if (validationResult == ItemDropResult.TooFar)
{
var localizedMessage = _localizedStringFinder.GetString(EOResourceID.STATUS_LABEL_ITEM_DROP_OUT_OF_RANGE);
var chatData = new ChatData(ChatTab.System, "System",localizedMessage, ChatIcon.DotDotDotDot);
var chatData = new ChatData(ChatTab.System, "System", localizedMessage, ChatIcon.DotDotDotDot);
_statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_ITEM_DROP_OUT_OF_RANGE);
_chatRepository.AllChat[ChatTab.System].Add(chatData);
}
Expand Down Expand Up @@ -348,10 +354,10 @@ public void TradeItem(EIFRecord itemData, InventoryItem inventoryItem)
EOResourceID.DIALOG_TRANSFER_OFFER);
}
}

private void DoItemDrop(EIFRecord itemData, InventoryItem inventoryItem, Action<int> dropAction,
ItemTransferDialog.TransferType transferType = ItemTransferDialog.TransferType.DropItems,
EOResourceID message = EOResourceID.DIALOG_TRANSFER_DROP)
ItemTransferDialog.TransferType transferType = ItemTransferDialog.TransferType.DropItems,
EOResourceID message = EOResourceID.DIALOG_TRANSFER_DROP)
{
if (inventoryItem.Amount > 1)
{
Expand All @@ -360,17 +366,24 @@ private void DoItemDrop(EIFRecord itemData, InventoryItem inventoryItem, Action<
transferType,
inventoryItem.Amount,
message);

transferDialog.DialogClosing += (sender, e) =>
{
if (e.Result == XNADialogResult.OK)
{
if (inventoryItem.ItemID == 1 && transferDialog.SelectedAmount > 10000 && transferType == ItemTransferDialog.TransferType.DropItems)
var isLargeGoldItemDrop = inventoryItem.ItemID == 1 && inventoryItem.Amount > 10000 && transferType == ItemTransferDialog.TransferType.DropItems;

if (isLargeGoldItemDrop && !_goldWarningShown)
{
var warningMsg = _eoMessageBoxFactory.CreateMessageBox(DialogResourceID.DROP_MANY_GOLD_ON_GROUND, EODialogButtons.OkCancel);
_sfxPlayer.PlaySfx(SoundEffectID.Login);
warningMsg.DialogClosing += (_, warningArgs) =>
{
if (warningArgs.Result == XNADialogResult.OK)
{
_goldWarningShown = true;
dropAction(transferDialog.SelectedAmount);
}
};
warningMsg.ShowDialog();
}
Expand Down Expand Up @@ -411,4 +424,4 @@ public interface IInventoryController

void TradeItem(EIFRecord itemData, InventoryItem inventoryItem);
}
}
}
12 changes: 10 additions & 2 deletions EndlessClient/Dialogs/Factories/ItemTransferDialogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using EndlessClient.HUD.Chat;
using EOLib.Graphics;
using EOLib.Localization;
using XNAControls;

namespace EndlessClient.Dialogs.Factories
{
Expand Down Expand Up @@ -44,7 +45,14 @@ public ItemTransferDialog CreateItemTransferDialog(string itemName, ItemTransfer
transferType,
totalAmount,
message);
dlg.DialogClosing += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.DialogButtonClick);

dlg.DialogClosing += (sender, args) =>
{
if (args.Result == XNADialogResult.Cancel)
{
_sfxPlayer.PlaySfx(SoundEffectID.DialogButtonClick);
}
};
return dlg;
}
}
Expand All @@ -53,4 +61,4 @@ public interface IItemTransferDialogFactory
{
ItemTransferDialog CreateItemTransferDialog(string itemName, ItemTransferDialog.TransferType transferType, int totalAmount, EOResourceID message);
}
}
}

0 comments on commit 7722bc2

Please sign in to comment.