Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PlayerInput.cs
Go to the documentation of this file.
1using System;
3using System.Linq;
5using Microsoft.Xna.Framework.Input;
10using Terraria.ID;
11using Terraria.Social;
12using Terraria.UI;
14
15namespace Terraria.GameInput;
16
17public class PlayerInput
18{
19 public class MiscSettingsTEMP
20 {
21 public static bool HotbarRadialShouldBeUsed = true;
22 }
23
24 public static class SettingsForUI
25 {
26 public static CursorMode CurrentCursorMode { get; private set; }
27
28 public static bool ShowGamepadHints
29 {
30 get
31 {
32 if (!UsingGamepad)
33 {
34 return SteamDeckIsUsed;
35 }
36 return true;
37 }
38 }
39
40 public static bool AllowSecondaryGamepadAim
41 {
42 get
43 {
44 if (CurrentCursorMode != CursorMode.Gamepad)
45 {
46 return !SteamDeckIsUsed;
47 }
48 return true;
49 }
50 }
51
52 public static bool PushEquipmentAreaUp
53 {
54 get
55 {
56 if (UsingGamepad)
57 {
58 return !SteamDeckIsUsed;
59 }
60 return false;
61 }
62 }
63
64 public static bool ShowGamepadCursor
65 {
66 get
67 {
68 if (!SteamDeckIsUsed)
69 {
70 return UsingGamepad;
71 }
72 return CurrentCursorMode == CursorMode.Gamepad;
73 }
74 }
75
76 public static bool HighlightThingsForMouse
77 {
78 get
79 {
81 {
82 return CurrentCursorMode == CursorMode.Mouse;
83 }
84 return true;
85 }
86 }
87
88 public static int FramesSinceLastTimeInMouseMode { get; private set; }
89
91
93 {
95 if (CurrentCursorMode == CursorMode.Mouse)
96 {
98 }
99 }
100
101 public static void UpdateCounters()
102 {
103 if (CurrentCursorMode != 0)
104 {
106 }
107 }
108
109 public static void TryRevertingToMouseMode()
110 {
112 {
115 Triggers.Current.UsedMovementKey = false;
117 }
118 }
119 }
120
121 private struct FastUseItemMemory
122 {
123 private int _slot;
124
125 private int _itemType;
126
127 private bool _shouldFastUse;
128
129 private bool _isMouseItem;
130
132
133 public bool TryStartForItemSlot(Player player, int itemSlot)
134 {
136 {
137 Clear();
138 return false;
139 }
140 _player = player;
141 _slot = itemSlot;
143 _shouldFastUse = true;
144 _isMouseItem = false;
146 return true;
147 }
148
149 public bool TryStartForMouse(Player player)
150 {
151 _player = player;
152 _slot = -1;
153 _itemType = Main.mouseItem.type;
154 _shouldFastUse = true;
155 _isMouseItem = true;
156 return true;
157 }
158
159 public void Clear()
160 {
161 _shouldFastUse = false;
162 }
163
164 public bool CanFastUse()
165 {
166 if (!_shouldFastUse)
167 {
168 return false;
169 }
170 if (_isMouseItem)
171 {
172 return Main.mouseItem.type == _itemType;
173 }
175 }
176
177 public void EndFastUse()
178 {
179 if (_shouldFastUse)
180 {
182 {
184 }
185 Clear();
186 }
187 }
188 }
189
191
192 public static TriggersPack Triggers = new TriggersPack();
193
195 {
196 "MouseLeft", "MouseRight", "Up", "Down", "Left", "Right", "Jump", "Throw", "Inventory", "Grapple",
197 "SmartSelect", "SmartCursor", "QuickMount", "QuickHeal", "QuickMana", "QuickBuff", "MapZoomIn", "MapZoomOut", "MapAlphaUp", "MapAlphaDown",
198 "MapFull", "MapStyle", "Hotbar1", "Hotbar2", "Hotbar3", "Hotbar4", "Hotbar5", "Hotbar6", "Hotbar7", "Hotbar8",
199 "Hotbar9", "Hotbar10", "HotbarMinus", "HotbarPlus", "DpadRadial1", "DpadRadial2", "DpadRadial3", "DpadRadial4", "RadialHotbar", "RadialQuickbar",
200 "DpadSnap1", "DpadSnap2", "DpadSnap3", "DpadSnap4", "MenuUp", "MenuDown", "MenuLeft", "MenuRight", "LockOn", "ViewZoomIn",
201 "ViewZoomOut", "Loadout1", "Loadout2", "Loadout3", "ToggleCameraMode", "ToggleCreativeMenu"
202 };
203
204 private static bool _canReleaseRebindingLock = true;
205
206 private static int _memoOfLastPoint = -1;
207
208 public static int NavigatorRebindingLock;
209
210 public static string BlockedKey = "";
211
212 private static string _listeningTrigger;
213
215
217
219
220 private static string _selectedProfile;
221
223
224 public static InputMode CurrentInputMode = InputMode.Keyboard;
225
226 private static Buttons[] ButtonsGamepad = (Buttons[])Enum.GetValues(typeof(Buttons));
227
228 public static bool GrappleAndInteractAreShared;
229
231
232 public static bool UseSteamDeckIfPossible;
233
234 private static string _invalidatorCheck = "";
235
236 private static bool _lastActivityState;
237
238 public static MouseState MouseInfo;
239
241
242 public static int MouseX;
243
244 public static int MouseY;
245
246 public static bool LockGamepadTileUseButton = false;
247
248 public static List<string> MouseKeys = new List<string>();
249
250 public static int PreUIX;
251
252 public static int PreUIY;
253
254 public static int PreLockOnX;
255
256 public static int PreLockOnY;
257
258 public static int ScrollWheelValue;
259
260 public static int ScrollWheelValueOld;
261
262 public static int ScrollWheelDelta;
263
264 public static int ScrollWheelDeltaForUI;
265
266 public static bool GamepadAllowScrolling;
267
268 public static int GamepadScrollValue;
269
271
273
275
276 private static bool _InBuildingMode;
277
278 private static int _UIPointForBuildingMode = -1;
279
280 public static bool WritingText;
281
282 private static int _originalMouseX;
283
284 private static int _originalMouseY;
285
286 private static int _originalLastMouseX;
287
288 private static int _originalLastMouseY;
289
290 private static int _originalScreenWidth;
291
292 private static int _originalScreenHeight;
293
295
297
298 public static bool PreventCursorModeSwappingToGamepad = false;
299
300 public static bool PreventFirstMousePositionGrab = false;
301
302 private static int[] DpadSnapCooldown = new int[4];
303
304 public static bool AllowExecutionOfGamepadInstructions = true;
305
306 public static string ListeningTrigger => _listeningTrigger;
307
308 public static bool CurrentlyRebinding => _listeningTrigger != null;
309
310 public static bool InvisibleGamepadInMenus
311 {
312 get
313 {
314 if ((!Main.gameMenu && !Main.ingameOptionsWindow && !Main.playerInventory && Main.player[Main.myPlayer].talkNPC == -1 && Main.player[Main.myPlayer].sign == -1 && Main.InGameUI.CurrentState == null) || _InBuildingMode || !Main.InvisibleCursorForGamepad)
315 {
316 if (CursorIsBusy)
317 {
318 return !_InBuildingMode;
319 }
320 return false;
321 }
322 return true;
323 }
324 }
325
327
328 public static KeyConfiguration ProfileGamepadUI => CurrentProfile.InputModes[InputMode.XBoxGamepadUI];
329
330 public static bool UsingGamepad
331 {
332 get
333 {
334 if (CurrentInputMode != InputMode.XBoxGamepad)
335 {
336 return CurrentInputMode == InputMode.XBoxGamepadUI;
337 }
338 return true;
339 }
340 }
341
342 public static bool UsingGamepadUI => CurrentInputMode == InputMode.XBoxGamepadUI;
343
344 public static bool IgnoreMouseInterface
345 {
346 get
347 {
348 if (Main.LocalPlayer.itemAnimation > 0 && !UsingGamepad)
349 {
350 return true;
351 }
354 {
355 return false;
356 }
357 return flag;
358 }
359 }
360
362
363 public static bool ShouldFastUseItem => _fastUseMemory.CanFastUse();
364
365 public static bool InBuildingMode => _InBuildingMode;
366
368
370
371 public static bool CursorIsBusy
372 {
373 get
374 {
376 {
377 return ItemSlot.QuicksRadialOpacity > 0f;
378 }
379 return true;
380 }
381 }
382
384
385 public static event Action OnBindingChange;
386
387 public static event Action OnActionableInput;
388
394
395 private static bool InvalidateKeyboardSwap()
396 {
397 if (_invalidatorCheck.Length == 0)
398 {
399 return false;
400 }
401 string text = "";
403 for (int i = 0; i < pressedKeys.Count; i++)
404 {
405 text = string.Concat(text, pressedKeys[i], ", ");
406 }
407 if (text == _invalidatorCheck)
408 {
409 return true;
410 }
412 return false;
413 }
414
416 {
417 bool isActive = Main.instance.IsActive;
419 {
420 MouseInfo = default(MouseState);
421 MouseInfoOld = default(MouseState);
422 Main.keyState = Keyboard.GetState();
423 Main.inputText = Keyboard.GetState();
424 Main.oldInputText = Keyboard.GetState();
425 Main.keyCount = 0;
426 Triggers.Reset();
427 Triggers.Reset();
428 string text = "";
430 for (int i = 0; i < pressedKeys.Count; i++)
431 {
432 text = string.Concat(text, pressedKeys[i], ", ");
433 }
435 }
437 }
438
440 {
441 List<Keys> list = Main.keyState.GetPressedKeys().ToList();
442 for (int num = list.Count - 1; num >= 0; num--)
443 {
444 if (list[num] == Keys.None || list[num] == Keys.Kanji)
445 {
446 list.RemoveAt(num);
447 }
448 }
449 return list;
450 }
451
453 {
454 _fastUseMemory.TryStartForItemSlot(Main.LocalPlayer, inventorySlot);
455 }
456
458 {
459 _fastUseMemory.TryStartForMouse(Main.LocalPlayer);
460 }
461
462 public static void TryEndingFastUse()
463 {
464 _fastUseMemory.EndFastUse();
465 }
466
481
497
498 public static void VerifyBuildingMode()
499 {
500 if (_InBuildingMode)
501 {
503 bool flag = false;
504 if (Main.mouseItem.stack <= 0)
505 {
506 flag = true;
507 }
508 if (obj.dead)
509 {
510 flag = true;
511 }
512 if (flag)
513 {
515 }
516 }
517 }
518
519 public static void SetSelectedProfile(string name)
520 {
521 if (Profiles.ContainsKey(name))
522 {
523 _selectedProfile = name;
525 }
526 }
527
528 public static void Initialize()
529 {
530 Main.InputProfiles.OnProcessText += PrettyPrintProfiles;
531 Player.Hooks.OnEnterWorld += Hook_OnEnterWorld;
535 playerInputProfile = new PlayerInputProfile("Yoraiz0r's Pick");
538 playerInputProfile = new PlayerInputProfile("Console (Playstation)");
541 playerInputProfile = new PlayerInputProfile("Console (Xbox)");
547 playerInputProfile = new PlayerInputProfile("Redigit's Pick");
550 playerInputProfile = new PlayerInputProfile("Yoraiz0r's Pick");
553 playerInputProfile = new PlayerInputProfile("Console (Playstation)");
556 playerInputProfile = new PlayerInputProfile("Console (Xbox)");
559 SetSelectedProfile("Custom");
560 Triggers.Initialize();
561 }
562
563 public static void Hook_OnEnterWorld(Player player)
564 {
565 if (player.whoAmI == Main.myPlayer)
566 {
567 Main.SmartCursorWanted_GamePad = true;
568 }
569 }
570
571 public static bool Save()
572 {
573 Main.InputProfiles.Clear();
574 Main.InputProfiles.Put("Selected Profile", _selectedProfile);
576 {
577 Main.InputProfiles.Put(profile.Value.Name, profile.Value.Save());
578 }
579 return Main.InputProfiles.Save();
580 }
581
582 public static void Load()
583 {
584 Main.InputProfiles.Load();
586 string currentValue = null;
587 Main.InputProfiles.Get("Selected Profile", ref currentValue);
588 List<string> allKeys = Main.InputProfiles.GetAllKeys();
589 for (int i = 0; i < allKeys.Count; i++)
590 {
591 string text = allKeys[i];
592 if (text == "Selected Profile" || string.IsNullOrEmpty(text))
593 {
594 continue;
595 }
598 if (currentValue2.Count > 0)
599 {
603 {
605 }
606 }
607 }
608 if (dictionary.Count > 0)
609 {
611 if (!string.IsNullOrEmpty(currentValue) && Profiles.ContainsKey(currentValue))
612 {
613 SetSelectedProfile(currentValue);
614 }
615 else
616 {
617 SetSelectedProfile(Profiles.Keys.First());
618 }
619 }
620 }
621
622 public static void ManageVersion_1_3()
623 {
625 string[,] array = new string[20, 2]
626 {
627 { "KeyUp", "Up" },
628 { "KeyDown", "Down" },
629 { "KeyLeft", "Left" },
630 { "KeyRight", "Right" },
631 { "KeyJump", "Jump" },
632 { "KeyThrowItem", "Throw" },
633 { "KeyInventory", "Inventory" },
634 { "KeyQuickHeal", "QuickHeal" },
635 { "KeyQuickMana", "QuickMana" },
636 { "KeyQuickBuff", "QuickBuff" },
637 { "KeyUseHook", "Grapple" },
638 { "KeyAutoSelect", "SmartSelect" },
639 { "KeySmartCursor", "SmartCursor" },
640 { "KeyMount", "QuickMount" },
641 { "KeyMapStyle", "MapStyle" },
642 { "KeyFullscreenMap", "MapFull" },
643 { "KeyMapZoomIn", "MapZoomIn" },
644 { "KeyMapZoomOut", "MapZoomOut" },
645 { "KeyMapAlphaUp", "MapAlphaUp" },
646 { "KeyMapAlphaDown", "MapAlphaDown" }
647 };
648 for (int i = 0; i < array.GetLength(0); i++)
649 {
650 string currentValue = null;
651 Main.Configuration.Get(array[i, 0], ref currentValue);
652 if (currentValue != null)
653 {
654 playerInputProfile.InputModes[InputMode.Keyboard].KeyStatus[array[i, 1]] = new List<string> { currentValue };
655 playerInputProfile.InputModes[InputMode.KeyboardUI].KeyStatus[array[i, 1]] = new List<string> { currentValue };
656 }
657 }
658 }
659
660 public static void LockGamepadButtons(string TriggerName)
661 {
662 List<string> value = null;
664 if (CurrentProfile.InputModes.TryGetValue(CurrentInputMode, out value2) && value2.KeyStatus.TryGetValue(TriggerName, out value))
665 {
666 _buttonsLocked.AddRange(value);
667 }
668 }
669
670 public static bool IsGamepadButtonLockedFromUse(string keyName)
671 {
672 return _buttonsLocked.Contains(keyName);
673 }
674
675 public static void UpdateInput()
676 {
678 Triggers.Reset();
683 GrappleAndInteractAreShared = (UsingGamepad || SteamDeckIsUsed) && CurrentProfile.InputModes[InputMode.XBoxGamepad].DoGrappleAndInteractShareTheSameKey;
685 {
687 }
689 {
691 Triggers.Current.UsedMovementKey = false;
693 {
694 UIManageControls.ForceMoveTo = _memoOfLastPoint;
695 _memoOfLastPoint = -1;
696 }
697 }
700 MouseInput();
701 int num = 0 | (KeyboardInput() ? 1 : 0) | (GamePadInput() ? 1 : 0);
702 Triggers.Update();
703 PostInput();
706 WritingText = false;
708 Main.mouseLeft = Triggers.Current.MouseLeft;
709 Main.mouseRight = Triggers.Current.MouseRight;
711 if (num != 0 && PlayerInput.OnActionableInput != null)
712 {
714 }
715 }
716
717 public static void UpdateMainMouse()
718 {
719 Main.lastMouseX = Main.mouseX;
720 Main.lastMouseY = Main.mouseY;
721 Main.mouseX = MouseX;
722 Main.mouseY = MouseY;
723 }
724
725 public static void CacheZoomableValues()
726 {
729 }
730
731 public static void CacheMousePositionForZoom()
732 {
733 float num = 1f;
734 _originalMouseX = (int)((float)Main.mouseX * num);
735 _originalMouseY = (int)((float)Main.mouseY * num);
736 }
737
745
751
752 private static bool GamePadInput()
753 {
754 bool flag = false;
757 bool flag2 = false;
758 for (int i = 0; i < 4; i++)
759 {
760 GamePadState state = GamePad.GetState((PlayerIndex)i);
761 if (state.IsConnected)
762 {
763 flag2 = true;
765 break;
766 }
767 }
769 {
770 return false;
771 }
772 if (!flag2)
773 {
774 return false;
775 }
777 {
778 return false;
779 }
780 Player player = Main.player[Main.myPlayer];
781 bool flag3 = UILinkPointNavigator.Available && !InBuildingMode;
782 InputMode inputMode = InputMode.XBoxGamepad;
783 if (Main.gameMenu || flag3 || player.talkNPC != -1 || player.sign != -1 || IngameFancyUI.CanCover())
784 {
785 inputMode = InputMode.XBoxGamepadUI;
786 }
788 {
789 inputMode = InputMode.XBoxGamepad;
790 }
791 if (CurrentInputMode == InputMode.XBoxGamepad && inputMode == InputMode.XBoxGamepadUI)
792 {
793 flag = true;
794 }
795 if (CurrentInputMode == InputMode.XBoxGamepadUI && inputMode == InputMode.XBoxGamepad)
796 {
797 flag = true;
798 }
799 if (flag)
800 {
802 }
804 int num = 2145386496;
805 for (int j = 0; j < ButtonsGamepad.Length; j++)
806 {
807 if ((int)((uint)num & (uint)ButtonsGamepad[j]) > 0)
808 {
809 continue;
810 }
811 string text = ButtonsGamepad[j].ToString();
812 bool flag4 = _buttonsLocked.Contains(text);
813 if (gamePadState.IsButtonDown(ButtonsGamepad[j]))
814 {
815 if (!flag4)
816 {
818 {
819 return false;
820 }
821 keyConfiguration.Processkey(Triggers.Current, text, inputMode);
822 flag = true;
823 }
824 }
825 else
826 {
827 _buttonsLocked.Remove(text);
828 }
829 }
830 GamepadThumbstickLeft = gamePadState.ThumbSticks.Left * new Vector2(1f, -1f) * new Vector2(CurrentProfile.LeftThumbstickInvertX.ToDirectionInt() * -1, CurrentProfile.LeftThumbstickInvertY.ToDirectionInt() * -1);
831 GamepadThumbstickRight = gamePadState.ThumbSticks.Right * new Vector2(1f, -1f) * new Vector2(CurrentProfile.RightThumbstickInvertX.ToDirectionInt() * -1, CurrentProfile.RightThumbstickInvertY.ToDirectionInt() * -1);
835 if (vector != Vector2.Zero)
836 {
837 vector.Normalize();
838 }
840 if (vector2 != Vector2.Zero)
841 {
842 vector2.Normalize();
843 }
844 float num2 = 0.6f;
845 float triggersDeadzone = CurrentProfile.TriggersDeadzone;
846 if (inputMode == InputMode.XBoxGamepadUI)
847 {
848 num2 = 0.4f;
850 {
852 }
853 GamepadAllowScrolling = false;
854 }
855 if (Vector2.Dot(-Vector2.UnitX, vector2) >= num2 && gamepadThumbstickLeft.X < 0f - CurrentProfile.LeftThumbstickDeadzoneX)
856 {
857 if (CheckRebindingProcessGamepad(Buttons.LeftThumbstickLeft.ToString()))
858 {
859 return false;
860 }
861 keyConfiguration.Processkey(Triggers.Current, Buttons.LeftThumbstickLeft.ToString(), inputMode);
862 flag = true;
863 }
864 if (Vector2.Dot(Vector2.UnitX, vector2) >= num2 && gamepadThumbstickLeft.X > CurrentProfile.LeftThumbstickDeadzoneX)
865 {
866 if (CheckRebindingProcessGamepad(Buttons.LeftThumbstickRight.ToString()))
867 {
868 return false;
869 }
870 keyConfiguration.Processkey(Triggers.Current, Buttons.LeftThumbstickRight.ToString(), inputMode);
871 flag = true;
872 }
873 if (Vector2.Dot(-Vector2.UnitY, vector2) >= num2 && gamepadThumbstickLeft.Y < 0f - CurrentProfile.LeftThumbstickDeadzoneY)
874 {
875 if (CheckRebindingProcessGamepad(Buttons.LeftThumbstickUp.ToString()))
876 {
877 return false;
878 }
879 keyConfiguration.Processkey(Triggers.Current, Buttons.LeftThumbstickUp.ToString(), inputMode);
880 flag = true;
881 }
882 if (Vector2.Dot(Vector2.UnitY, vector2) >= num2 && gamepadThumbstickLeft.Y > CurrentProfile.LeftThumbstickDeadzoneY)
883 {
884 if (CheckRebindingProcessGamepad(Buttons.LeftThumbstickDown.ToString()))
885 {
886 return false;
887 }
888 keyConfiguration.Processkey(Triggers.Current, Buttons.LeftThumbstickDown.ToString(), inputMode);
889 flag = true;
890 }
891 if (Vector2.Dot(-Vector2.UnitX, vector) >= num2 && gamepadThumbstickRight.X < 0f - CurrentProfile.RightThumbstickDeadzoneX)
892 {
893 if (CheckRebindingProcessGamepad(Buttons.RightThumbstickLeft.ToString()))
894 {
895 return false;
896 }
897 keyConfiguration.Processkey(Triggers.Current, Buttons.RightThumbstickLeft.ToString(), inputMode);
898 flag = true;
899 }
900 if (Vector2.Dot(Vector2.UnitX, vector) >= num2 && gamepadThumbstickRight.X > CurrentProfile.RightThumbstickDeadzoneX)
901 {
902 if (CheckRebindingProcessGamepad(Buttons.RightThumbstickRight.ToString()))
903 {
904 return false;
905 }
906 keyConfiguration.Processkey(Triggers.Current, Buttons.RightThumbstickRight.ToString(), inputMode);
907 flag = true;
908 }
909 if (Vector2.Dot(-Vector2.UnitY, vector) >= num2 && gamepadThumbstickRight.Y < 0f - CurrentProfile.RightThumbstickDeadzoneY)
910 {
911 if (CheckRebindingProcessGamepad(Buttons.RightThumbstickUp.ToString()))
912 {
913 return false;
914 }
915 keyConfiguration.Processkey(Triggers.Current, Buttons.RightThumbstickUp.ToString(), inputMode);
916 flag = true;
917 }
918 if (Vector2.Dot(Vector2.UnitY, vector) >= num2 && gamepadThumbstickRight.Y > CurrentProfile.RightThumbstickDeadzoneY)
919 {
920 if (CheckRebindingProcessGamepad(Buttons.RightThumbstickDown.ToString()))
921 {
922 return false;
923 }
924 keyConfiguration.Processkey(Triggers.Current, Buttons.RightThumbstickDown.ToString(), inputMode);
925 flag = true;
926 }
927 if (gamePadState.Triggers.Left > triggersDeadzone)
928 {
929 if (CheckRebindingProcessGamepad(Buttons.LeftTrigger.ToString()))
930 {
931 return false;
932 }
933 keyConfiguration.Processkey(Triggers.Current, Buttons.LeftTrigger.ToString(), inputMode);
934 flag = true;
935 }
936 if (gamePadState.Triggers.Right > triggersDeadzone)
937 {
938 string newKey = Buttons.RightTrigger.ToString();
940 {
941 return false;
942 }
944 {
945 Triggers.Current.MouseLeft = true;
946 }
947 else
948 {
949 keyConfiguration.Processkey(Triggers.Current, newKey, inputMode);
950 flag = true;
951 }
952 }
954 Item item = player.inventory[player.selectedItem];
955 int num3 = item.tileBoost + ItemID.Sets.GamepadExtraRange[item.type];
956 if (player.yoyoString && ItemID.Sets.Yoyo[item.type])
957 {
958 num3 += 5;
959 }
960 else if (item.createTile < 0 && item.createWall <= 0 && item.shoot > 0)
961 {
962 num3 += 10;
963 }
964 else if (player.controlTorch)
965 {
966 num3++;
967 }
968 if (item.createWall > 0 || item.createTile > 0 || item.tileWand > 0)
969 {
970 num3 += player.blockRange;
971 }
972 if (flag5)
973 {
974 num3 += 30;
975 }
976 if (player.mount.Active && player.mount.Type == 8)
977 {
978 num3 = 10;
979 }
980 bool flag6 = false;
981 bool flag7 = !Main.gameMenu && !flag3 && Main.SmartCursorWanted;
982 if (!CursorIsBusy)
983 {
984 bool flag8 = Main.mapFullscreen || (!Main.gameMenu && !flag3);
985 int num4 = Main.screenWidth / 2;
986 int num5 = Main.screenHeight / 2;
987 if (!Main.mapFullscreen && flag8 && !flag5)
988 {
989 Point point = Main.ReverseGravitySupport(player.Center - Main.screenPosition).ToPoint();
990 num4 = point.X;
991 num5 = point.Y;
992 }
994 {
995 num4 += player.direction * 10;
996 }
997 float m = Main.GameViewMatrix.ZoomMatrix.M11;
998 smartSelectPointer.UpdateSize(new Vector2(Player.tileRangeX * 16 + num3 * 16, Player.tileRangeY * 16 + num3 * 16) * m);
999 if (flag5)
1000 {
1002 }
1003 smartSelectPointer.UpdateCenter(new Vector2(num4, num5));
1005 {
1006 Vector2 vector3 = new Vector2(8f);
1008 {
1009 vector3 = new Vector2(16f);
1010 }
1011 if (flag7)
1012 {
1014 if (num3 != 0)
1015 {
1016 vector3 += new Vector2(num3 * 16, num3 * 16);
1017 }
1018 if (flag5)
1019 {
1021 }
1022 }
1023 else if (!Main.mapFullscreen)
1024 {
1025 if (player.inventory[player.selectedItem].mech)
1026 {
1027 vector3 += Vector2.Zero;
1028 }
1029 else
1030 {
1031 vector3 += new Vector2(num3) / 4f;
1032 }
1033 }
1034 float m2 = Main.GameViewMatrix.ZoomMatrix.M11;
1036 int num6 = MouseX - num4;
1037 int num7 = MouseY - num5;
1038 if (flag7)
1039 {
1040 num6 = 0;
1041 num7 = 0;
1042 }
1043 num6 += (int)vector4.X;
1044 num7 += (int)vector4.Y;
1045 MouseX = num6 + num4;
1046 MouseY = num7 + num5;
1047 flag = true;
1048 flag6 = true;
1050 }
1053 {
1054 float num8 = 8f;
1056 {
1057 num8 = 3f;
1058 }
1059 if (Main.mapFullscreen)
1060 {
1062 Main.mapFullscreenPos += vector5 * num8 * (1f / Main.mapFullscreenScale);
1063 flag = true;
1064 }
1066 {
1067 float m3 = Main.GameViewMatrix.ZoomMatrix.M11;
1069 if (num3 != 0)
1070 {
1072 }
1073 if (flag5)
1074 {
1076 }
1077 int num9 = (int)vector6.X;
1078 int num10 = (int)vector6.Y;
1079 MouseX = num9 + num4;
1080 MouseY = num10 + num5;
1081 flag6 = true;
1082 }
1083 flag = true;
1084 }
1085 if (CurrentInputMode == InputMode.XBoxGamepad)
1086 {
1089 {
1090 int num11 = MouseX - num4;
1091 int num12 = MouseY - num5;
1092 if (!Main.gameMenu && !flag3)
1093 {
1094 if (flag5 && !Main.mapFullscreen)
1095 {
1096 float num13 = 1f;
1097 int num14 = Main.screenWidth / 2;
1098 int num15 = Main.screenHeight / 2;
1099 num11 = (int)Utils.Clamp(num11, (float)(-num14) * num13, (float)num14 * num13);
1100 num12 = (int)Utils.Clamp(num12, (float)(-num15) * num13, (float)num15 * num13);
1101 }
1102 else
1103 {
1104 float num16 = 0f;
1105 if (player.HeldItem.createTile >= 0 || player.HeldItem.createWall > 0 || player.HeldItem.tileWand >= 0)
1106 {
1107 num16 = 0.5f;
1108 }
1109 float m4 = Main.GameViewMatrix.ZoomMatrix.M11;
1110 float num17 = (0f - ((float)(Player.tileRangeY + num3) - num16)) * 16f * m4;
1111 float max = ((float)(Player.tileRangeY + num3) - num16) * 16f * m4;
1112 num17 -= (float)(player.height / 16 / 2 * 16);
1113 num11 = (int)Utils.Clamp(num11, (0f - ((float)(Player.tileRangeX + num3) - num16)) * 16f * m4, ((float)(Player.tileRangeX + num3) - num16) * 16f * m4);
1114 num12 = (int)Utils.Clamp(num12, num17, max);
1115 }
1116 if (flag7 && (!flag || flag5))
1117 {
1118 float num18 = 0.81f;
1119 if (flag5)
1120 {
1121 num18 = 0.95f;
1122 }
1123 num11 = (int)((float)num11 * num18);
1124 num12 = (int)((float)num12 * num18);
1125 }
1126 }
1127 else
1128 {
1129 num11 = Utils.Clamp(num11, -num4 + 10, num4 - 10);
1130 num12 = Utils.Clamp(num12, -num5 + 10, num5 - 10);
1131 }
1132 MouseX = num11 + num4;
1133 MouseY = num12 + num5;
1134 }
1135 }
1136 }
1137 if (flag)
1138 {
1140 }
1141 if (CurrentInputMode == InputMode.XBoxGamepad)
1142 {
1144 }
1145 if (CurrentInputMode != InputMode.XBoxGamepadUI && flag)
1146 {
1148 }
1149 if (!flag)
1150 {
1152 }
1153 if (CurrentInputMode == InputMode.XBoxGamepadUI && flag && !PreventCursorModeSwappingToGamepad)
1154 {
1156 }
1157 return flag;
1158 }
1159
1160 private static void MouseInput()
1161 {
1162 bool flag = false;
1164 MouseInfo = Mouse.GetState();
1165 ScrollWheelValue += MouseInfo.ScrollWheelValue;
1166 if (MouseInfo.X != MouseInfoOld.X || MouseInfo.Y != MouseInfoOld.Y || MouseInfo.ScrollWheelValue != MouseInfoOld.ScrollWheelValue)
1167 {
1168 MouseX = (int)((float)MouseInfo.X * RawMouseScale.X);
1169 MouseY = (int)((float)MouseInfo.Y * RawMouseScale.Y);
1171 {
1172 flag = true;
1174 }
1176 }
1177 MouseKeys.Clear();
1178 if (Main.instance.IsActive)
1179 {
1180 if (MouseInfo.LeftButton == ButtonState.Pressed)
1181 {
1182 MouseKeys.Add("Mouse1");
1183 flag = true;
1184 }
1185 if (MouseInfo.RightButton == ButtonState.Pressed)
1186 {
1187 MouseKeys.Add("Mouse2");
1188 flag = true;
1189 }
1190 if (MouseInfo.MiddleButton == ButtonState.Pressed)
1191 {
1192 MouseKeys.Add("Mouse3");
1193 flag = true;
1194 }
1195 if (MouseInfo.XButton1 == ButtonState.Pressed)
1196 {
1197 MouseKeys.Add("Mouse4");
1198 flag = true;
1199 }
1200 if (MouseInfo.XButton2 == ButtonState.Pressed)
1201 {
1202 MouseKeys.Add("Mouse5");
1203 flag = true;
1204 }
1205 }
1206 if (flag)
1207 {
1209 Triggers.Current.UsedMovementKey = false;
1210 }
1211 }
1212
1213 private static bool KeyboardInput()
1214 {
1215 bool flag = false;
1216 bool flag2 = false;
1219 if (pressedKeys.Count == 0 && MouseKeys.Count == 0)
1220 {
1221 Main.blockKey = Keys.None.ToString();
1222 return false;
1223 }
1224 for (int i = 0; i < pressedKeys.Count; i++)
1225 {
1226 if (pressedKeys[i] == Keys.LeftShift || pressedKeys[i] == Keys.RightShift)
1227 {
1228 flag = true;
1229 }
1230 else if (pressedKeys[i] == Keys.LeftAlt || pressedKeys[i] == Keys.RightAlt)
1231 {
1232 flag2 = true;
1233 }
1234 Main.ChromaPainter.PressKey(pressedKeys[i]);
1235 }
1236 if (Main.blockKey != Keys.None.ToString())
1237 {
1238 bool flag3 = false;
1239 for (int j = 0; j < pressedKeys.Count; j++)
1240 {
1242 {
1243 pressedKeys[j] = Keys.None;
1244 flag3 = true;
1245 }
1246 }
1247 if (!flag3)
1248 {
1249 Main.blockKey = Keys.None.ToString();
1250 }
1251 }
1253 if (Main.gameMenu && !WritingText)
1254 {
1255 keyConfiguration = CurrentProfile.InputModes[InputMode.KeyboardUI];
1256 }
1258 for (int k = 0; k < pressedKeys.Count; k++)
1259 {
1260 list.Add(pressedKeys[k].ToString());
1261 }
1262 if (WritingText)
1263 {
1264 list.Clear();
1265 }
1266 int count = list.Count;
1267 list.AddRange(MouseKeys);
1268 bool flag4 = false;
1269 for (int l = 0; l < list.Count; l++)
1270 {
1271 if (l < count && pressedKeys[l] == Keys.None)
1272 {
1273 continue;
1274 }
1275 string newKey = list[l];
1276 if (!(list[l] == Keys.Tab.ToString()) || !((flag && SocialAPI.Mode == SocialMode.Steam) || flag2))
1277 {
1279 {
1280 return false;
1281 }
1282 _ = Main.oldKeyState;
1283 if (l >= count || !Main.oldKeyState.IsKeyDown(pressedKeys[l]))
1284 {
1285 keyConfiguration.Processkey(Triggers.Current, newKey, InputMode.Keyboard);
1286 }
1287 else
1288 {
1289 keyConfiguration.CopyKeyState(Triggers.Old, Triggers.Current, newKey);
1290 }
1291 if (l >= count || pressedKeys[l] != 0)
1292 {
1293 flag4 = true;
1294 }
1295 }
1296 }
1297 if (flag4)
1298 {
1299 CurrentInputMode = InputMode.Keyboard;
1300 }
1301 return flag4;
1302 }
1303
1304 private static void DebugKeys(List<Keys> keys)
1305 {
1306 }
1307
1308 private static void FixDerpedRebinds()
1309 {
1310 List<string> list = new List<string> { "MouseLeft", "MouseRight", "Inventory" };
1312 {
1313 if (value == InputMode.Mouse)
1314 {
1315 continue;
1316 }
1318 foreach (string item in list)
1319 {
1320 if (CurrentProfile.InputModes[value].KeyStatus[item].Count < 1)
1321 {
1323 }
1324 }
1325 }
1326 }
1327
1329 {
1330 for (int i = 0; i < triggers.Count; i++)
1331 {
1332 for (int j = i + 1; j < triggers.Count; j++)
1333 {
1334 List<string> list = CurrentProfile.InputModes[inputMode].KeyStatus[triggers[i]];
1335 List<string> list2 = CurrentProfile.InputModes[inputMode].KeyStatus[triggers[j]];
1336 foreach (string item in list.Intersect(list2).ToList())
1337 {
1338 list.Remove(item);
1339 list2.Remove(item);
1340 }
1341 }
1342 }
1343 }
1344
1345 private static void ResetKeyBinding(InputMode inputMode, string trigger)
1346 {
1347 string key = "Redigit's Pick";
1348 if (OriginalProfiles.ContainsKey(_selectedProfile))
1349 {
1351 }
1352 CurrentProfile.InputModes[inputMode].KeyStatus[trigger].Clear();
1353 CurrentProfile.InputModes[inputMode].KeyStatus[trigger].AddRange(OriginalProfiles[key].InputModes[inputMode].KeyStatus[trigger]);
1354 }
1355
1356 private static bool CheckRebindingProcessGamepad(string newKey)
1357 {
1359 if (CurrentlyRebinding && _listeningInputMode == InputMode.XBoxGamepad)
1360 {
1364 if (CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus[ListeningTrigger].Contains(newKey))
1365 {
1366 CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus[ListeningTrigger].Remove(newKey);
1367 }
1368 else
1369 {
1370 CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus[ListeningTrigger] = new List<string> { newKey };
1371 }
1372 ListenFor(null, InputMode.XBoxGamepad);
1373 }
1374 if (CurrentlyRebinding && _listeningInputMode == InputMode.XBoxGamepadUI)
1375 {
1379 if (CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus[ListeningTrigger].Contains(newKey))
1380 {
1381 CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus[ListeningTrigger].Remove(newKey);
1382 }
1383 else
1384 {
1385 CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus[ListeningTrigger] = new List<string> { newKey };
1386 }
1387 ListenFor(null, InputMode.XBoxGamepadUI);
1388 }
1390 if (PlayerInput.OnBindingChange != null)
1391 {
1393 }
1394 return NavigatorRebindingLock > 0;
1395 }
1396
1397 private static bool CheckRebindingProcessKeyboard(string newKey)
1398 {
1401 {
1405 if (CurrentProfile.InputModes[InputMode.Keyboard].KeyStatus[ListeningTrigger].Contains(newKey))
1406 {
1407 CurrentProfile.InputModes[InputMode.Keyboard].KeyStatus[ListeningTrigger].Remove(newKey);
1408 }
1409 else
1410 {
1411 CurrentProfile.InputModes[InputMode.Keyboard].KeyStatus[ListeningTrigger] = new List<string> { newKey };
1412 }
1413 ListenFor(null, InputMode.Keyboard);
1414 Main.blockKey = newKey;
1415 Main.blockInput = false;
1416 Main.ChromaPainter.CollectBoundKeys();
1417 }
1419 {
1423 if (CurrentProfile.InputModes[InputMode.KeyboardUI].KeyStatus[ListeningTrigger].Contains(newKey))
1424 {
1425 CurrentProfile.InputModes[InputMode.KeyboardUI].KeyStatus[ListeningTrigger].Remove(newKey);
1426 }
1427 else
1428 {
1429 CurrentProfile.InputModes[InputMode.KeyboardUI].KeyStatus[ListeningTrigger] = new List<string> { newKey };
1430 }
1431 ListenFor(null, InputMode.KeyboardUI);
1432 Main.blockKey = newKey;
1433 Main.blockInput = false;
1434 Main.ChromaPainter.CollectBoundKeys();
1435 }
1437 if (PlayerInput.OnBindingChange != null)
1438 {
1440 }
1441 return NavigatorRebindingLock > 0;
1442 }
1443
1444 private static void PostInput()
1445 {
1447 if (CurrentProfile.HotbarAllowsRadial)
1448 {
1449 int num = Triggers.Current.HotbarPlus.ToInt() - Triggers.Current.HotbarMinus.ToInt();
1451 {
1452 switch (num)
1453 {
1454 case 1:
1455 Triggers.Current.RadialHotbar = true;
1456 Triggers.JustReleased.RadialHotbar = false;
1457 break;
1458 case -1:
1459 Triggers.Current.RadialQuickbar = true;
1460 Triggers.JustReleased.RadialQuickbar = false;
1461 break;
1462 }
1463 }
1464 }
1465 MiscSettingsTEMP.HotbarRadialShouldBeUsed = false;
1466 }
1467
1468 private static void HandleDpadSnap()
1469 {
1471 Player player = Main.player[Main.myPlayer];
1472 for (int i = 0; i < 4; i++)
1473 {
1474 bool flag = false;
1477 {
1478 return;
1479 }
1480 switch (i)
1481 {
1482 case 0:
1483 flag = Triggers.Current.DpadMouseSnap1;
1484 vector = -Vector2.UnitY;
1485 break;
1486 case 1:
1487 flag = Triggers.Current.DpadMouseSnap2;
1489 break;
1490 case 2:
1491 flag = Triggers.Current.DpadMouseSnap3;
1493 break;
1494 case 3:
1495 flag = Triggers.Current.DpadMouseSnap4;
1496 vector = -Vector2.UnitX;
1497 break;
1498 }
1499 if (DpadSnapCooldown[i] > 0)
1500 {
1501 DpadSnapCooldown[i]--;
1502 }
1503 if (flag)
1504 {
1505 if (DpadSnapCooldown[i] == 0)
1506 {
1507 int num = 6;
1508 if (ItemSlot.IsABuildingItem(player.inventory[player.selectedItem]))
1509 {
1510 num = player.inventory[player.selectedItem].useTime;
1511 }
1512 DpadSnapCooldown[i] = num;
1513 zero += vector;
1514 }
1515 }
1516 else
1517 {
1518 DpadSnapCooldown[i] = 0;
1519 }
1520 }
1521 if (zero != Vector2.Zero)
1522 {
1523 Main.SmartCursorWanted_GamePad = false;
1524 Matrix zoomMatrix = Main.GameViewMatrix.ZoomMatrix;
1525 Matrix matrix = Matrix.Invert(zoomMatrix);
1528 Vector2 vector2 = Vector2.Transform((Vector2.Transform(mouseScreen, matrix) + zero * new Vector2(16f) + Main.screenPosition).ToTileCoordinates().ToWorldCoordinates() - Main.screenPosition, zoomMatrix);
1529 MouseX = (int)vector2.X;
1530 MouseY = (int)vector2.Y;
1532 }
1533 }
1534
1536 {
1537 if (!UsingGamepad)
1538 {
1539 return SteamDeckIsUsed;
1540 }
1541 return true;
1542 }
1543
1544 public static string ComposeInstructionsForGamepad()
1545 {
1546 string empty = string.Empty;
1547 InputMode inputMode = InputMode.XBoxGamepad;
1549 {
1550 inputMode = InputMode.XBoxGamepadUI;
1551 }
1553 {
1554 inputMode = InputMode.XBoxGamepad;
1555 }
1558 {
1559 empty += " ";
1560 empty += BuildCommand(Lang.misc[56].Value, false, ProfileGamepadUI.KeyStatus["Inventory"]);
1561 empty += BuildCommand(Lang.inter[118].Value, false, ProfileGamepadUI.KeyStatus["HotbarPlus"]);
1562 empty += BuildCommand(Lang.inter[119].Value, false, ProfileGamepadUI.KeyStatus["HotbarMinus"]);
1563 if (Main.netMode == 1 && Main.player[Main.myPlayer].HasItem(2997))
1564 {
1565 empty += BuildCommand(Lang.inter[120].Value, false, ProfileGamepadUI.KeyStatus["MouseRight"]);
1566 }
1567 }
1568 else if (inputMode == InputMode.XBoxGamepadUI && !InBuildingMode)
1569 {
1571 }
1572 else
1573 {
1574 empty += BuildCommand(Lang.misc[58].Value, false, keyConfiguration.KeyStatus["Jump"]);
1575 empty += BuildCommand(Lang.misc[59].Value, false, keyConfiguration.KeyStatus["HotbarMinus"], keyConfiguration.KeyStatus["HotbarPlus"]);
1576 if (InBuildingMode)
1577 {
1578 empty += BuildCommand(Lang.menu[6].Value, false, keyConfiguration.KeyStatus["Inventory"], keyConfiguration.KeyStatus["MouseRight"]);
1579 }
1580 if (WiresUI.Open)
1581 {
1582 empty += BuildCommand(Lang.misc[53].Value, false, keyConfiguration.KeyStatus["MouseLeft"]);
1583 empty += BuildCommand(Lang.misc[56].Value, false, keyConfiguration.KeyStatus["MouseRight"]);
1584 }
1585 else
1586 {
1587 Item item = Main.player[Main.myPlayer].inventory[Main.player[Main.myPlayer].selectedItem];
1588 empty = ((item.damage > 0 && item.ammo == 0) ? (empty + BuildCommand(Lang.misc[60].Value, false, keyConfiguration.KeyStatus["MouseLeft"])) : ((item.createTile < 0 && item.createWall <= 0) ? (empty + BuildCommand(Lang.misc[63].Value, false, keyConfiguration.KeyStatus["MouseLeft"])) : (empty + BuildCommand(Lang.misc[61].Value, false, keyConfiguration.KeyStatus["MouseLeft"]))));
1589 bool flag = true;
1590 bool flag2 = Main.SmartInteractProj != -1 || Main.HasInteractibleObjectThatIsNotATile;
1591 bool flag3 = !Main.SmartInteractShowingGenuine && Main.SmartInteractShowingFake;
1593 {
1594 if (Main.SmartInteractNPC != -1)
1595 {
1596 if (flag3)
1597 {
1598 flag = false;
1599 }
1600 empty += BuildCommand(Lang.misc[80].Value, false, keyConfiguration.KeyStatus["MouseRight"]);
1601 }
1602 else if (flag2)
1603 {
1604 if (flag3)
1605 {
1606 flag = false;
1607 }
1608 empty += BuildCommand(Lang.misc[79].Value, false, keyConfiguration.KeyStatus["MouseRight"]);
1609 }
1610 else if (Main.SmartInteractX != -1 && Main.SmartInteractY != -1)
1611 {
1612 if (flag3)
1613 {
1614 flag = false;
1615 }
1617 empty = ((!TileID.Sets.TileInteractRead[tile.type]) ? (empty + BuildCommand(Lang.misc[79].Value, false, keyConfiguration.KeyStatus["MouseRight"])) : (empty + BuildCommand(Lang.misc[81].Value, false, keyConfiguration.KeyStatus["MouseRight"])));
1618 }
1619 }
1621 {
1622 empty += BuildCommand(Lang.misc[89].Value, false, keyConfiguration.KeyStatus["MouseRight"]);
1623 }
1625 {
1626 empty += BuildCommand(Lang.misc[57].Value, false, keyConfiguration.KeyStatus["Grapple"]);
1627 }
1628 }
1629 }
1630 return empty;
1631 }
1632
1633 public static string BuildCommand(string CommandText, bool Last, params List<string>[] Bindings)
1634 {
1635 string text = "";
1636 if (Bindings.Length == 0)
1637 {
1638 return text;
1639 }
1640 text += GenerateGlyphList(Bindings[0]);
1641 for (int i = 1; i < Bindings.Length; i++)
1642 {
1643 string text2 = GenerateGlyphList(Bindings[i]);
1644 if (text2.Length > 0)
1645 {
1646 text = text + "/" + text2;
1647 }
1648 }
1649 if (text.Length > 0)
1650 {
1651 text = text + ": " + CommandText;
1652 if (!Last)
1653 {
1654 text += " ";
1655 }
1656 }
1657 return text;
1658 }
1659
1661 {
1663 if (inputMode == InputMode.Mouse || inputMode == InputMode.KeyboardUI)
1664 {
1665 inputMode = InputMode.Keyboard;
1666 }
1667 if (!(triggerName == "SmartSelect"))
1668 {
1669 if (triggerName == "SmartCursor" && inputMode == InputMode.Keyboard)
1670 {
1671 return GenerateRawInputList(new List<string> { Keys.LeftAlt.ToString() });
1672 }
1673 }
1674 else if (inputMode == InputMode.Keyboard)
1675 {
1676 return GenerateRawInputList(new List<string> { Keys.LeftControl.ToString() });
1677 }
1679 }
1680
1682 {
1684 if (inputMode == InputMode.Mouse || inputMode == InputMode.KeyboardUI)
1685 {
1686 inputMode = InputMode.Keyboard;
1687 }
1688 if (tagForGameplay)
1689 {
1690 if ((uint)(inputMode - 3) > 1u)
1691 {
1692 return GenerateRawInputList(CurrentProfile.InputModes[inputMode].KeyStatus[triggerName]);
1693 }
1694 return GenerateGlyphList(CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus[triggerName]);
1695 }
1696 if ((uint)(inputMode - 3) > 1u)
1697 {
1698 return GenerateRawInputList(CurrentProfile.InputModes[inputMode].KeyStatus[triggerName]);
1699 }
1700 return GenerateGlyphList(CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus[triggerName]);
1701 }
1702
1703 public static string GenerateInputTags_GamepadUI(string triggerName)
1704 {
1705 return GenerateGlyphList(CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus[triggerName]);
1706 }
1707
1708 public static string GenerateInputTags_Gamepad(string triggerName)
1709 {
1710 return GenerateGlyphList(CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus[triggerName]);
1711 }
1712
1713 private static string GenerateGlyphList(List<string> list)
1714 {
1715 if (list.Count == 0)
1716 {
1717 return "";
1718 }
1719 string text = GlyphTagHandler.GenerateTag(list[0]);
1720 for (int i = 1; i < list.Count; i++)
1721 {
1723 }
1724 return text;
1725 }
1726
1728 {
1729 if (list.Count == 0)
1730 {
1731 return "";
1732 }
1733 string text = list[0];
1734 for (int i = 1; i < list.Count; i++)
1735 {
1736 text = text + "/" + list[i];
1737 }
1738 return text;
1739 }
1740
1741 public static void NavigatorCachePosition()
1742 {
1743 PreUIX = MouseX;
1744 PreUIY = MouseY;
1745 }
1746
1747 public static void NavigatorUnCachePosition()
1748 {
1749 MouseX = PreUIX;
1750 MouseY = PreUIY;
1751 }
1752
1753 public static void LockOnCachePosition()
1754 {
1757 }
1758
1759 public static void LockOnUnCachePosition()
1760 {
1763 }
1764
1765 public static void PrettyPrintProfiles(ref string text)
1766 {
1767 string[] array = text.Split(new string[1] { "\r\n" }, StringSplitOptions.None);
1768 foreach (string text2 in array)
1769 {
1770 if (text2.Contains(": {"))
1771 {
1772 string text3 = text2.Substring(0, text2.IndexOf('"'));
1773 string text4 = text2 + "\r\n ";
1774 string newValue = text4.Replace(": {\r\n ", ": \r\n" + text3 + "{\r\n ");
1775 text = text.Replace(text4, newValue);
1776 }
1777 }
1778 text = text.Replace("[\r\n ", "[");
1779 text = text.Replace("[\r\n ", "[");
1780 text = text.Replace("\"\r\n ", "\"");
1781 text = text.Replace("\",\r\n ", "\", ");
1782 text = text.Replace("\",\r\n ", "\", ");
1783 text = text.Replace("\r\n ]", "]");
1784 }
1785
1786 public static void PrettyPrintProfilesOld(ref string text)
1787 {
1788 text = text.Replace(": {\r\n ", ": \r\n {\r\n ");
1789 text = text.Replace("[\r\n ", "[");
1790 text = text.Replace("\"\r\n ", "\"");
1791 text = text.Replace("\",\r\n ", "\", ");
1792 text = text.Replace("\r\n ]", "]");
1793 }
1794
1795 public static void Reset(KeyConfiguration c, PresetProfiles style, InputMode mode)
1796 {
1797 switch (style)
1798 {
1799 case PresetProfiles.Redigit:
1800 switch (mode)
1801 {
1802 case InputMode.Keyboard:
1803 c.KeyStatus["MouseLeft"].Add("Mouse1");
1804 c.KeyStatus["MouseRight"].Add("Mouse2");
1805 c.KeyStatus["Up"].Add("W");
1806 c.KeyStatus["Down"].Add("S");
1807 c.KeyStatus["Left"].Add("A");
1808 c.KeyStatus["Right"].Add("D");
1809 c.KeyStatus["Jump"].Add("Space");
1810 c.KeyStatus["Inventory"].Add("Escape");
1811 c.KeyStatus["Grapple"].Add("E");
1812 c.KeyStatus["SmartSelect"].Add("LeftShift");
1813 c.KeyStatus["SmartCursor"].Add("LeftControl");
1814 c.KeyStatus["QuickMount"].Add("R");
1815 c.KeyStatus["QuickHeal"].Add("H");
1816 c.KeyStatus["QuickMana"].Add("J");
1817 c.KeyStatus["QuickBuff"].Add("B");
1818 c.KeyStatus["MapStyle"].Add("Tab");
1819 c.KeyStatus["MapFull"].Add("M");
1820 c.KeyStatus["MapZoomIn"].Add("Add");
1821 c.KeyStatus["MapZoomOut"].Add("Subtract");
1822 c.KeyStatus["MapAlphaUp"].Add("PageUp");
1823 c.KeyStatus["MapAlphaDown"].Add("PageDown");
1824 c.KeyStatus["Hotbar1"].Add("D1");
1825 c.KeyStatus["Hotbar2"].Add("D2");
1826 c.KeyStatus["Hotbar3"].Add("D3");
1827 c.KeyStatus["Hotbar4"].Add("D4");
1828 c.KeyStatus["Hotbar5"].Add("D5");
1829 c.KeyStatus["Hotbar6"].Add("D6");
1830 c.KeyStatus["Hotbar7"].Add("D7");
1831 c.KeyStatus["Hotbar8"].Add("D8");
1832 c.KeyStatus["Hotbar9"].Add("D9");
1833 c.KeyStatus["Hotbar10"].Add("D0");
1834 c.KeyStatus["ViewZoomOut"].Add("OemMinus");
1835 c.KeyStatus["ViewZoomIn"].Add("OemPlus");
1836 c.KeyStatus["ToggleCreativeMenu"].Add("C");
1837 c.KeyStatus["Loadout1"].Add("F1");
1838 c.KeyStatus["Loadout2"].Add("F2");
1839 c.KeyStatus["Loadout3"].Add("F3");
1840 c.KeyStatus["ToggleCameraMode"].Add("F4");
1841 break;
1842 case InputMode.KeyboardUI:
1843 c.KeyStatus["MouseLeft"].Add("Mouse1");
1844 c.KeyStatus["MouseLeft"].Add("Space");
1845 c.KeyStatus["MouseRight"].Add("Mouse2");
1846 c.KeyStatus["Up"].Add("W");
1847 c.KeyStatus["Up"].Add("Up");
1848 c.KeyStatus["Down"].Add("S");
1849 c.KeyStatus["Down"].Add("Down");
1850 c.KeyStatus["Left"].Add("A");
1851 c.KeyStatus["Left"].Add("Left");
1852 c.KeyStatus["Right"].Add("D");
1853 c.KeyStatus["Right"].Add("Right");
1854 c.KeyStatus["Inventory"].Add(Keys.Escape.ToString());
1855 c.KeyStatus["MenuUp"].Add(string.Concat(Buttons.DPadUp));
1856 c.KeyStatus["MenuDown"].Add(string.Concat(Buttons.DPadDown));
1857 c.KeyStatus["MenuLeft"].Add(string.Concat(Buttons.DPadLeft));
1858 c.KeyStatus["MenuRight"].Add(string.Concat(Buttons.DPadRight));
1859 break;
1860 case InputMode.XBoxGamepad:
1861 c.KeyStatus["MouseLeft"].Add(string.Concat(Buttons.RightTrigger));
1862 c.KeyStatus["MouseRight"].Add(string.Concat(Buttons.B));
1863 c.KeyStatus["Up"].Add(string.Concat(Buttons.LeftThumbstickUp));
1864 c.KeyStatus["Down"].Add(string.Concat(Buttons.LeftThumbstickDown));
1865 c.KeyStatus["Left"].Add(string.Concat(Buttons.LeftThumbstickLeft));
1866 c.KeyStatus["Right"].Add(string.Concat(Buttons.LeftThumbstickRight));
1867 c.KeyStatus["Jump"].Add(string.Concat(Buttons.LeftTrigger));
1868 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.Y));
1869 c.KeyStatus["Grapple"].Add(string.Concat(Buttons.B));
1870 c.KeyStatus["LockOn"].Add(string.Concat(Buttons.X));
1871 c.KeyStatus["QuickMount"].Add(string.Concat(Buttons.A));
1872 c.KeyStatus["SmartSelect"].Add(string.Concat(Buttons.RightStick));
1873 c.KeyStatus["SmartCursor"].Add(string.Concat(Buttons.LeftStick));
1874 c.KeyStatus["HotbarMinus"].Add(string.Concat(Buttons.LeftShoulder));
1875 c.KeyStatus["HotbarPlus"].Add(string.Concat(Buttons.RightShoulder));
1876 c.KeyStatus["MapFull"].Add(string.Concat(Buttons.Start));
1877 c.KeyStatus["DpadSnap1"].Add(string.Concat(Buttons.DPadUp));
1878 c.KeyStatus["DpadSnap3"].Add(string.Concat(Buttons.DPadDown));
1879 c.KeyStatus["DpadSnap4"].Add(string.Concat(Buttons.DPadLeft));
1880 c.KeyStatus["DpadSnap2"].Add(string.Concat(Buttons.DPadRight));
1881 c.KeyStatus["MapStyle"].Add(string.Concat(Buttons.Back));
1882 break;
1883 case InputMode.XBoxGamepadUI:
1884 c.KeyStatus["MouseLeft"].Add(string.Concat(Buttons.A));
1885 c.KeyStatus["MouseRight"].Add(string.Concat(Buttons.LeftShoulder));
1886 c.KeyStatus["SmartCursor"].Add(string.Concat(Buttons.RightShoulder));
1887 c.KeyStatus["Up"].Add(string.Concat(Buttons.LeftThumbstickUp));
1888 c.KeyStatus["Down"].Add(string.Concat(Buttons.LeftThumbstickDown));
1889 c.KeyStatus["Left"].Add(string.Concat(Buttons.LeftThumbstickLeft));
1890 c.KeyStatus["Right"].Add(string.Concat(Buttons.LeftThumbstickRight));
1891 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.B));
1892 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.Y));
1893 c.KeyStatus["HotbarMinus"].Add(string.Concat(Buttons.LeftTrigger));
1894 c.KeyStatus["HotbarPlus"].Add(string.Concat(Buttons.RightTrigger));
1895 c.KeyStatus["Grapple"].Add(string.Concat(Buttons.X));
1896 c.KeyStatus["MapFull"].Add(string.Concat(Buttons.Start));
1897 c.KeyStatus["SmartSelect"].Add(string.Concat(Buttons.Back));
1898 c.KeyStatus["QuickMount"].Add(string.Concat(Buttons.RightStick));
1899 c.KeyStatus["DpadSnap1"].Add(string.Concat(Buttons.DPadUp));
1900 c.KeyStatus["DpadSnap3"].Add(string.Concat(Buttons.DPadDown));
1901 c.KeyStatus["DpadSnap4"].Add(string.Concat(Buttons.DPadLeft));
1902 c.KeyStatus["DpadSnap2"].Add(string.Concat(Buttons.DPadRight));
1903 c.KeyStatus["MenuUp"].Add(string.Concat(Buttons.DPadUp));
1904 c.KeyStatus["MenuDown"].Add(string.Concat(Buttons.DPadDown));
1905 c.KeyStatus["MenuLeft"].Add(string.Concat(Buttons.DPadLeft));
1906 c.KeyStatus["MenuRight"].Add(string.Concat(Buttons.DPadRight));
1907 break;
1908 case InputMode.Mouse:
1909 break;
1910 }
1911 break;
1912 case PresetProfiles.Yoraiz0r:
1913 switch (mode)
1914 {
1915 case InputMode.Keyboard:
1916 c.KeyStatus["MouseLeft"].Add("Mouse1");
1917 c.KeyStatus["MouseRight"].Add("Mouse2");
1918 c.KeyStatus["Up"].Add("W");
1919 c.KeyStatus["Down"].Add("S");
1920 c.KeyStatus["Left"].Add("A");
1921 c.KeyStatus["Right"].Add("D");
1922 c.KeyStatus["Jump"].Add("Space");
1923 c.KeyStatus["Inventory"].Add("Escape");
1924 c.KeyStatus["Grapple"].Add("E");
1925 c.KeyStatus["SmartSelect"].Add("LeftShift");
1926 c.KeyStatus["SmartCursor"].Add("LeftControl");
1927 c.KeyStatus["QuickMount"].Add("R");
1928 c.KeyStatus["QuickHeal"].Add("H");
1929 c.KeyStatus["QuickMana"].Add("J");
1930 c.KeyStatus["QuickBuff"].Add("B");
1931 c.KeyStatus["MapStyle"].Add("Tab");
1932 c.KeyStatus["MapFull"].Add("M");
1933 c.KeyStatus["MapZoomIn"].Add("Add");
1934 c.KeyStatus["MapZoomOut"].Add("Subtract");
1935 c.KeyStatus["MapAlphaUp"].Add("PageUp");
1936 c.KeyStatus["MapAlphaDown"].Add("PageDown");
1937 c.KeyStatus["Hotbar1"].Add("D1");
1938 c.KeyStatus["Hotbar2"].Add("D2");
1939 c.KeyStatus["Hotbar3"].Add("D3");
1940 c.KeyStatus["Hotbar4"].Add("D4");
1941 c.KeyStatus["Hotbar5"].Add("D5");
1942 c.KeyStatus["Hotbar6"].Add("D6");
1943 c.KeyStatus["Hotbar7"].Add("D7");
1944 c.KeyStatus["Hotbar8"].Add("D8");
1945 c.KeyStatus["Hotbar9"].Add("D9");
1946 c.KeyStatus["Hotbar10"].Add("D0");
1947 c.KeyStatus["ViewZoomOut"].Add("OemMinus");
1948 c.KeyStatus["ViewZoomIn"].Add("OemPlus");
1949 c.KeyStatus["ToggleCreativeMenu"].Add("C");
1950 c.KeyStatus["Loadout1"].Add("F1");
1951 c.KeyStatus["Loadout2"].Add("F2");
1952 c.KeyStatus["Loadout3"].Add("F3");
1953 c.KeyStatus["ToggleCameraMode"].Add("F4");
1954 break;
1955 case InputMode.KeyboardUI:
1956 c.KeyStatus["MouseLeft"].Add("Mouse1");
1957 c.KeyStatus["MouseLeft"].Add("Space");
1958 c.KeyStatus["MouseRight"].Add("Mouse2");
1959 c.KeyStatus["Up"].Add("W");
1960 c.KeyStatus["Up"].Add("Up");
1961 c.KeyStatus["Down"].Add("S");
1962 c.KeyStatus["Down"].Add("Down");
1963 c.KeyStatus["Left"].Add("A");
1964 c.KeyStatus["Left"].Add("Left");
1965 c.KeyStatus["Right"].Add("D");
1966 c.KeyStatus["Right"].Add("Right");
1967 c.KeyStatus["Inventory"].Add(Keys.Escape.ToString());
1968 c.KeyStatus["MenuUp"].Add(string.Concat(Buttons.DPadUp));
1969 c.KeyStatus["MenuDown"].Add(string.Concat(Buttons.DPadDown));
1970 c.KeyStatus["MenuLeft"].Add(string.Concat(Buttons.DPadLeft));
1971 c.KeyStatus["MenuRight"].Add(string.Concat(Buttons.DPadRight));
1972 break;
1973 case InputMode.XBoxGamepad:
1974 c.KeyStatus["MouseLeft"].Add(string.Concat(Buttons.RightTrigger));
1975 c.KeyStatus["MouseRight"].Add(string.Concat(Buttons.B));
1976 c.KeyStatus["Up"].Add(string.Concat(Buttons.LeftThumbstickUp));
1977 c.KeyStatus["Down"].Add(string.Concat(Buttons.LeftThumbstickDown));
1978 c.KeyStatus["Left"].Add(string.Concat(Buttons.LeftThumbstickLeft));
1979 c.KeyStatus["Right"].Add(string.Concat(Buttons.LeftThumbstickRight));
1980 c.KeyStatus["Jump"].Add(string.Concat(Buttons.LeftTrigger));
1981 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.Y));
1982 c.KeyStatus["Grapple"].Add(string.Concat(Buttons.LeftShoulder));
1983 c.KeyStatus["SmartSelect"].Add(string.Concat(Buttons.LeftStick));
1984 c.KeyStatus["SmartCursor"].Add(string.Concat(Buttons.RightStick));
1985 c.KeyStatus["QuickMount"].Add(string.Concat(Buttons.X));
1986 c.KeyStatus["QuickHeal"].Add(string.Concat(Buttons.A));
1987 c.KeyStatus["RadialHotbar"].Add(string.Concat(Buttons.RightShoulder));
1988 c.KeyStatus["MapFull"].Add(string.Concat(Buttons.Start));
1989 c.KeyStatus["DpadSnap1"].Add(string.Concat(Buttons.DPadUp));
1990 c.KeyStatus["DpadSnap3"].Add(string.Concat(Buttons.DPadDown));
1991 c.KeyStatus["DpadSnap4"].Add(string.Concat(Buttons.DPadLeft));
1992 c.KeyStatus["DpadSnap2"].Add(string.Concat(Buttons.DPadRight));
1993 c.KeyStatus["MapStyle"].Add(string.Concat(Buttons.Back));
1994 break;
1995 case InputMode.XBoxGamepadUI:
1996 c.KeyStatus["MouseLeft"].Add(string.Concat(Buttons.A));
1997 c.KeyStatus["MouseRight"].Add(string.Concat(Buttons.LeftShoulder));
1998 c.KeyStatus["SmartCursor"].Add(string.Concat(Buttons.RightShoulder));
1999 c.KeyStatus["Up"].Add(string.Concat(Buttons.LeftThumbstickUp));
2000 c.KeyStatus["Down"].Add(string.Concat(Buttons.LeftThumbstickDown));
2001 c.KeyStatus["Left"].Add(string.Concat(Buttons.LeftThumbstickLeft));
2002 c.KeyStatus["Right"].Add(string.Concat(Buttons.LeftThumbstickRight));
2003 c.KeyStatus["LockOn"].Add(string.Concat(Buttons.B));
2004 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.Y));
2005 c.KeyStatus["HotbarMinus"].Add(string.Concat(Buttons.LeftTrigger));
2006 c.KeyStatus["HotbarPlus"].Add(string.Concat(Buttons.RightTrigger));
2007 c.KeyStatus["Grapple"].Add(string.Concat(Buttons.X));
2008 c.KeyStatus["MapFull"].Add(string.Concat(Buttons.Start));
2009 c.KeyStatus["SmartSelect"].Add(string.Concat(Buttons.Back));
2010 c.KeyStatus["QuickMount"].Add(string.Concat(Buttons.RightStick));
2011 c.KeyStatus["DpadSnap1"].Add(string.Concat(Buttons.DPadUp));
2012 c.KeyStatus["DpadSnap3"].Add(string.Concat(Buttons.DPadDown));
2013 c.KeyStatus["DpadSnap4"].Add(string.Concat(Buttons.DPadLeft));
2014 c.KeyStatus["DpadSnap2"].Add(string.Concat(Buttons.DPadRight));
2015 c.KeyStatus["MenuUp"].Add(string.Concat(Buttons.DPadUp));
2016 c.KeyStatus["MenuDown"].Add(string.Concat(Buttons.DPadDown));
2017 c.KeyStatus["MenuLeft"].Add(string.Concat(Buttons.DPadLeft));
2018 c.KeyStatus["MenuRight"].Add(string.Concat(Buttons.DPadRight));
2019 break;
2020 case InputMode.Mouse:
2021 break;
2022 }
2023 break;
2024 case PresetProfiles.ConsolePS:
2025 switch (mode)
2026 {
2027 case InputMode.Keyboard:
2028 c.KeyStatus["MouseLeft"].Add("Mouse1");
2029 c.KeyStatus["MouseRight"].Add("Mouse2");
2030 c.KeyStatus["Up"].Add("W");
2031 c.KeyStatus["Down"].Add("S");
2032 c.KeyStatus["Left"].Add("A");
2033 c.KeyStatus["Right"].Add("D");
2034 c.KeyStatus["Jump"].Add("Space");
2035 c.KeyStatus["Inventory"].Add("Escape");
2036 c.KeyStatus["Grapple"].Add("E");
2037 c.KeyStatus["SmartSelect"].Add("LeftShift");
2038 c.KeyStatus["SmartCursor"].Add("LeftControl");
2039 c.KeyStatus["QuickMount"].Add("R");
2040 c.KeyStatus["QuickHeal"].Add("H");
2041 c.KeyStatus["QuickMana"].Add("J");
2042 c.KeyStatus["QuickBuff"].Add("B");
2043 c.KeyStatus["MapStyle"].Add("Tab");
2044 c.KeyStatus["MapFull"].Add("M");
2045 c.KeyStatus["MapZoomIn"].Add("Add");
2046 c.KeyStatus["MapZoomOut"].Add("Subtract");
2047 c.KeyStatus["MapAlphaUp"].Add("PageUp");
2048 c.KeyStatus["MapAlphaDown"].Add("PageDown");
2049 c.KeyStatus["Hotbar1"].Add("D1");
2050 c.KeyStatus["Hotbar2"].Add("D2");
2051 c.KeyStatus["Hotbar3"].Add("D3");
2052 c.KeyStatus["Hotbar4"].Add("D4");
2053 c.KeyStatus["Hotbar5"].Add("D5");
2054 c.KeyStatus["Hotbar6"].Add("D6");
2055 c.KeyStatus["Hotbar7"].Add("D7");
2056 c.KeyStatus["Hotbar8"].Add("D8");
2057 c.KeyStatus["Hotbar9"].Add("D9");
2058 c.KeyStatus["Hotbar10"].Add("D0");
2059 c.KeyStatus["ViewZoomOut"].Add("OemMinus");
2060 c.KeyStatus["ViewZoomIn"].Add("OemPlus");
2061 c.KeyStatus["ToggleCreativeMenu"].Add("C");
2062 c.KeyStatus["Loadout1"].Add("F1");
2063 c.KeyStatus["Loadout2"].Add("F2");
2064 c.KeyStatus["Loadout3"].Add("F3");
2065 c.KeyStatus["ToggleCameraMode"].Add("F4");
2066 break;
2067 case InputMode.KeyboardUI:
2068 c.KeyStatus["MouseLeft"].Add("Mouse1");
2069 c.KeyStatus["MouseLeft"].Add("Space");
2070 c.KeyStatus["MouseRight"].Add("Mouse2");
2071 c.KeyStatus["Up"].Add("W");
2072 c.KeyStatus["Up"].Add("Up");
2073 c.KeyStatus["Down"].Add("S");
2074 c.KeyStatus["Down"].Add("Down");
2075 c.KeyStatus["Left"].Add("A");
2076 c.KeyStatus["Left"].Add("Left");
2077 c.KeyStatus["Right"].Add("D");
2078 c.KeyStatus["Right"].Add("Right");
2079 c.KeyStatus["MenuUp"].Add(string.Concat(Buttons.DPadUp));
2080 c.KeyStatus["MenuDown"].Add(string.Concat(Buttons.DPadDown));
2081 c.KeyStatus["MenuLeft"].Add(string.Concat(Buttons.DPadLeft));
2082 c.KeyStatus["MenuRight"].Add(string.Concat(Buttons.DPadRight));
2083 c.KeyStatus["Inventory"].Add(Keys.Escape.ToString());
2084 break;
2085 case InputMode.XBoxGamepad:
2086 c.KeyStatus["MouseLeft"].Add(string.Concat(Buttons.RightShoulder));
2087 c.KeyStatus["MouseRight"].Add(string.Concat(Buttons.B));
2088 c.KeyStatus["Up"].Add(string.Concat(Buttons.LeftThumbstickUp));
2089 c.KeyStatus["Down"].Add(string.Concat(Buttons.LeftThumbstickDown));
2090 c.KeyStatus["Left"].Add(string.Concat(Buttons.LeftThumbstickLeft));
2091 c.KeyStatus["Right"].Add(string.Concat(Buttons.LeftThumbstickRight));
2092 c.KeyStatus["Jump"].Add(string.Concat(Buttons.A));
2093 c.KeyStatus["LockOn"].Add(string.Concat(Buttons.X));
2094 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.Y));
2095 c.KeyStatus["Grapple"].Add(string.Concat(Buttons.LeftShoulder));
2096 c.KeyStatus["SmartSelect"].Add(string.Concat(Buttons.LeftStick));
2097 c.KeyStatus["SmartCursor"].Add(string.Concat(Buttons.RightStick));
2098 c.KeyStatus["HotbarMinus"].Add(string.Concat(Buttons.LeftTrigger));
2099 c.KeyStatus["HotbarPlus"].Add(string.Concat(Buttons.RightTrigger));
2100 c.KeyStatus["MapFull"].Add(string.Concat(Buttons.Start));
2101 c.KeyStatus["DpadRadial1"].Add(string.Concat(Buttons.DPadUp));
2102 c.KeyStatus["DpadRadial3"].Add(string.Concat(Buttons.DPadDown));
2103 c.KeyStatus["DpadRadial4"].Add(string.Concat(Buttons.DPadLeft));
2104 c.KeyStatus["DpadRadial2"].Add(string.Concat(Buttons.DPadRight));
2105 c.KeyStatus["QuickMount"].Add(string.Concat(Buttons.Back));
2106 break;
2107 case InputMode.XBoxGamepadUI:
2108 c.KeyStatus["MouseLeft"].Add(string.Concat(Buttons.A));
2109 c.KeyStatus["MouseRight"].Add(string.Concat(Buttons.LeftShoulder));
2110 c.KeyStatus["SmartCursor"].Add(string.Concat(Buttons.RightShoulder));
2111 c.KeyStatus["Up"].Add(string.Concat(Buttons.LeftThumbstickUp));
2112 c.KeyStatus["Down"].Add(string.Concat(Buttons.LeftThumbstickDown));
2113 c.KeyStatus["Left"].Add(string.Concat(Buttons.LeftThumbstickLeft));
2114 c.KeyStatus["Right"].Add(string.Concat(Buttons.LeftThumbstickRight));
2115 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.B));
2116 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.Y));
2117 c.KeyStatus["HotbarMinus"].Add(string.Concat(Buttons.LeftTrigger));
2118 c.KeyStatus["HotbarPlus"].Add(string.Concat(Buttons.RightTrigger));
2119 c.KeyStatus["Grapple"].Add(string.Concat(Buttons.X));
2120 c.KeyStatus["MapFull"].Add(string.Concat(Buttons.Start));
2121 c.KeyStatus["SmartSelect"].Add(string.Concat(Buttons.Back));
2122 c.KeyStatus["QuickMount"].Add(string.Concat(Buttons.RightStick));
2123 c.KeyStatus["DpadRadial1"].Add(string.Concat(Buttons.DPadUp));
2124 c.KeyStatus["DpadRadial3"].Add(string.Concat(Buttons.DPadDown));
2125 c.KeyStatus["DpadRadial4"].Add(string.Concat(Buttons.DPadLeft));
2126 c.KeyStatus["DpadRadial2"].Add(string.Concat(Buttons.DPadRight));
2127 c.KeyStatus["MenuUp"].Add(string.Concat(Buttons.DPadUp));
2128 c.KeyStatus["MenuDown"].Add(string.Concat(Buttons.DPadDown));
2129 c.KeyStatus["MenuLeft"].Add(string.Concat(Buttons.DPadLeft));
2130 c.KeyStatus["MenuRight"].Add(string.Concat(Buttons.DPadRight));
2131 break;
2132 case InputMode.Mouse:
2133 break;
2134 }
2135 break;
2136 case PresetProfiles.ConsoleXBox:
2137 switch (mode)
2138 {
2139 case InputMode.Keyboard:
2140 c.KeyStatus["MouseLeft"].Add("Mouse1");
2141 c.KeyStatus["MouseRight"].Add("Mouse2");
2142 c.KeyStatus["Up"].Add("W");
2143 c.KeyStatus["Down"].Add("S");
2144 c.KeyStatus["Left"].Add("A");
2145 c.KeyStatus["Right"].Add("D");
2146 c.KeyStatus["Jump"].Add("Space");
2147 c.KeyStatus["Inventory"].Add("Escape");
2148 c.KeyStatus["Grapple"].Add("E");
2149 c.KeyStatus["SmartSelect"].Add("LeftShift");
2150 c.KeyStatus["SmartCursor"].Add("LeftControl");
2151 c.KeyStatus["QuickMount"].Add("R");
2152 c.KeyStatus["QuickHeal"].Add("H");
2153 c.KeyStatus["QuickMana"].Add("J");
2154 c.KeyStatus["QuickBuff"].Add("B");
2155 c.KeyStatus["MapStyle"].Add("Tab");
2156 c.KeyStatus["MapFull"].Add("M");
2157 c.KeyStatus["MapZoomIn"].Add("Add");
2158 c.KeyStatus["MapZoomOut"].Add("Subtract");
2159 c.KeyStatus["MapAlphaUp"].Add("PageUp");
2160 c.KeyStatus["MapAlphaDown"].Add("PageDown");
2161 c.KeyStatus["Hotbar1"].Add("D1");
2162 c.KeyStatus["Hotbar2"].Add("D2");
2163 c.KeyStatus["Hotbar3"].Add("D3");
2164 c.KeyStatus["Hotbar4"].Add("D4");
2165 c.KeyStatus["Hotbar5"].Add("D5");
2166 c.KeyStatus["Hotbar6"].Add("D6");
2167 c.KeyStatus["Hotbar7"].Add("D7");
2168 c.KeyStatus["Hotbar8"].Add("D8");
2169 c.KeyStatus["Hotbar9"].Add("D9");
2170 c.KeyStatus["Hotbar10"].Add("D0");
2171 c.KeyStatus["ViewZoomOut"].Add("OemMinus");
2172 c.KeyStatus["ViewZoomIn"].Add("OemPlus");
2173 c.KeyStatus["ToggleCreativeMenu"].Add("C");
2174 c.KeyStatus["Loadout1"].Add("F1");
2175 c.KeyStatus["Loadout2"].Add("F2");
2176 c.KeyStatus["Loadout3"].Add("F3");
2177 c.KeyStatus["ToggleCameraMode"].Add("F4");
2178 break;
2179 case InputMode.KeyboardUI:
2180 c.KeyStatus["MouseLeft"].Add("Mouse1");
2181 c.KeyStatus["MouseLeft"].Add("Space");
2182 c.KeyStatus["MouseRight"].Add("Mouse2");
2183 c.KeyStatus["Up"].Add("W");
2184 c.KeyStatus["Up"].Add("Up");
2185 c.KeyStatus["Down"].Add("S");
2186 c.KeyStatus["Down"].Add("Down");
2187 c.KeyStatus["Left"].Add("A");
2188 c.KeyStatus["Left"].Add("Left");
2189 c.KeyStatus["Right"].Add("D");
2190 c.KeyStatus["Right"].Add("Right");
2191 c.KeyStatus["MenuUp"].Add(string.Concat(Buttons.DPadUp));
2192 c.KeyStatus["MenuDown"].Add(string.Concat(Buttons.DPadDown));
2193 c.KeyStatus["MenuLeft"].Add(string.Concat(Buttons.DPadLeft));
2194 c.KeyStatus["MenuRight"].Add(string.Concat(Buttons.DPadRight));
2195 c.KeyStatus["Inventory"].Add(Keys.Escape.ToString());
2196 break;
2197 case InputMode.XBoxGamepad:
2198 c.KeyStatus["MouseLeft"].Add(string.Concat(Buttons.RightTrigger));
2199 c.KeyStatus["MouseRight"].Add(string.Concat(Buttons.B));
2200 c.KeyStatus["Up"].Add(string.Concat(Buttons.LeftThumbstickUp));
2201 c.KeyStatus["Down"].Add(string.Concat(Buttons.LeftThumbstickDown));
2202 c.KeyStatus["Left"].Add(string.Concat(Buttons.LeftThumbstickLeft));
2203 c.KeyStatus["Right"].Add(string.Concat(Buttons.LeftThumbstickRight));
2204 c.KeyStatus["Jump"].Add(string.Concat(Buttons.A));
2205 c.KeyStatus["LockOn"].Add(string.Concat(Buttons.X));
2206 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.Y));
2207 c.KeyStatus["Grapple"].Add(string.Concat(Buttons.LeftTrigger));
2208 c.KeyStatus["SmartSelect"].Add(string.Concat(Buttons.LeftStick));
2209 c.KeyStatus["SmartCursor"].Add(string.Concat(Buttons.RightStick));
2210 c.KeyStatus["HotbarMinus"].Add(string.Concat(Buttons.LeftShoulder));
2211 c.KeyStatus["HotbarPlus"].Add(string.Concat(Buttons.RightShoulder));
2212 c.KeyStatus["MapFull"].Add(string.Concat(Buttons.Start));
2213 c.KeyStatus["DpadRadial1"].Add(string.Concat(Buttons.DPadUp));
2214 c.KeyStatus["DpadRadial3"].Add(string.Concat(Buttons.DPadDown));
2215 c.KeyStatus["DpadRadial4"].Add(string.Concat(Buttons.DPadLeft));
2216 c.KeyStatus["DpadRadial2"].Add(string.Concat(Buttons.DPadRight));
2217 c.KeyStatus["QuickMount"].Add(string.Concat(Buttons.Back));
2218 break;
2219 case InputMode.XBoxGamepadUI:
2220 c.KeyStatus["MouseLeft"].Add(string.Concat(Buttons.A));
2221 c.KeyStatus["MouseRight"].Add(string.Concat(Buttons.LeftShoulder));
2222 c.KeyStatus["SmartCursor"].Add(string.Concat(Buttons.RightShoulder));
2223 c.KeyStatus["Up"].Add(string.Concat(Buttons.LeftThumbstickUp));
2224 c.KeyStatus["Down"].Add(string.Concat(Buttons.LeftThumbstickDown));
2225 c.KeyStatus["Left"].Add(string.Concat(Buttons.LeftThumbstickLeft));
2226 c.KeyStatus["Right"].Add(string.Concat(Buttons.LeftThumbstickRight));
2227 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.B));
2228 c.KeyStatus["Inventory"].Add(string.Concat(Buttons.Y));
2229 c.KeyStatus["HotbarMinus"].Add(string.Concat(Buttons.LeftTrigger));
2230 c.KeyStatus["HotbarPlus"].Add(string.Concat(Buttons.RightTrigger));
2231 c.KeyStatus["Grapple"].Add(string.Concat(Buttons.X));
2232 c.KeyStatus["MapFull"].Add(string.Concat(Buttons.Start));
2233 c.KeyStatus["SmartSelect"].Add(string.Concat(Buttons.Back));
2234 c.KeyStatus["QuickMount"].Add(string.Concat(Buttons.RightStick));
2235 c.KeyStatus["DpadRadial1"].Add(string.Concat(Buttons.DPadUp));
2236 c.KeyStatus["DpadRadial3"].Add(string.Concat(Buttons.DPadDown));
2237 c.KeyStatus["DpadRadial4"].Add(string.Concat(Buttons.DPadLeft));
2238 c.KeyStatus["DpadRadial2"].Add(string.Concat(Buttons.DPadRight));
2239 c.KeyStatus["MenuUp"].Add(string.Concat(Buttons.DPadUp));
2240 c.KeyStatus["MenuDown"].Add(string.Concat(Buttons.DPadDown));
2241 c.KeyStatus["MenuLeft"].Add(string.Concat(Buttons.DPadLeft));
2242 c.KeyStatus["MenuRight"].Add(string.Concat(Buttons.DPadRight));
2243 break;
2244 case InputMode.Mouse:
2245 break;
2246 }
2247 break;
2248 }
2249 }
2250
2251 public static void SetZoom_UI()
2252 {
2253 float uIScale = Main.UIScale;
2254 SetZoom_Scaled(1f / uIScale);
2255 }
2256
2257 public static void SetZoom_World()
2258 {
2259 SetZoom_Scaled(1f);
2261 }
2262
2263 public static void SetZoom_Unscaled()
2264 {
2265 Main.lastMouseX = _originalLastMouseX;
2266 Main.lastMouseY = _originalLastMouseY;
2267 Main.mouseX = _originalMouseX;
2268 Main.mouseY = _originalMouseY;
2269 Main.screenWidth = _originalScreenWidth;
2270 Main.screenHeight = _originalScreenHeight;
2271 }
2272
2273 public static void SetZoom_Test()
2274 {
2275 Vector2 vector = Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) / 2f;
2276 Vector2 vector2 = Main.screenPosition + new Vector2(_originalMouseX, _originalMouseY);
2277 Vector2 vector3 = Main.screenPosition + new Vector2(_originalLastMouseX, _originalLastMouseY);
2278 Vector2 vector4 = Main.screenPosition + new Vector2(0f, 0f);
2279 Vector2 vector5 = Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight);
2283 _ = vector5 - vector;
2284 float num = 1f / Main.GameViewMatrix.Zoom.X;
2285 float num2 = 1f;
2286 Vector2 vector9 = vector - Main.screenPosition + vector6 * num;
2287 Vector2 vector10 = vector - Main.screenPosition + vector7 * num;
2288 Vector2 screenPosition = vector + vector8 * num2;
2289 Main.mouseX = (int)vector9.X;
2290 Main.mouseY = (int)vector9.Y;
2291 Main.lastMouseX = (int)vector10.X;
2292 Main.lastMouseY = (int)vector10.Y;
2293 Main.screenPosition = screenPosition;
2294 Main.screenWidth = (int)((float)_originalScreenWidth * num2);
2295 Main.screenHeight = (int)((float)_originalScreenHeight * num2);
2296 }
2297
2298 public static void SetZoom_MouseInWorld()
2299 {
2300 Vector2 vector = Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) / 2f;
2301 Vector2 vector2 = Main.screenPosition + new Vector2(_originalMouseX, _originalMouseY);
2302 Vector2 vector3 = Main.screenPosition + new Vector2(_originalLastMouseX, _originalLastMouseY);
2305 float num = 1f / Main.GameViewMatrix.Zoom.X;
2306 Vector2 vector6 = vector - Main.screenPosition + vector4 * num;
2307 Main.mouseX = (int)vector6.X;
2308 Main.mouseY = (int)vector6.Y;
2309 Vector2 vector7 = vector - Main.screenPosition + vector5 * num;
2310 Main.lastMouseX = (int)vector7.X;
2311 Main.lastMouseY = (int)vector7.Y;
2312 }
2313
2314 public static void SetDesiredZoomContext(ZoomContext context)
2315 {
2316 _currentWantedZoom = context;
2317 }
2318
2319 public static void SetZoom_Context()
2320 {
2321 switch (_currentWantedZoom)
2322 {
2323 case ZoomContext.Unscaled:
2326 break;
2327 case ZoomContext.Unscaled_MouseInWorld:
2331 break;
2332 case ZoomContext.UI:
2333 SetZoom_UI();
2335 break;
2336 case ZoomContext.World:
2337 SetZoom_World();
2339 break;
2340 }
2341 }
2342
2343 private static void SetZoom_Scaled(float scale)
2344 {
2345 Main.lastMouseX = (int)((float)_originalLastMouseX * scale);
2346 Main.lastMouseY = (int)((float)_originalLastMouseY * scale);
2347 Main.mouseX = (int)((float)_originalMouseX * scale);
2348 Main.mouseY = (int)((float)_originalMouseY * scale);
2349 Main.screenWidth = (int)((float)_originalScreenWidth * scale);
2350 Main.screenHeight = (int)((float)_originalScreenHeight * scale);
2351 }
2352}
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static Array GetValues(Type enumType)
Definition Enum.cs:323
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 Center
Definition Entity.cs:43
Vector2 velocity
Definition Entity.cs:16
Dictionary< string, List< string > > KeyStatus
static void SetCursorMode(CursorMode cursorMode)
static string GenerateInputTag_ForCurrentGamemode(bool tagForGameplay, string triggerName)
static string GenerateInputTags_Gamepad(string triggerName)
static List< string > _buttonsLocked
static FastUseItemMemory _fastUseMemory
static MouseState MouseInfoOld
static Buttons[] ButtonsGamepad
static string GenerateGlyphList(List< string > list)
static void TryEnteringFastUseModeForMouseItem()
static void DebugKeys(List< Keys > keys)
static void PrettyPrintProfiles(ref string text)
static TriggersPack Triggers
static void TryEnteringFastUseModeForInventorySlot(int inventorySlot)
static void CacheOriginalScreenDimensions()
static void PrettyPrintProfilesOld(ref string text)
static bool PreventFirstMousePositionGrab
static bool IsGamepadButtonLockedFromUse(string keyName)
static void SetSelectedProfile(string name)
static void FixKeysConflict(InputMode inputMode, List< string > triggers)
static bool CheckRebindingProcessKeyboard(string newKey)
static List< Keys > GetPressedKeys()
static List< string > MouseKeys
static void Reset(KeyConfiguration c, PresetProfiles style, InputMode mode)
static PlayerInputProfile _currentProfile
static bool PreventCursorModeSwappingToGamepad
static InputMode _listeningInputMode
static string GenerateInputTag_ForCurrentGamemode_WithHacks(bool tagForGameplay, string triggerName)
static InputMode CurrentInputMode
static string BuildCommand(string CommandText, bool Last, params List< string >[] Bindings)
static Vector2 GamepadThumbstickLeft
static void CacheMousePositionForZoom()
static SmartSelectGamepadPointer smartSelectPointer
static PlayerInputProfile CurrentProfile
static void Hook_OnEnterWorld(Player player)
static Dictionary< string, PlayerInputProfile > OriginalProfiles
static void ResetInputsOnActiveStateChange()
static void SetZoom_Scaled(float scale)
static string GenerateRawInputList(List< string > list)
static void ResetKeyBinding(InputMode inputMode, string trigger)
static void LockGamepadButtons(string TriggerName)
static bool AllowExecutionOfGamepadInstructions
static ZoomContext _currentWantedZoom
static void SetDesiredZoomContext(ZoomContext context)
static bool ShouldShowInstructionsForGamepad()
static Vector2 GamepadThumbstickRight
static string ComposeInstructionsForGamepad()
static KeyConfiguration ProfileGamepadUI
static List< string > KnownTriggers
static void ListenFor(string triggerName, InputMode inputmode)
static string GenerateInputTags_GamepadUI(string triggerName)
static bool CheckRebindingProcessGamepad(string newKey)
static bool[] Yoyo
Definition ItemID.cs:1086
static int[] GamepadExtraRange
Definition ItemID.cs:1078
static bool[] GamepadWholeScreenUseRange
Definition ItemID.cs:1080
static bool[] TileInteractRead
Definition TileID.cs:185
bool mech
Definition Item.cs:81
int tileWand
Definition Item.cs:89
int createWall
Definition Item.cs:163
int createTile
Definition Item.cs:161
bool IsAir
Definition Item.cs:377
int useTime
Definition Item.cs:147
static LocalizedText[] inter
Definition Lang.cs:28
static LocalizedText[] menu
Definition Lang.cs:19
static LocalizedText[] misc
Definition Lang.cs:25
static bool HasSmartInteractTarget
Definition Main.cs:2858
static float mapFullscreenScale
Definition Main.cs:936
static bool ingameOptionsWindow
Definition Main.cs:704
static bool InvisibleCursorForGamepad
Definition Main.cs:267
static UserInterface InGameUI
Definition Main.cs:383
static bool SmartInteractShowingGenuine
Definition Main.cs:2155
static void SetRecommendedZoomContext(Matrix matrix)
Definition Main.cs:2964
static bool SettingBlockGamepadsEntirely
Definition Main.cs:249
static int myPlayer
Definition Main.cs:1801
static Vector2 ReverseGravitySupport(Vector2 pos, float height=0f)
Definition Main.cs:3005
static int netMode
Definition Main.cs:2095
static bool SmartInteractShowingFake
Definition Main.cs:2157
static bool mouseRight
Definition Main.cs:616
static string blockKey
Definition Main.cs:1821
static float UIScale
Definition Main.cs:2624
static int lastMouseY
Definition Main.cs:610
static Main instance
Definition Main.cs:283
static int screenHeight
Definition Main.cs:1721
static Vector2 screenPosition
Definition Main.cs:1715
static int SmartInteractNPC
Definition Main.cs:2163
static Vector2 MouseScreen
Definition Main.cs:2773
static bool HasInteractibleObjectThatIsNotATile
Definition Main.cs:1998
static Item mouseItem
Definition Main.cs:1773
static Matrix UIScaleMatrix
Definition Main.cs:2619
static SpriteViewMatrix GameViewMatrix
Definition Main.cs:227
static Tile[,] tile
Definition Main.cs:1675
static KeyboardState oldKeyState
Definition Main.cs:990
static int lastMouseX
Definition Main.cs:608
static KeyboardState keyState
Definition Main.cs:988
static ChromaHotkeyPainter ChromaPainter
Definition Main.cs:287
static float GamepadCursorAlpha
Definition Main.cs:2527
static int SmartInteractY
Definition Main.cs:2161
static bool playerInventory
Definition Main.cs:1759
static bool SmartCursorIsUsed
Definition Main.cs:2855
static int screenWidth
Definition Main.cs:1719
static int SmartInteractX
Definition Main.cs:2159
static int mouseY
Definition Main.cs:606
static bool gameMenu
Definition Main.cs:1926
static Preferences Configuration
Definition Main.cs:1956
static Player LocalPlayer
Definition Main.cs:2829
static bool mapFullscreen
Definition Main.cs:932
static bool AllowUnfocusedInputOnGamepad
Definition Main.cs:265
static bool SmartCursorWanted
Definition Main.cs:2840
static Preferences InputProfiles
Definition Main.cs:1958
static Player[] player
Definition Main.cs:1803
static int mouseX
Definition Main.cs:604
static void SetCameraGamepadLerp(float lerp)
Definition Main.cs:2999
bool Active
Definition Mount.cs:345
bool controlTorch
Definition Player.cs:1401
static int tileRangeX
Definition Player.cs:2075
bool yoyoString
Definition Player.cs:671
static int tileRangeY
Definition Player.cs:2077
Item[] inventory
Definition Player.cs:1257
static SocialMode Mode
Definition SocialAPI.cs:32
ushort type
Definition Tile.cs:8
static float CircularRadialOpacity
Definition ItemSlot.cs:157
static void PickupItemIntoMouse(Item[] inv, int context, int slot, Player player)
Definition ItemSlot.cs:1425
static bool IsABuildingItem(Item item)
Definition ItemSlot.cs:3617
static Matrix Invert(Matrix matrix)
Definition Matrix.cs:1694
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121
static Vector2 Transform(Vector2 position, Matrix matrix)
Definition Vector2.cs:317
bool TryStartForItemSlot(Player player, int itemSlot)