Skip to content

Commit

Permalink
Remember last player an item was sent to
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed May 19, 2024
1 parent cafeac9 commit d29c395
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Fika.Core/UI/Patches/ItemContextPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Fika.Core.UI.Patches
{
public class ItemContextPatch : ModulePatch
{
private static int lastIndex = 0;

protected override MethodBase GetTargetMethod()
{
return typeof(SimpleContextMenu).GetMethod(nameof(SimpleContextMenu.method_0)).MakeGenericMethod(typeof(EItemInfoButton));
Expand Down Expand Up @@ -82,6 +84,11 @@ private static void Prefix(ItemInfoInteractionsAbstractClass<EItemInfoButton> co
sendItemUI.PlayersDropdown.ClearOptions();
sendItemUI.PlayersDropdown.AddOptions(optionDatas);
if (sendItemUI.PlayersDropdown.options.Count >= lastIndex)
{
sendItemUI.PlayersDropdown.value = lastIndex;
}
sendItemUI.PlayersDropdown.onValueChanged.AddListener((value) =>
{
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuDropdownSelect);
Expand All @@ -102,6 +109,7 @@ private static void Prefix(ItemInfoInteractionsAbstractClass<EItemInfoButton> co
if (sendItemUI.PlayersDropdown.options[sendItemUI.PlayersDropdown.value].text != null)
{
string player = sendItemUI.PlayersDropdown.options[sendItemUI.PlayersDropdown.value].text;
lastIndex = sendItemUI.PlayersDropdown.value;
if (Singleton<ClientApplication<ISession>>.Instantiated)
{
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.TradeOperationComplete);
Expand Down

0 comments on commit d29c395

Please sign in to comment.