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

◆ CreatePanel()

UIElement Terraria.GameContent.UI.States.UIManageControls.CreatePanel ( string bind,
InputMode currentInputMode,
Color color )
inline

Definition at line 381 of file UIManageControls.cs.

382 {
383 switch (bind)
384 {
385 case "sp1":
386 {
387 UIKeybindingToggleListItem uIKeybindingToggleListItem5 = new UIKeybindingToggleListItem(() => Lang.menu[196].Value, () => PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap1"].Contains(Buttons.DPadUp.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap2"].Contains(Buttons.DPadRight.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap3"].Contains(Buttons.DPadDown.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap4"].Contains(Buttons.DPadLeft.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap1"].Contains(Buttons.DPadUp.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap2"].Contains(Buttons.DPadRight.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap3"].Contains(Buttons.DPadDown.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap4"].Contains(Buttons.DPadLeft.ToString()), color);
388 uIKeybindingToggleListItem5.OnLeftClick += SnapButtonClick;
390 }
391 case "sp2":
392 {
393 UIKeybindingToggleListItem uIKeybindingToggleListItem4 = new UIKeybindingToggleListItem(() => Lang.menu[197].Value, () => PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial1"].Contains(Buttons.DPadUp.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial2"].Contains(Buttons.DPadRight.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial3"].Contains(Buttons.DPadDown.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial4"].Contains(Buttons.DPadLeft.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial1"].Contains(Buttons.DPadUp.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial2"].Contains(Buttons.DPadRight.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial3"].Contains(Buttons.DPadDown.ToString()) && PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial4"].Contains(Buttons.DPadLeft.ToString()), color);
394 uIKeybindingToggleListItem4.OnLeftClick += RadialButtonClick;
396 }
397 case "sp3":
398 return new UIKeybindingSliderItem(() => Lang.menu[199].Value + " (" + PlayerInput.CurrentProfile.TriggersDeadzone.ToString("P1") + ")", () => PlayerInput.CurrentProfile.TriggersDeadzone, delegate(float f)
399 {
400 PlayerInput.CurrentProfile.TriggersDeadzone = f;
401 }, delegate
402 {
403 PlayerInput.CurrentProfile.TriggersDeadzone = UILinksInitializer.HandleSliderHorizontalInput(PlayerInput.CurrentProfile.TriggersDeadzone, 0f, 0.95f, PlayerInput.CurrentProfile.InterfaceDeadzoneX, 0.35f);
404 }, 1000, color);
405 case "sp4":
406 return new UIKeybindingSliderItem(() => Lang.menu[200].Value + " (" + PlayerInput.CurrentProfile.InterfaceDeadzoneX.ToString("P1") + ")", () => PlayerInput.CurrentProfile.InterfaceDeadzoneX, delegate(float f)
407 {
408 PlayerInput.CurrentProfile.InterfaceDeadzoneX = f;
409 }, delegate
410 {
411 PlayerInput.CurrentProfile.InterfaceDeadzoneX = UILinksInitializer.HandleSliderHorizontalInput(PlayerInput.CurrentProfile.InterfaceDeadzoneX, 0f, 0.95f, 0.35f, 0.35f);
412 }, 1001, color);
413 case "sp5":
414 return new UIKeybindingSliderItem(() => Lang.menu[201].Value + " (" + PlayerInput.CurrentProfile.LeftThumbstickDeadzoneX.ToString("P1") + ")", () => PlayerInput.CurrentProfile.LeftThumbstickDeadzoneX, delegate(float f)
415 {
416 PlayerInput.CurrentProfile.LeftThumbstickDeadzoneX = f;
417 }, delegate
418 {
419 PlayerInput.CurrentProfile.LeftThumbstickDeadzoneX = UILinksInitializer.HandleSliderHorizontalInput(PlayerInput.CurrentProfile.LeftThumbstickDeadzoneX, 0f, 0.95f, PlayerInput.CurrentProfile.InterfaceDeadzoneX, 0.35f);
420 }, 1002, color);
421 case "sp6":
422 return new UIKeybindingSliderItem(() => Lang.menu[202].Value + " (" + PlayerInput.CurrentProfile.LeftThumbstickDeadzoneY.ToString("P1") + ")", () => PlayerInput.CurrentProfile.LeftThumbstickDeadzoneY, delegate(float f)
423 {
424 PlayerInput.CurrentProfile.LeftThumbstickDeadzoneY = f;
425 }, delegate
426 {
427 PlayerInput.CurrentProfile.LeftThumbstickDeadzoneY = UILinksInitializer.HandleSliderHorizontalInput(PlayerInput.CurrentProfile.LeftThumbstickDeadzoneY, 0f, 0.95f, PlayerInput.CurrentProfile.InterfaceDeadzoneX, 0.35f);
428 }, 1003, color);
429 case "sp7":
430 return new UIKeybindingSliderItem(() => Lang.menu[203].Value + " (" + PlayerInput.CurrentProfile.RightThumbstickDeadzoneX.ToString("P1") + ")", () => PlayerInput.CurrentProfile.RightThumbstickDeadzoneX, delegate(float f)
431 {
432 PlayerInput.CurrentProfile.RightThumbstickDeadzoneX = f;
433 }, delegate
434 {
435 PlayerInput.CurrentProfile.RightThumbstickDeadzoneX = UILinksInitializer.HandleSliderHorizontalInput(PlayerInput.CurrentProfile.RightThumbstickDeadzoneX, 0f, 0.95f, PlayerInput.CurrentProfile.InterfaceDeadzoneX, 0.35f);
436 }, 1004, color);
437 case "sp8":
438 return new UIKeybindingSliderItem(() => Lang.menu[204].Value + " (" + PlayerInput.CurrentProfile.RightThumbstickDeadzoneY.ToString("P1") + ")", () => PlayerInput.CurrentProfile.RightThumbstickDeadzoneY, delegate(float f)
439 {
440 PlayerInput.CurrentProfile.RightThumbstickDeadzoneY = f;
441 }, delegate
442 {
443 PlayerInput.CurrentProfile.RightThumbstickDeadzoneY = UILinksInitializer.HandleSliderHorizontalInput(PlayerInput.CurrentProfile.RightThumbstickDeadzoneY, 0f, 0.95f, PlayerInput.CurrentProfile.InterfaceDeadzoneX, 0.35f);
444 }, 1005, color);
445 case "sp9":
446 {
448 uIKeybindingSimpleListItem3.OnLeftClick += delegate
449 {
452 };
454 }
455 case "sp10":
456 {
458 uIKeybindingSimpleListItem5.OnLeftClick += delegate
459 {
462 };
464 }
465 case "sp11":
466 {
468 uIKeybindingSimpleListItem2.OnLeftClick += delegate
469 {
472 };
474 }
475 case "sp12":
476 {
478 uIKeybindingSimpleListItem.OnLeftClick += delegate
479 {
482 };
484 }
485 case "sp13":
486 {
488 uIKeybindingSimpleListItem4.OnLeftClick += delegate
489 {
492 };
494 }
495 case "sp14":
496 {
497 UIKeybindingToggleListItem uIKeybindingToggleListItem = new UIKeybindingToggleListItem(() => Lang.menu[205].Value, () => PlayerInput.CurrentProfile.LeftThumbstickInvertX, color);
498 uIKeybindingToggleListItem.OnLeftClick += delegate
499 {
500 if (PlayerInput.CurrentProfile.AllowEditting)
501 {
502 PlayerInput.CurrentProfile.LeftThumbstickInvertX = !PlayerInput.CurrentProfile.LeftThumbstickInvertX;
503 }
504 };
506 }
507 case "sp15":
508 {
509 UIKeybindingToggleListItem uIKeybindingToggleListItem3 = new UIKeybindingToggleListItem(() => Lang.menu[206].Value, () => PlayerInput.CurrentProfile.LeftThumbstickInvertY, color);
510 uIKeybindingToggleListItem3.OnLeftClick += delegate
511 {
512 if (PlayerInput.CurrentProfile.AllowEditting)
513 {
514 PlayerInput.CurrentProfile.LeftThumbstickInvertY = !PlayerInput.CurrentProfile.LeftThumbstickInvertY;
515 }
516 };
518 }
519 case "sp16":
520 {
521 UIKeybindingToggleListItem uIKeybindingToggleListItem2 = new UIKeybindingToggleListItem(() => Lang.menu[207].Value, () => PlayerInput.CurrentProfile.RightThumbstickInvertX, color);
522 uIKeybindingToggleListItem2.OnLeftClick += delegate
523 {
524 if (PlayerInput.CurrentProfile.AllowEditting)
525 {
526 PlayerInput.CurrentProfile.RightThumbstickInvertX = !PlayerInput.CurrentProfile.RightThumbstickInvertX;
527 }
528 };
530 }
531 case "sp17":
532 {
533 UIKeybindingToggleListItem uIKeybindingToggleListItem6 = new UIKeybindingToggleListItem(() => Lang.menu[208].Value, () => PlayerInput.CurrentProfile.RightThumbstickInvertY, color);
534 uIKeybindingToggleListItem6.OnLeftClick += delegate
535 {
536 if (PlayerInput.CurrentProfile.AllowEditting)
537 {
538 PlayerInput.CurrentProfile.RightThumbstickInvertY = !PlayerInput.CurrentProfile.RightThumbstickInvertY;
539 }
540 };
542 }
543 case "sp18":
545 {
546 int hotbarRadialHoldTimeRequired = PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired;
547 return (hotbarRadialHoldTimeRequired == -1) ? Lang.menu[228].Value : (Lang.menu[227].Value + " (" + ((float)hotbarRadialHoldTimeRequired / 60f).ToString("F2") + "s)");
548 }, () => (PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired == -1) ? 1f : ((float)PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired / 301f), delegate(float f)
549 {
550 PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired = (int)(f * 301f);
551 if ((float)PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired == 301f)
552 {
553 PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired = -1;
554 }
555 }, delegate
556 {
557 float currentValue = ((PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired == -1) ? 1f : ((float)PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired / 301f));
558 currentValue = UILinksInitializer.HandleSliderHorizontalInput(currentValue, 0f, 1f, PlayerInput.CurrentProfile.InterfaceDeadzoneX);
559 PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired = (int)(currentValue * 301f);
560 if ((float)PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired == 301f)
561 {
562 PlayerInput.CurrentProfile.HotbarRadialHoldTimeRequired = -1;
563 }
564 }, 1007, color);
565 case "sp19":
567 {
568 int inventoryMoveCD = PlayerInput.CurrentProfile.InventoryMoveCD;
569 return Lang.menu[252].Value + " (" + ((float)inventoryMoveCD / 60f).ToString("F2") + "s)";
570 }, () => Utils.GetLerpValue(4f, 12f, PlayerInput.CurrentProfile.InventoryMoveCD, clamped: true), delegate(float f)
571 {
572 PlayerInput.CurrentProfile.InventoryMoveCD = (int)Math.Round(MathHelper.Lerp(4f, 12f, f));
573 }, delegate
574 {
576 {
578 }
580 {
581 float lerpValue = Utils.GetLerpValue(4f, 12f, PlayerInput.CurrentProfile.InventoryMoveCD, clamped: true);
583 if (lerpValue != num)
584 {
585 UILinkPointNavigator.Shortcuts.INV_MOVE_OPTION_CD = 8;
586 int num2 = Math.Sign(num - lerpValue);
587 PlayerInput.CurrentProfile.InventoryMoveCD = (int)MathHelper.Clamp(PlayerInput.CurrentProfile.InventoryMoveCD + num2, 4f, 12f);
588 }
589 }
590 }, 1008, color);
591 default:
592 return new UIKeybindingListItem(bind, currentInputMode, color);
593 }
594 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static decimal Round(decimal d)
Definition Math.cs:1096
static int Sign(decimal value)
Definition Math.cs:1202
void SnapButtonClick(UIMouseEvent evt, UIElement listeningElement)
void RadialButtonClick(UIMouseEvent evt, UIElement listeningElement)
static PlayerInputProfile CurrentProfile
static Dictionary< string, PlayerInputProfile > OriginalProfiles
static float HandleSliderHorizontalInput(float currentValue, float min, float max, float deadZone=0.2f, float sensitivity=0.5f)

References Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.GameInput.PlayerInput.CurrentProfile, Terraria.GameContent.UI.States.UIManageControls.GetCopyableProfileName(), Terraria.Utils.GetLerpValue(), Terraria.Initializers.UILinksInitializer.HandleSliderHorizontalInput(), Terraria.UI.Gamepad.UILinkPointNavigator.Shortcuts.INV_MOVE_OPTION_CD, Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.Lang.menu, Terraria.GameInput.PlayerInput.OriginalProfiles, Terraria.GameContent.UI.States.UIManageControls.RadialButtonClick(), System.Math.Round(), System.Math.Sign(), and Terraria.GameContent.UI.States.UIManageControls.SnapButtonClick().

Referenced by Terraria.GameContent.UI.States.UIManageControls.CreateElementGroup().