Terraria v1.4.4.9
Terraria 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 3105 of file ItemSlot.cs.

3106 {
3107 Player player = Main.player[Main.myPlayer];
3108 string s = "";
3109 if (inv == null || inv[slot] == null || Main.mouseItem == null)
3110 {
3111 return s;
3112 }
3113 if (context == 0 || context == 1 || context == 2)
3114 {
3115 if (inv[slot].type > 0 && inv[slot].stack > 0)
3116 {
3117 if (Main.mouseItem.type > 0)
3118 {
3119 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3120 if (inv[slot].type == Main.mouseItem.type && Main.mouseItem.stack < inv[slot].maxStack && inv[slot].maxStack > 1)
3121 {
3122 s += PlayerInput.BuildCommand(Lang.misc[55].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3123 }
3124 }
3125 else
3126 {
3127 if (context == 0 && player.chest == -1 && PlayerInput.AllowExecutionOfGamepadInstructions)
3128 {
3129 player.DpadRadial.ChangeBinding(slot);
3130 }
3131 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3132 if (inv[slot].maxStack > 1)
3133 {
3134 s += PlayerInput.BuildCommand(Lang.misc[55].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3135 }
3136 }
3137 if (inv[slot].maxStack == 1 && Equippable(inv, context, slot))
3138 {
3139 s += PlayerInput.BuildCommand(Lang.misc[67].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3140 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3141 {
3142 SwapEquip(inv, context, slot);
3145 }
3146 }
3147 s += PlayerInput.BuildCommand(Lang.misc[83].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["SmartCursor"]);
3148 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.SmartCursor)
3149 {
3150 inv[slot].favorited = !inv[slot].favorited;
3151 PlayerInput.LockGamepadButtons("SmartCursor");
3153 }
3154 }
3155 else if (Main.mouseItem.type > 0)
3156 {
3157 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3158 }
3159 }
3160 if (context == 3 || context == 4 || context == 32)
3161 {
3162 if (inv[slot].type > 0 && inv[slot].stack > 0)
3163 {
3164 if (Main.mouseItem.type > 0)
3165 {
3166 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3167 if (inv[slot].type == Main.mouseItem.type && Main.mouseItem.stack < inv[slot].maxStack && inv[slot].maxStack > 1)
3168 {
3169 s += PlayerInput.BuildCommand(Lang.misc[55].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3170 }
3171 }
3172 else
3173 {
3174 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3175 if (inv[slot].maxStack > 1)
3176 {
3177 s += PlayerInput.BuildCommand(Lang.misc[55].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3178 }
3179 }
3180 if (inv[slot].maxStack == 1 && Equippable(inv, context, slot))
3181 {
3182 s += PlayerInput.BuildCommand(Lang.misc[67].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3183 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3184 {
3185 SwapEquip(inv, context, slot);
3188 }
3189 }
3190 if (context == 32)
3191 {
3192 s += PlayerInput.BuildCommand(Lang.misc[83].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["SmartCursor"]);
3193 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.SmartCursor)
3194 {
3195 inv[slot].favorited = !inv[slot].favorited;
3196 PlayerInput.LockGamepadButtons("SmartCursor");
3198 }
3199 }
3200 }
3201 else if (Main.mouseItem.type > 0)
3202 {
3203 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3204 }
3205 }
3206 if (context == 15)
3207 {
3208 if (inv[slot].type > 0 && inv[slot].stack > 0)
3209 {
3210 if (Main.mouseItem.type > 0)
3211 {
3212 if (inv[slot].type == Main.mouseItem.type && Main.mouseItem.stack < inv[slot].maxStack && inv[slot].maxStack > 1)
3213 {
3214 s += PlayerInput.BuildCommand(Lang.misc[91].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3215 }
3216 }
3217 else
3218 {
3219 s += PlayerInput.BuildCommand(Lang.misc[90].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"], PlayerInput.ProfileGamepadUI.KeyStatus["MouseRight"]);
3220 }
3221 }
3222 else if (Main.mouseItem.type > 0)
3223 {
3224 s += PlayerInput.BuildCommand(Lang.misc[92].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3225 }
3226 }
3227 if (context == 8 || context == 9 || context == 16 || context == 17 || context == 18 || context == 19 || context == 20)
3228 {
3229 if (inv[slot].type > 0 && inv[slot].stack > 0)
3230 {
3231 if (Main.mouseItem.type > 0)
3232 {
3233 if (Equippable(ref Main.mouseItem, context))
3234 {
3235 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3236 }
3237 }
3238 else if (context != 8 || !isEquipLocked(inv[slot].type))
3239 {
3240 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3241 }
3242 if (context == 8 && slot >= 3)
3243 {
3244 bool flag = player.hideVisibleAccessory[slot];
3245 s += PlayerInput.BuildCommand(Lang.misc[flag ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3246 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3247 {
3248 player.hideVisibleAccessory[slot] = !player.hideVisibleAccessory[slot];
3250 if (Main.netMode == 1)
3251 {
3252 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3253 }
3256 }
3257 }
3258 if ((context == 16 || context == 17 || context == 18 || context == 19 || context == 20) && slot < 2)
3259 {
3260 bool flag2 = player.hideMisc[slot];
3261 s += PlayerInput.BuildCommand(Lang.misc[flag2 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3262 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3263 {
3264 if (slot == 0)
3265 {
3266 player.TogglePet();
3267 }
3268 if (slot == 1)
3269 {
3270 player.ToggleLight();
3271 }
3273 if (Main.netMode == 1)
3274 {
3275 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3276 }
3279 }
3280 }
3281 }
3282 else
3283 {
3284 if (Main.mouseItem.type > 0 && Equippable(ref Main.mouseItem, context))
3285 {
3286 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3287 }
3288 if (context == 8 && slot >= 3)
3289 {
3290 int num = slot;
3291 if (num % 10 == 8 && !player.CanDemonHeartAccessoryBeShown())
3292 {
3293 num++;
3294 }
3295 bool flag3 = player.hideVisibleAccessory[num];
3296 s += PlayerInput.BuildCommand(Lang.misc[flag3 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3297 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3298 {
3299 player.hideVisibleAccessory[num] = !player.hideVisibleAccessory[num];
3301 if (Main.netMode == 1)
3302 {
3303 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3304 }
3307 }
3308 }
3309 if ((context == 16 || context == 17 || context == 18 || context == 19 || context == 20) && slot < 2)
3310 {
3311 bool flag4 = player.hideMisc[slot];
3312 s += PlayerInput.BuildCommand(Lang.misc[flag4 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3313 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3314 {
3315 if (slot == 0)
3316 {
3317 player.TogglePet();
3318 }
3319 if (slot == 1)
3320 {
3321 player.ToggleLight();
3322 }
3323 Main.mouseLeftRelease = false;
3325 if (Main.netMode == 1)
3326 {
3327 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3328 }
3331 }
3332 }
3333 }
3334 }
3335 switch (context)
3336 {
3337 case 12:
3338 case 25:
3339 case 27:
3340 case 33:
3341 if (inv[slot].type > 0 && inv[slot].stack > 0)
3342 {
3343 if (Main.mouseItem.type > 0)
3344 {
3345 if (Main.mouseItem.dye > 0)
3346 {
3347 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3348 }
3349 }
3350 else
3351 {
3352 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3353 }
3354 if (context == 12 || context == 25 || context == 27 || context == 33)
3355 {
3356 int num2 = -1;
3357 if (inv == player.dye)
3358 {
3359 num2 = slot;
3360 }
3361 if (inv == player.miscDyes)
3362 {
3363 num2 = 10 + slot;
3364 }
3365 if (num2 != -1)
3366 {
3367 if (num2 < 10)
3368 {
3369 bool flag7 = player.hideVisibleAccessory[slot];
3370 s += PlayerInput.BuildCommand(Lang.misc[flag7 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3371 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3372 {
3373 player.hideVisibleAccessory[slot] = !player.hideVisibleAccessory[slot];
3375 if (Main.netMode == 1)
3376 {
3377 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3378 }
3381 }
3382 }
3383 else
3384 {
3385 bool flag8 = player.hideMisc[slot];
3386 s += PlayerInput.BuildCommand(Lang.misc[flag8 ? 77 : 78].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3387 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3388 {
3389 player.hideMisc[slot] = !player.hideMisc[slot];
3391 if (Main.netMode == 1)
3392 {
3393 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3394 }
3397 }
3398 }
3399 }
3400 }
3401 }
3402 else if (Main.mouseItem.type > 0 && Main.mouseItem.dye > 0)
3403 {
3404 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3405 }
3406 return s;
3407 case 18:
3408 {
3409 if (inv[slot].type > 0 && inv[slot].stack > 0)
3410 {
3411 if (Main.mouseItem.type > 0)
3412 {
3413 if (Main.mouseItem.dye > 0)
3414 {
3415 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3416 }
3417 }
3418 else
3419 {
3420 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3421 }
3422 }
3423 else if (Main.mouseItem.type > 0 && Main.mouseItem.dye > 0)
3424 {
3425 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3426 }
3427 bool enabledSuperCart = player.enabledSuperCart;
3428 s += PlayerInput.BuildCommand(Language.GetTextValue((!enabledSuperCart) ? "UI.EnableSuperCart" : "UI.DisableSuperCart"), false, PlayerInput.ProfileGamepadUI.KeyStatus["Grapple"]);
3429 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.Grapple)
3430 {
3431 player.enabledSuperCart = !player.enabledSuperCart;
3433 if (Main.netMode == 1)
3434 {
3435 NetMessage.SendData(4, -1, -1, null, Main.myPlayer);
3436 }
3439 }
3440 return s;
3441 }
3442 case 6:
3443 if (inv[slot].type > 0 && inv[slot].stack > 0)
3444 {
3445 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"])));
3446 }
3447 else if (Main.mouseItem.type > 0)
3448 {
3449 s += PlayerInput.BuildCommand(Lang.misc[74].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3450 }
3451 return s;
3452 case 5:
3453 case 7:
3454 {
3455 bool flag6 = false;
3456 if (context == 5)
3457 {
3458 flag6 = Main.mouseItem.Prefix(-3) || Main.mouseItem.type == 0;
3459 }
3460 if (context == 7)
3461 {
3462 flag6 = Main.mouseItem.material;
3463 }
3464 if (inv[slot].type > 0 && inv[slot].stack > 0)
3465 {
3466 if (Main.mouseItem.type > 0)
3467 {
3468 if (flag6)
3469 {
3470 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3471 }
3472 }
3473 else
3474 {
3475 s += PlayerInput.BuildCommand(Lang.misc[54].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3476 }
3477 }
3478 else if (Main.mouseItem.type > 0 && flag6)
3479 {
3480 s += PlayerInput.BuildCommand(Lang.misc[65].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["MouseLeft"]);
3481 }
3482 return s;
3483 }
3484 default:
3485 {
3486 string overrideInstructions = GetOverrideInstructions(inv, context, slot);
3487 bool flag5 = Main.mouseItem.type > 0 && (context == 0 || context == 1 || context == 2 || context == 6 || context == 15 || context == 7 || context == 4 || context == 32 || context == 3);
3488 if (context != 8 || !isEquipLocked(inv[slot].type))
3489 {
3490 if (flag5 && string.IsNullOrEmpty(overrideInstructions))
3491 {
3492 s += PlayerInput.BuildCommand(Lang.inter[121].Value, false, PlayerInput.ProfileGamepadUI.KeyStatus["SmartSelect"]);
3493 if (CanExecuteCommand() && PlayerInput.Triggers.JustPressed.SmartSelect)
3494 {
3495 player.DropSelectedItem();
3496 PlayerInput.LockGamepadButtons("SmartSelect");
3498 }
3499 }
3500 else if (!string.IsNullOrEmpty(overrideInstructions))
3501 {
3502 ShiftForcedOn = true;
3503 int cursorOverride = Main.cursorOverride;
3504 OverrideHover(inv, context, slot);
3505 if (-1 != Main.cursorOverride)
3506 {
3507 s += PlayerInput.BuildCommand(overrideInstructions, false, PlayerInput.ProfileGamepadUI.KeyStatus["SmartSelect"]);
3508 if (CanDoSimulatedClickAction() && CanExecuteCommand() && PlayerInput.Triggers.JustPressed.SmartSelect)
3509 {
3510 bool mouseLeft = Main.mouseLeft;
3511 Main.mouseLeft = true;
3512 LeftClick(inv, context, slot);
3513 Main.mouseLeft = mouseLeft;
3514 PlayerInput.LockGamepadButtons("SmartSelect");
3516 }
3517 }
3518 Main.cursorOverride = cursorOverride;
3519 ShiftForcedOn = false;
3520 }
3521 }
3522 if (!TryEnteringFastUseMode(inv, context, slot, player, ref s))
3523 {
3524 TryEnteringBuildingMode(inv, context, slot, player, ref s);
3525 }
3526 return s;
3527 }
3528 }
3529 }
static void PlaySound(int type, Vector2 position, int style=1)
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)
Definition Language.cs:15
static bool isEquipLocked(int type)
Definition ItemSlot.cs:329
static bool TryEnteringFastUseMode(Item[] inv, int context, int slot, Player player, ref string s)
Definition ItemSlot.cs:3540
static void OverrideHover(ref Item inv, int context=0)
Definition ItemSlot.cs:322
static void SwapEquip(ref Item inv, int context=0)
Definition ItemSlot.cs:2544
static bool ShiftForcedOn
Definition ItemSlot.cs:129
static bool Equippable(ref Item inv, int context=0)
Definition ItemSlot.cs:2627
static string GetOverrideInstructions(Item[] inv, int context, int slot)
Definition ItemSlot.cs:1067
static void LeftClick(ref Item inv, int context=0)
Definition ItemSlot.cs:630
static bool CanDoSimulatedClickAction()
Definition ItemSlot.cs:3531
static bool TryEnteringBuildingMode(Item[] inv, int context, int slot, Player player, ref string s)
Definition ItemSlot.cs:3571
static bool CanExecuteCommand()
Definition ItemSlot.cs:3100

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.Item.favorited, 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.Item.maxStack, 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, System.s, 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(), Terraria.GameInput.PlayerInput.SettingsForUI.TryRevertingToMouseMode(), and System.type.