Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIManageControls.cs
Go to the documentation of this file.
1using System;
3using System.Linq;
6using Microsoft.Xna.Framework.Input;
11using Terraria.ID;
14using Terraria.UI;
16
18
20{
21 public static int ForceMoveTo = -1;
22
23 private const float PanelTextureHeight = 30f;
24
26 {
27 "Throw", "Inventory", "RadialHotbar", "RadialQuickbar", "LockOn", "ToggleCreativeMenu", "Loadout1", "Loadout2", "Loadout3", "ToggleCameraMode",
28 "sp3", "sp4", "sp5", "sp6", "sp7", "sp8", "sp18", "sp19", "sp9", "sp10",
29 "sp11", "sp12", "sp13"
30 };
31
32 private static List<string> _BindingsHalfSingleLine = new List<string> { "sp9", "sp10", "sp11", "sp12", "sp13" };
33
34 private bool OnKeyboard = true;
35
36 private bool OnGameplay = true;
37
39
41
43
45
47
48 private UIList _uilist;
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
78 private static int SnapPointIndex;
79
80 public override void OnInitialize()
81 {
82 _KeyboardGamepadTexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Inputs", (AssetRequestMode)1);
83 _keyboardGamepadBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Inputs_Border", (AssetRequestMode)1);
84 _GameplayVsUITexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Inputs_2", (AssetRequestMode)1);
85 _GameplayVsUIBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Inputs_2_Border", (AssetRequestMode)1);
87 uIElement.Width.Set(0f, 0.8f);
88 uIElement.MaxWidth.Set(600f, 0f);
89 uIElement.Top.Set(220f, 0f);
90 uIElement.Height.Set(-200f, 1f);
91 uIElement.HAlign = 0.5f;
93 UIPanel uIPanel = new UIPanel();
94 uIPanel.Width.Set(0f, 1f);
95 uIPanel.Height.Set(-110f, 1f);
96 uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
97 uIElement.Append(uIPanel);
99 _buttonKeyboard.VAlign = 0f;
100 _buttonKeyboard.HAlign = 0f;
101 _buttonKeyboard.Left.Set(0f, 0f);
102 _buttonKeyboard.Top.Set(8f, 0f);
103 _buttonKeyboard.OnLeftClick += KeyboardButtonClick;
104 _buttonKeyboard.OnMouseOver += ManageBorderKeyboardOn;
105 _buttonKeyboard.OnMouseOut += ManageBorderKeyboardOff;
106 uIPanel.Append(_buttonKeyboard);
108 _buttonGamepad.VAlign = 0f;
109 _buttonGamepad.HAlign = 0f;
110 _buttonGamepad.Left.Set(76f, 0f);
111 _buttonGamepad.Top.Set(8f, 0f);
112 _buttonGamepad.OnLeftClick += GamepadButtonClick;
113 _buttonGamepad.OnMouseOver += ManageBorderGamepadOn;
114 _buttonGamepad.OnMouseOut += ManageBorderGamepadOff;
115 uIPanel.Append(_buttonGamepad);
117 _buttonBorder1.VAlign = 0f;
118 _buttonBorder1.HAlign = 0f;
119 _buttonBorder1.Left.Set(0f, 0f);
120 _buttonBorder1.Top.Set(8f, 0f);
121 _buttonBorder1.Color = Color.Silver;
122 _buttonBorder1.IgnoresMouseInteraction = true;
123 uIPanel.Append(_buttonBorder1);
125 _buttonBorder2.VAlign = 0f;
126 _buttonBorder2.HAlign = 0f;
127 _buttonBorder2.Left.Set(76f, 0f);
128 _buttonBorder2.Top.Set(8f, 0f);
129 _buttonBorder2.Color = Color.Transparent;
130 _buttonBorder2.IgnoresMouseInteraction = true;
131 uIPanel.Append(_buttonBorder2);
133 _buttonVs1.VAlign = 0f;
134 _buttonVs1.HAlign = 0f;
135 _buttonVs1.Left.Set(172f, 0f);
136 _buttonVs1.Top.Set(8f, 0f);
137 _buttonVs1.OnLeftClick += VsGameplayButtonClick;
138 _buttonVs1.OnMouseOver += ManageBorderGameplayOn;
139 _buttonVs1.OnMouseOut += ManageBorderGameplayOff;
140 uIPanel.Append(_buttonVs1);
142 _buttonVs2.VAlign = 0f;
143 _buttonVs2.HAlign = 0f;
144 _buttonVs2.Left.Set(212f, 0f);
145 _buttonVs2.Top.Set(8f, 0f);
146 _buttonVs2.OnLeftClick += VsMenuButtonClick;
147 _buttonVs2.OnMouseOver += ManageBorderMenuOn;
148 _buttonVs2.OnMouseOut += ManageBorderMenuOff;
149 uIPanel.Append(_buttonVs2);
151 _buttonBorderVs1.VAlign = 0f;
152 _buttonBorderVs1.HAlign = 0f;
153 _buttonBorderVs1.Left.Set(172f, 0f);
154 _buttonBorderVs1.Top.Set(8f, 0f);
155 _buttonBorderVs1.Color = Color.Silver;
156 _buttonBorderVs1.IgnoresMouseInteraction = true;
159 _buttonBorderVs2.VAlign = 0f;
160 _buttonBorderVs2.HAlign = 0f;
161 _buttonBorderVs2.Left.Set(212f, 0f);
162 _buttonBorderVs2.Top.Set(8f, 0f);
163 _buttonBorderVs2.Color = Color.Transparent;
164 _buttonBorderVs2.IgnoresMouseInteraction = true;
166 _buttonProfile = new UIKeybindingSimpleListItem(() => PlayerInput.CurrentProfile.ShowName, new Color(73, 94, 171, 255) * 0.9f);
167 _buttonProfile.VAlign = 0f;
168 _buttonProfile.HAlign = 1f;
169 _buttonProfile.Width.Set(180f, 0f);
170 _buttonProfile.Height.Set(30f, 0f);
171 _buttonProfile.MarginRight = 30f;
172 _buttonProfile.Left.Set(0f, 0f);
173 _buttonProfile.Top.Set(8f, 0f);
174 _buttonProfile.OnLeftClick += profileButtonClick;
175 uIPanel.Append(_buttonProfile);
176 _uilist = new UIList();
177 _uilist.Width.Set(-25f, 1f);
178 _uilist.Height.Set(-50f, 1f);
179 _uilist.VAlign = 1f;
180 _uilist.PaddingBottom = 5f;
181 _uilist.ListPadding = 20f;
182 uIPanel.Append(_uilist);
184 FillList();
186 uIScrollbar.SetView(100f, 1000f);
187 uIScrollbar.Height.Set(-67f, 1f);
188 uIScrollbar.HAlign = 1f;
189 uIScrollbar.VAlign = 1f;
190 uIScrollbar.MarginBottom = 11f;
191 uIPanel.Append(uIScrollbar);
194 uITextPanel.HAlign = 0.5f;
195 uITextPanel.Top.Set(-45f, 0f);
196 uITextPanel.Left.Set(-10f, 0f);
197 uITextPanel.SetPadding(15f);
198 uITextPanel.BackgroundColor = new Color(73, 94, 171);
199 uIElement.Append(uITextPanel);
201 uITextPanel2.Width.Set(-10f, 0.5f);
202 uITextPanel2.Height.Set(50f, 0f);
203 uITextPanel2.VAlign = 1f;
204 uITextPanel2.HAlign = 0.5f;
205 uITextPanel2.Top.Set(-45f, 0f);
206 uITextPanel2.OnMouseOver += FadedMouseOver;
207 uITextPanel2.OnMouseOut += FadedMouseOut;
208 uITextPanel2.OnLeftClick += GoBackClick;
209 uIElement.Append(uITextPanel2);
212 }
213
214 private void AssembleBindPanels()
215 {
216 List<string> bindings = new List<string>
217 {
218 "MouseLeft", "MouseRight", "Up", "Down", "Left", "Right", "Jump", "Grapple", "SmartSelect", "SmartCursor",
219 "QuickMount", "QuickHeal", "QuickMana", "QuickBuff", "Throw", "Inventory", "ToggleCreativeMenu", "ViewZoomIn", "ViewZoomOut", "Loadout1",
220 "Loadout2", "Loadout3", "ToggleCameraMode", "sp9"
221 };
223 {
224 "MouseLeft", "MouseRight", "Up", "Down", "Left", "Right", "Jump", "Grapple", "SmartSelect", "SmartCursor",
225 "QuickMount", "QuickHeal", "QuickMana", "QuickBuff", "LockOn", "Throw", "Inventory", "Loadout1", "Loadout2", "Loadout3",
226 "ToggleCameraMode", "sp9"
227 };
229 {
230 "HotbarMinus", "HotbarPlus", "Hotbar1", "Hotbar2", "Hotbar3", "Hotbar4", "Hotbar5", "Hotbar6", "Hotbar7", "Hotbar8",
231 "Hotbar9", "Hotbar10", "sp10"
232 };
233 List<string> bindings4 = new List<string> { "MapZoomIn", "MapZoomOut", "MapAlphaUp", "MapAlphaDown", "MapFull", "MapStyle", "sp11" };
234 List<string> bindings5 = new List<string> { "sp1", "sp2", "RadialHotbar", "RadialQuickbar", "sp12" };
236 {
237 "sp3", "sp4", "sp5", "sp6", "sp7", "sp8", "sp14", "sp15", "sp16", "sp17",
238 "sp18", "sp19", "sp13"
239 };
244 currentInputMode = InputMode.XBoxGamepad;
250 currentInputMode = InputMode.KeyboardUI;
254 currentInputMode = InputMode.XBoxGamepadUI;
260 }
261
263 {
265 uISortableElement.HAlign = 0.5f;
266 uISortableElement.Width.Set(0f, 1f);
267 uISortableElement.Height.Set(2000f, 0f);
268 UIPanel uIPanel = new UIPanel();
269 uIPanel.Width.Set(0f, 1f);
270 uIPanel.Height.Set(-16f, 1f);
271 uIPanel.VAlign = 1f;
272 uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
274 UIList uIList = new UIList();
275 uIList.OverflowHidden = false;
276 uIList.Width.Set(0f, 1f);
277 uIList.Height.Set(-8f, 1f);
278 uIList.VAlign = 1f;
279 uIList.ListPadding = 5f;
280 uIPanel.Append(uIList);
281 _ = uIPanel.BackgroundColor;
282 switch (elementIndex)
283 {
284 case 0:
285 uIPanel.BackgroundColor = Color.Lerp(uIPanel.BackgroundColor, Color.Green, 0.18f);
286 break;
287 case 1:
288 uIPanel.BackgroundColor = Color.Lerp(uIPanel.BackgroundColor, Color.Goldenrod, 0.18f);
289 break;
290 case 2:
291 uIPanel.BackgroundColor = Color.Lerp(uIPanel.BackgroundColor, Color.HotPink, 0.18f);
292 break;
293 case 3:
294 uIPanel.BackgroundColor = Color.Lerp(uIPanel.BackgroundColor, Color.Indigo, 0.18f);
295 break;
296 case 4:
297 uIPanel.BackgroundColor = Color.Lerp(uIPanel.BackgroundColor, Color.Turquoise, 0.18f);
298 break;
299 }
300 CreateElementGroup(uIList, bindings, currentInputMode, uIPanel.BackgroundColor);
301 uIPanel.BackgroundColor = uIPanel.BackgroundColor.MultiplyRGBA(new Color(111, 111, 111));
303 switch (elementIndex)
304 {
305 case 0:
306 text = ((currentInputMode == InputMode.Keyboard || currentInputMode == InputMode.XBoxGamepad) ? Lang.menu[164] : Lang.menu[243]);
307 break;
308 case 1:
309 text = Lang.menu[165];
310 break;
311 case 2:
312 text = Lang.menu[166];
313 break;
314 case 3:
315 text = Lang.menu[167];
316 break;
317 case 4:
318 text = Lang.menu[198];
319 break;
320 }
322 {
323 VAlign = 0f,
324 HAlign = 0.5f
325 };
326 uISortableElement.Append(element);
327 uISortableElement.Recalculate();
328 float totalHeight = uIList.GetTotalHeight();
329 uISortableElement.Width.Set(0f, 1f);
330 uISortableElement.Height.Set(totalHeight + 30f + 16f, 0f);
331 return uISortableElement;
332 }
333
335 {
336 for (int i = 0; i < bindings.Count; i++)
337 {
338 _ = bindings[i];
340 uISortableElement.Width.Set(0f, 1f);
341 uISortableElement.Height.Set(30f, 0f);
342 uISortableElement.HAlign = 0.5f;
343 parent.Add(uISortableElement);
344 if (_BindingsHalfSingleLine.Contains(bindings[i]))
345 {
346 UIElement uIElement = CreatePanel(bindings[i], currentInputMode, color);
347 uIElement.Width.Set(0f, 0.5f);
348 uIElement.HAlign = 0.5f;
349 uIElement.Height.Set(0f, 1f);
350 uIElement.SetSnapPoint("Wide", SnapPointIndex++);
352 continue;
353 }
354 if (_BindingsFullLine.Contains(bindings[i]))
355 {
356 UIElement uIElement2 = CreatePanel(bindings[i], currentInputMode, color);
357 uIElement2.Width.Set(0f, 1f);
358 uIElement2.Height.Set(0f, 1f);
359 uIElement2.SetSnapPoint("Wide", SnapPointIndex++);
361 continue;
362 }
363 UIElement uIElement3 = CreatePanel(bindings[i], currentInputMode, color);
364 uIElement3.Width.Set(-5f, 0.5f);
365 uIElement3.Height.Set(0f, 1f);
366 uIElement3.SetSnapPoint("Thin", SnapPointIndex++);
368 i++;
369 if (i < bindings.Count)
370 {
371 uIElement3 = CreatePanel(bindings[i], currentInputMode, color);
372 uIElement3.Width.Set(-5f, 0.5f);
373 uIElement3.Height.Set(0f, 1f);
374 uIElement3.HAlign = 1f;
375 uIElement3.SetSnapPoint("Thin", SnapPointIndex++);
377 }
378 }
379 }
380
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 {
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 {
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 {
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 {
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 }
595
596 public override void OnActivate()
597 {
598 if (Main.gameMenu)
599 {
600 _outerContainer.Top.Set(220f, 0f);
601 _outerContainer.Height.Set(-220f, 1f);
602 }
603 else
604 {
605 _outerContainer.Top.Set(120f, 0f);
606 _outerContainer.Height.Set(-120f, 1f);
607 }
609 {
611 }
612 }
613
614 private static string GetCopyableProfileName()
615 {
616 string result = "Redigit's Pick";
618 {
619 result = PlayerInput.CurrentProfile.Name;
620 }
621 return result;
622 }
623
624 private void FillList()
625 {
627 if (!OnKeyboard)
628 {
630 }
631 if (!OnGameplay)
632 {
634 }
635 _uilist.Clear();
636 foreach (UIElement item in list)
637 {
639 }
640 }
641
643 {
644 if (PlayerInput.CurrentProfile.AllowEditting)
645 {
647 if (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()))
648 {
649 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap1"].Clear();
650 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap2"].Clear();
651 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap3"].Clear();
652 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap4"].Clear();
653 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap1"].Clear();
654 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap2"].Clear();
655 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap3"].Clear();
656 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap4"].Clear();
657 return;
658 }
659 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial1"].Clear();
660 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial2"].Clear();
661 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial3"].Clear();
662 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial4"].Clear();
663 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial1"].Clear();
664 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial2"].Clear();
665 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial3"].Clear();
666 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial4"].Clear();
667 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap1"] = new List<string> { Buttons.DPadUp.ToString() };
668 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap2"] = new List<string> { Buttons.DPadRight.ToString() };
669 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap3"] = new List<string> { Buttons.DPadDown.ToString() };
670 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap4"] = new List<string> { Buttons.DPadLeft.ToString() };
671 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap1"] = new List<string> { Buttons.DPadUp.ToString() };
672 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap2"] = new List<string> { Buttons.DPadRight.ToString() };
673 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap3"] = new List<string> { Buttons.DPadDown.ToString() };
674 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap4"] = new List<string> { Buttons.DPadLeft.ToString() };
675 }
676 }
677
679 {
680 if (PlayerInput.CurrentProfile.AllowEditting)
681 {
683 if (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()))
684 {
685 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial1"].Clear();
686 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial2"].Clear();
687 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial3"].Clear();
688 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial4"].Clear();
689 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial1"].Clear();
690 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial2"].Clear();
691 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial3"].Clear();
692 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial4"].Clear();
693 return;
694 }
695 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap1"].Clear();
696 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap2"].Clear();
697 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap3"].Clear();
698 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadSnap4"].Clear();
699 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap1"].Clear();
700 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap2"].Clear();
701 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap3"].Clear();
702 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadSnap4"].Clear();
703 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial1"] = new List<string> { Buttons.DPadUp.ToString() };
704 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial2"] = new List<string> { Buttons.DPadRight.ToString() };
705 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial3"] = new List<string> { Buttons.DPadDown.ToString() };
706 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepad].KeyStatus["DpadRadial4"] = new List<string> { Buttons.DPadLeft.ToString() };
707 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial1"] = new List<string> { Buttons.DPadUp.ToString() };
708 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial2"] = new List<string> { Buttons.DPadRight.ToString() };
709 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial3"] = new List<string> { Buttons.DPadDown.ToString() };
710 PlayerInput.CurrentProfile.InputModes[InputMode.XBoxGamepadUI].KeyStatus["DpadRadial4"] = new List<string> { Buttons.DPadLeft.ToString() };
711 }
712 }
713
721
729
731 {
732 _buttonBorder2.Color = ((!OnKeyboard) ? Color.Silver : Color.Black);
733 _buttonBorder1.Color = Main.OurFavoriteColor;
734 }
735
737 {
738 _buttonBorder2.Color = ((!OnKeyboard) ? Color.Silver : Color.Black);
739 _buttonBorder1.Color = (OnKeyboard ? Color.Silver : Color.Black);
740 }
741
743 {
744 _buttonBorder1.Color = (OnKeyboard ? Color.Silver : Color.Black);
745 _buttonBorder2.Color = Main.OurFavoriteColor;
746 }
747
749 {
750 _buttonBorder1.Color = (OnKeyboard ? Color.Silver : Color.Black);
751 _buttonBorder2.Color = ((!OnKeyboard) ? Color.Silver : Color.Black);
752 }
753
761
763 {
764 _buttonVs1.SetFrame(_GameplayVsUITexture.Frame(2, 2, 0, 1));
766 OnGameplay = false;
767 FillList();
768 }
769
771 {
772 _buttonBorderVs2.Color = ((!OnGameplay) ? Color.Silver : Color.Black);
773 _buttonBorderVs1.Color = Main.OurFavoriteColor;
774 }
775
777 {
778 _buttonBorderVs2.Color = ((!OnGameplay) ? Color.Silver : Color.Black);
779 _buttonBorderVs1.Color = (OnGameplay ? Color.Silver : Color.Black);
780 }
781
783 {
784 _buttonBorderVs1.Color = (OnGameplay ? Color.Silver : Color.Black);
785 _buttonBorderVs2.Color = Main.OurFavoriteColor;
786 }
787
789 {
790 _buttonBorderVs1.Color = (OnGameplay ? Color.Silver : Color.Black);
791 _buttonBorderVs2.Color = ((!OnGameplay) ? Color.Silver : Color.Black);
792 }
793
795 {
796 string name = PlayerInput.CurrentProfile.Name;
797 List<string> list = PlayerInput.Profiles.Keys.ToList();
798 int num = list.IndexOf(name);
799 num++;
800 if (num >= list.Count)
801 {
802 num -= list.Count;
803 }
805 }
806
808 {
810 ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171);
811 ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
812 }
813
815 {
816 ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f;
817 ((UIPanel)evt.Target).BorderColor = Color.Black;
818 }
819
821 {
822 Main.menuMode = 1127;
824 }
825
826 public override void Draw(SpriteBatch spriteBatch)
827 {
828 base.Draw(spriteBatch);
829 SetupGamepadPoints(spriteBatch);
830 }
831
832 private void SetupGamepadPoints(SpriteBatch spriteBatch)
833 {
834 UILinkPointNavigator.Shortcuts.BackButtonCommand = 4;
835 int num = 3000;
842 int key = num;
844 uILinkPoint.Unlink();
845 uILinkPoint.Up = num + 6;
846 key = num + 1;
848 uILinkPoint2.Unlink();
849 uILinkPoint2.Right = num + 2;
850 uILinkPoint2.Down = num + 6;
851 key = num + 2;
853 uILinkPoint3.Unlink();
854 uILinkPoint3.Left = num + 1;
855 uILinkPoint3.Right = num + 4;
856 uILinkPoint3.Down = num + 6;
857 key = num + 4;
859 uILinkPoint4.Unlink();
860 uILinkPoint4.Left = num + 2;
861 uILinkPoint4.Right = num + 5;
862 uILinkPoint4.Down = num + 6;
863 key = num + 5;
865 uILinkPoint5.Unlink();
866 uILinkPoint5.Left = num + 4;
867 uILinkPoint5.Right = num + 3;
868 uILinkPoint5.Down = num + 6;
869 key = num + 3;
871 uILinkPoint6.Unlink();
872 uILinkPoint6.Left = num + 5;
873 uILinkPoint6.Down = num + 6;
874 float num2 = 1f / Main.UIScale;
877 Vector2 maximum = clippingRectangle.BottomRight() * num2;
879 for (int i = 0; i < snapPoints.Count; i++)
880 {
881 if (!snapPoints[i].Position.Between(minimum, maximum))
882 {
883 _ = snapPoints[i].Position;
885 i--;
886 }
887 }
888 snapPoints.Sort((SnapPoint x, SnapPoint y) => x.Id.CompareTo(y.Id));
889 for (int j = 0; j < snapPoints.Count; j++)
890 {
891 key = num + 6 + j;
892 if (snapPoints[j].Name == "Thin")
893 {
895 uILinkPoint7.Unlink();
897 uILinkPoint7.Right = key + 1;
898 uILinkPoint7.Down = ((j < snapPoints.Count - 2) ? (key + 2) : num);
899 uILinkPoint7.Up = ((j < 2) ? (num + 1) : ((snapPoints[j - 1].Name == "Wide") ? (key - 1) : (key - 2)));
901 UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = key;
902 j++;
903 if (j < snapPoints.Count)
904 {
905 key = num + 6 + j;
907 uILinkPoint8.Unlink();
909 uILinkPoint8.Left = key - 1;
910 uILinkPoint8.Down = ((j >= snapPoints.Count - 1) ? num : ((snapPoints[j + 1].Name == "Wide") ? (key + 1) : (key + 2)));
911 uILinkPoint8.Up = ((j < 2) ? (num + 1) : (key - 2));
912 UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = key;
913 }
914 }
915 else
916 {
918 uILinkPoint9.Unlink();
920 uILinkPoint9.Down = ((j < snapPoints.Count - 1) ? (key + 1) : num);
921 uILinkPoint9.Up = ((j < 1) ? (num + 1) : ((snapPoints[j - 1].Name == "Wide") ? (key - 1) : (key - 2)));
922 UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = key;
924 }
925 }
926 if (ForceMoveTo != -1)
927 {
929 ForceMoveTo = -1;
930 }
931 }
932}
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
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
static decimal Round(decimal d)
Definition Math.cs:1096
static int Sign(decimal value)
Definition Math.cs:1202
static void PlaySound(int type, Vector2 position, int style=1)
virtual void Add(UIElement item)
Definition UIList.cs:82
override List< SnapPoint > GetSnapPoints()
Definition UIList.cs:165
void SetScrollbar(UIScrollbar scrollbar)
Definition UIList.cs:141
UIElement CreatePanel(string bind, InputMode currentInputMode, Color color)
void KeyboardButtonClick(UIMouseEvent evt, UIElement listeningElement)
void GamepadButtonClick(UIMouseEvent evt, UIElement listeningElement)
void ManageBorderMenuOn(UIMouseEvent evt, UIElement listeningElement)
void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
void SnapButtonClick(UIMouseEvent evt, UIElement listeningElement)
void VsMenuButtonClick(UIMouseEvent evt, UIElement listeningElement)
void ManageBorderGameplayOff(UIMouseEvent evt, UIElement listeningElement)
void CreateElementGroup(UIList parent, List< string > bindings, InputMode currentInputMode, Color color)
void ManageBorderMenuOff(UIMouseEvent evt, UIElement listeningElement)
void ManageBorderGamepadOn(UIMouseEvent evt, UIElement listeningElement)
void ManageBorderGameplayOn(UIMouseEvent evt, UIElement listeningElement)
void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
void VsGameplayButtonClick(UIMouseEvent evt, UIElement listeningElement)
void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
void profileButtonClick(UIMouseEvent evt, UIElement listeningElement)
override void Draw(SpriteBatch spriteBatch)
void ManageBorderKeyboardOff(UIMouseEvent evt, UIElement listeningElement)
void RadialButtonClick(UIMouseEvent evt, UIElement listeningElement)
void ManageBorderGamepadOff(UIMouseEvent evt, UIElement listeningElement)
UISortableElement CreateBindingGroup(int elementIndex, List< string > bindings, InputMode currentInputMode)
void ManageBorderKeyboardOn(UIMouseEvent evt, UIElement listeningElement)
static void SetSelectedProfile(string name)
static PlayerInputProfile CurrentProfile
static Dictionary< string, PlayerInputProfile > OriginalProfiles
static Dictionary< string, PlayerInputProfile > Profiles
static readonly Color FancyUIFatButtonMouseOver
Definition Colors.cs:91
static float HandleSliderHorizontalInput(float currentValue, float min, float max, float deadZone=0.2f, float sensitivity=0.5f)
static LocalizedText[] menu
Definition Lang.cs:19
static LocalizedText GetText(string key)
Definition Language.cs:10
static readonly LocalizedText Empty
static float UIScale
Definition Main.cs:2624
static Microsoft.Xna.Framework.Color OurFavoriteColor
Definition Main.cs:902
static IAssetRepository Assets
Definition Main.cs:209
static bool gameMenu
Definition Main.cs:1926
static Dictionary< int, UILinkPoint > Points
static void SetPosition(int ID, Vector2 Position)
StyleDimension Height
Definition UIElement.cs:29
void Append(UIElement element)
Definition UIElement.cs:166
CalculatedStyle GetInnerDimensions()
Definition UIElement.cs:377
StyleDimension Left
Definition UIElement.cs:25
StyleDimension Width
Definition UIElement.cs:27
StyleDimension Top
Definition UIElement.cs:23
Rectangle GetClippingRectangle(SpriteBatch spriteBatch)
Definition UIElement.cs:246
static float GetLerpValue(float from, float to, float t, bool clamped=false)
Definition Utils.cs:203
static Color Transparent
Definition Color.cs:76
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491
void Set(float pixels, float precent)