TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ GetGamepadInstructions() [1/2]

static string Terraria.UI.ItemSlot.GetGamepadInstructions ( Item[] inv,
int context = 0,
int slot = 0 )
inlinestatic

Definition at line 3568 of file ItemSlot.cs.

3569 {
3570 Player player = Main.player[Main.myPlayer];
3571 string s = "";
3572 if (inv == null || inv[slot] == null || Main.mouseItem == null)
3573 {
3574 return s;
3575 }
3576 if (context == 0 || context == 1 || context == 2)
3577 {
3578 if (inv[slot].type > 0 && inv[slot].stack > 0)
3579 {
3580 if (Main.mouseItem.type > 0)
3581 {
3582 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3583 if (inv[slot].type == Main.mouseItem.type && Main.mouseItem.stack < inv[slot].maxStack && inv[slot].maxStack > 1)
3584 {
3585 s += PlayerInput.BuildCommand(Lang.misc[55].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3586 }
3587 }
3588 else
3589 {
3590 if (context == 0 && player.chest == -1 && PlayerInput.AllowExecutionOfGamepadInstructions)
3591 {
3592 player.DpadRadial.ChangeBinding(slot);
3593 }
3594 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3595 if (inv[slot].maxStack > 1)
3596 {
3597 s += PlayerInput.BuildCommand(Lang.misc[55].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3598 }
3599 }
3600 if (inv[slot].maxStack == 1 && Equippable(inv, context, slot))
3601 {
3602 s += PlayerInput.BuildCommand(Lang.misc[67].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3603 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3604 {
3605 SwapEquip(inv, context, slot);
3608 }
3609 }
3610 s += PlayerInput.BuildCommand(Lang.misc[83].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["SmartCursor"]);
3611 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.SmartCursor)
3612 {
3613 inv[slot].favorited = !inv[slot].favorited;
3614 PlayerInput.LockGamepadButtons("SmartCursor");
3616 }
3617 }
3618 else if (Main.mouseItem.type > 0)
3619 {
3620 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3621 }
3622 }
3623 if (context == 3 || context == 4 || context == 32)
3624 {
3625 if (inv[slot].type > 0 && inv[slot].stack > 0)
3626 {
3627 if (Main.mouseItem.type > 0)
3628 {
3629 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3630 if (inv[slot].type == Main.mouseItem.type && Main.mouseItem.stack < inv[slot].maxStack && inv[slot].maxStack > 1)
3631 {
3632 s += PlayerInput.BuildCommand(Lang.misc[55].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3633 }
3634 }
3635 else
3636 {
3637 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3638 if (inv[slot].maxStack > 1)
3639 {
3640 s += PlayerInput.BuildCommand(Lang.misc[55].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3641 }
3642 }
3643 if (inv[slot].maxStack == 1 && Equippable(inv, context, slot))
3644 {
3645 s += PlayerInput.BuildCommand(Lang.misc[67].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3646 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3647 {
3648 SwapEquip(inv, context, slot);
3651 }
3652 }
3653 if (context == 32)
3654 {
3655 s += PlayerInput.BuildCommand(Lang.misc[83].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["SmartCursor"]);
3656 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.SmartCursor)
3657 {
3658 inv[slot].favorited = !inv[slot].favorited;
3659 PlayerInput.LockGamepadButtons("SmartCursor");
3661 }
3662 }
3663 }
3664 else if (Main.mouseItem.type > 0)
3665 {
3666 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3667 }
3668 }
3669 if (context == 15)
3670 {
3671 if (inv[slot].type > 0 && inv[slot].stack > 0)
3672 {
3673 if (Main.mouseItem.type > 0)
3674 {
3675 if (inv[slot].type == Main.mouseItem.type && Main.mouseItem.stack < inv[slot].maxStack && inv[slot].maxStack > 1)
3676 {
3677 s += PlayerInput.BuildCommand(Lang.misc[91].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3678 }
3679 }
3680 else
3681 {
3682 s += PlayerInput.BuildCommand(Lang.misc[90].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"], PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3683 }
3684 }
3685 else if (Main.mouseItem.type > 0)
3686 {
3687 s += PlayerInput.BuildCommand(Lang.misc[92].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3688 }
3689 }
3690 if (context == 8 || context == 9 || context == 16 || context == 17 || context == 18 || context == 19 || context == 20)
3691 {
3692 if (inv[slot].type > 0 && inv[slot].stack > 0)
3693 {
3694 if (Main.mouseItem.type > 0)
3695 {
3696 if (Equippable(ref Main.mouseItem, context))
3697 {
3698 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3699 }
3700 }
3701 else if (context != 8 || !isEquipLocked(inv[slot].type))
3702 {
3703 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3704 }
3705 if (context == 8 && slot >= 3)
3706 {
3707 bool flag = player.hideVisibleAccessory[slot];
3708 s += PlayerInput.BuildCommand(Lang.misc[flag ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3709 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3710 {
3711 player.hideVisibleAccessory[slot] = !player.hideVisibleAccessory[slot];
3713 if (Main.netMode == 1)
3714 {
3715 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3716 }
3719 }
3720 }
3721 if ((context == 16 || context == 17 || context == 18 || context == 19 || context == 20) && slot < 2)
3722 {
3723 bool flag2 = player.hideMisc[slot];
3724 s += PlayerInput.BuildCommand(Lang.misc[flag2 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3725 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3726 {
3727 if (slot == 0)
3728 {
3729 player.TogglePet();
3730 }
3731 if (slot == 1)
3732 {
3733 player.ToggleLight();
3734 }
3736 if (Main.netMode == 1)
3737 {
3738 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3739 }
3742 }
3743 }
3744 }
3745 else
3746 {
3747 if (Main.mouseItem.type > 0 && Equippable(ref Main.mouseItem, context))
3748 {
3749 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3750 }
3751 if (context == 8 && slot >= 3)
3752 {
3753 int num = slot;
3754 if (num % 10 == 8 && !player.CanDemonHeartAccessoryBeShown())
3755 {
3756 num++;
3757 }
3758 bool flag3 = player.hideVisibleAccessory[num];
3759 s += PlayerInput.BuildCommand(Lang.misc[flag3 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3760 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3761 {
3762 player.hideVisibleAccessory[num] = !player.hideVisibleAccessory[num];
3764 if (Main.netMode == 1)
3765 {
3766 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3767 }
3770 }
3771 }
3772 if ((context == 16 || context == 17 || context == 18 || context == 19 || context == 20) && slot < 2)
3773 {
3774 bool flag4 = player.hideMisc[slot];
3775 s += PlayerInput.BuildCommand(Lang.misc[flag4 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3776 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3777 {
3778 if (slot == 0)
3779 {
3780 player.TogglePet();
3781 }
3782 if (slot == 1)
3783 {
3784 player.ToggleLight();
3785 }
3786 Main.mouseLeftRelease = false;
3788 if (Main.netMode == 1)
3789 {
3790 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3791 }
3794 }
3795 }
3796 }
3797 }
3798 switch (context)
3799 {
3800 case 12:
3801 case 25:
3802 case 27:
3803 case 33:
3804 if (inv[slot].type > 0 && inv[slot].stack > 0)
3805 {
3806 if (Main.mouseItem.type > 0)
3807 {
3808 if (Main.mouseItem.dye > 0)
3809 {
3810 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3811 }
3812 }
3813 else
3814 {
3815 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3816 }
3817 if (context == 12 || context == 25 || context == 27 || context == 33)
3818 {
3819 int num2 = -1;
3820 if (inv == player.dye)
3821 {
3822 num2 = slot;
3823 }
3824 if (inv == player.miscDyes)
3825 {
3826 num2 = 10 + slot;
3827 }
3828 if (num2 != -1)
3829 {
3830 if (num2 < 10)
3831 {
3832 bool flag7 = player.hideVisibleAccessory[slot];
3833 s += PlayerInput.BuildCommand(Lang.misc[flag7 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3834 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3835 {
3836 player.hideVisibleAccessory[slot] = !player.hideVisibleAccessory[slot];
3838 if (Main.netMode == 1)
3839 {
3840 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3841 }
3844 }
3845 }
3846 else
3847 {
3848 bool flag8 = player.hideMisc[slot];
3849 s += PlayerInput.BuildCommand(Lang.misc[flag8 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3850 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3851 {
3852 player.hideMisc[slot] = !player.hideMisc[slot];
3854 if (Main.netMode == 1)
3855 {
3856 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3857 }
3860 }
3861 }
3862 }
3863 }
3864 }
3865 else if (Main.mouseItem.type > 0 && Main.mouseItem.dye > 0)
3866 {
3867 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3868 }
3869 return s;
3870 case 18:
3871 {
3872 if (inv[slot].type > 0 && inv[slot].stack > 0)
3873 {
3874 if (Main.mouseItem.type > 0)
3875 {
3876 if (Main.mouseItem.dye > 0)
3877 {
3878 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3879 }
3880 }
3881 else
3882 {
3883 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3884 }
3885 }
3886 else if (Main.mouseItem.type > 0 && Main.mouseItem.dye > 0)
3887 {
3888 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3889 }
3890 bool enabledSuperCart = player.enabledSuperCart;
3891 s += PlayerInput.BuildCommand(Language.GetTextValue((!enabledSuperCart) ? "UI.EnableSuperCart" : "UI.DisableSuperCart"), false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3892 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3893 {
3894 player.enabledSuperCart = !player.enabledSuperCart;
3896 if (Main.netMode == 1)
3897 {
3898 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3899 }
3902 }
3903 return s;
3904 }
3905 case 6:
3906 if (inv[slot].type > 0 && inv[slot].stack > 0)
3907 {
3908 s = ((Main.mouseItem.type <= 0) ? (s + PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"])) : (s + PlayerInput.BuildCommand(Lang.misc[74].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"])));
3909 }
3910 else if (Main.mouseItem.type > 0)
3911 {
3912 s += PlayerInput.BuildCommand(Lang.misc[74].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3913 }
3914 return s;
3915 case 5:
3916 case 7:
3917 {
3918 bool flag6 = false;
3919 if (context == 5)
3920 {
3921 flag6 = Main.mouseItem.Prefix(-3) || Main.mouseItem.type == 0;
3922 }
3923 if (context == 7)
3924 {
3925 flag6 = Main.mouseItem.material;
3926 }
3927 if (inv[slot].type > 0 && inv[slot].stack > 0)
3928 {
3929 if (Main.mouseItem.type > 0)
3930 {
3931 if (flag6)
3932 {
3933 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3934 }
3935 }
3936 else
3937 {
3938 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3939 }
3940 }
3941 else if (Main.mouseItem.type > 0 && flag6)
3942 {
3943 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3944 }
3945 return s;
3946 }
3947 default:
3948 {
3950 bool flag5 = Main.mouseItem.type > 0 && (context == 0 || context == 1 || context == 2 || context == 6 || context == 15 || context == 7 || context == 4 || context == 32 || context == 3);
3951 if (context != 8 || !isEquipLocked(inv[slot].type))
3952 {
3954 {
3955 s += PlayerInput.BuildCommand(Lang.inter[121].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["SmartSelect"]);
3956 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.SmartSelect)
3957 {
3958 player.DropSelectedItem();
3959 PlayerInput.LockGamepadButtons("SmartSelect");
3961 }
3962 }
3963 else if (!string.IsNullOrEmpty(overrideInstructions))
3964 {
3965 ShiftForcedOn = true;
3966 int cursorOverride = Main.cursorOverride;
3967 OverrideHover(inv, context, slot);
3968 if (-1 != Main.cursorOverride)
3969 {
3970 s += PlayerInput.BuildCommand(overrideInstructions, false, PlayerInput.ProfileGamepadUI.KeyStatus["SmartSelect"]);
3971 if (CanDoSimulatedClickAction() && CanExecuteCommand() && PlayerInput.Triggers.JustPressed.SmartSelect)
3972 {
3973 bool mouseLeft = Main.mouseLeft;
3974 Main.mouseLeft = true;
3975 LeftClick(inv, context, slot);
3976 Main.mouseLeft = mouseLeft;
3977 PlayerInput.LockGamepadButtons("SmartSelect");
3979 }
3980 }
3981 Main.cursorOverride = cursorOverride;
3982 ShiftForcedOn = false;
3983 }
3984 }
3985 if (!TryEnteringFastUseMode(inv, context, slot, player, ref s))
3986 {
3987 TryEnteringBuildingMode(inv, context, slot, player, ref s);
3988 }
3989 return s;
3990 }
3991 }
3992 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
static TriggersPack Triggers
static string BuildCommand(string CommandText, bool Last, params List< string >[] Bindings)
static void LockGamepadButtons(string TriggerName)
static bool AllowExecutionOfGamepadInstructions
static KeyConfiguration ProfileGamepadUI
static string GetTextValue(string key)
Retrieves the text value for a specified localization key. The text returned will be for the currentl...
Definition Language.cs:35
Contains methods to access or retrieve localization values. The Localization Guideteaches more about ...
Definition Language.cs:12
static bool isEquipLocked(int type)
Definition ItemSlot.cs:358
static bool TryEnteringFastUseMode(Item[] inv, int context, int slot, Player player, ref string s)
Definition ItemSlot.cs:4003
static void OverrideHover(ref Item inv, int context=0)
Definition ItemSlot.cs:351
static void SwapEquip(ref Item inv, int context=0)
Definition ItemSlot.cs:2926
static bool ShiftForcedOn
Definition ItemSlot.cs:139
static bool Equippable(ref Item inv, int context=0)
Definition ItemSlot.cs:3009
static string GetOverrideInstructions(Item[] inv, int context, int slot)
Definition ItemSlot.cs:1071
static void LeftClick(ref Item inv, int context=0)
Definition ItemSlot.cs:668
static bool CanDoSimulatedClickAction()
Definition ItemSlot.cs:3994
static bool TryEnteringBuildingMode(Item[] inv, int context, int slot, Player player, ref string s)
Definition ItemSlot.cs:4034
static bool CanExecuteCommand()
Definition ItemSlot.cs:3563

References Terraria.GameInput.PlayerInput.AllowExecutionOfGamepadInstructions, Terraria.GameInput.PlayerInput.BuildCommand(), Terraria.Player.CanDemonHeartAccessoryBeShown(), Terraria.UI.ItemSlot.CanDoSimulatedClickAction(), Terraria.UI.ItemSlot.CanExecuteCommand(), Terraria.Player.SelectionRadial.ChangeBinding(), Terraria.Player.chest, Terraria.Main.cursorOverride, Terraria.Player.DpadRadial, Terraria.Player.DropSelectedItem(), Terraria.Player.dye, Terraria.Player.enabledSuperCart, Terraria.UI.ItemSlot.Equippable(), Terraria.UI.ItemSlot.GetOverrideInstructions(), Terraria.Localization.Language.GetTextValue(), Terraria.Player.hideMisc, Terraria.Player.hideVisibleAccessory, Terraria.Lang.inter, Terraria.UI.ItemSlot.isEquipLocked(), Terraria.UI.ItemSlot.LeftClick(), Terraria.GameInput.PlayerInput.LockGamepadButtons(), Terraria.Lang.misc, Terraria.Player.miscDyes, Terraria.Main.mouseItem, Terraria.Main.mouseLeft, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.UI.ItemSlot.OverrideHover(), Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.GameInput.PlayerInput.ProfileGamepadUI, Terraria.NetMessage.SendData(), Terraria.UI.ItemSlot.ShiftForcedOn, Terraria.UI.ItemSlot.SwapEquip(), Terraria.Player.ToggleLight(), Terraria.Player.TogglePet(), Terraria.GameInput.PlayerInput.Triggers, Terraria.UI.ItemSlot.TryEnteringBuildingMode(), Terraria.UI.ItemSlot.TryEnteringFastUseMode(), and Terraria.GameInput.PlayerInput.SettingsForUI.TryRevertingToMouseMode().

+ Here is the call graph for this function: