Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UICreativePowersMenu.cs
Go to the documentation of this file.
1using System;
8using Terraria.UI;
10
12
14{
28
39
40 private enum WeatherSubcategory
41 {
42 None,
45 }
46
47 private enum TimeSubcategory
48 {
49 None,
51 }
52
54 {
55 None,
57 }
58
59 private bool _hovered;
60
62
64
66
68
70
72
74
76
78
80
81 private const int INITIAL_LEFT_PIXELS = 20;
82
83 private const int LEFT_PIXELS_PER_STRIP_DEPTH = 60;
84
85 private const string STRIP_MAIN = "strip 0";
86
87 private const string STRIP_DEPTH_1 = "strip 1";
88
89 private const string STRIP_DEPTH_2 = "strip 2";
90
92
93 public bool IsShowingResearchMenu => _mainCategory.CurrentOption == 2;
94
95 public override void OnActivate()
96 {
98 }
99
100 private void InitializePage()
101 {
102 int num = 270;
103 int num2 = 20;
105 {
106 HAlign = 0f,
107 VAlign = 0f,
108 Width = new StyleDimension(0f, 1f),
109 Height = new StyleDimension(-num - num2, 1f),
110 Top = new StyleDimension(num, 0f)
111 };
115 {
116 HAlign = 0f,
117 VAlign = 0.5f,
118 Left = new StyleDimension(20f, 0f)
119 };
120 powerStripUIElement.OnMouseOver += strip_OnMouseOver;
121 powerStripUIElement.OnMouseOut += strip_OnMouseOut;
125 {
126 HAlign = 0f,
127 VAlign = 0.5f,
128 Left = new StyleDimension(80f, 0f)
129 };
130 powerStripUIElement2.OnMouseOver += strip_OnMouseOver;
131 powerStripUIElement2.OnMouseOut += strip_OnMouseOut;
135 {
136 HAlign = 0f,
137 VAlign = 0.5f,
138 Left = new StyleDimension(80f, 0f)
139 };
140 powerStripUIElement3.OnMouseOver += strip_OnMouseOver;
141 powerStripUIElement3.OnMouseOut += strip_OnMouseOut;
145 {
146 HAlign = 0f,
147 VAlign = 0.5f,
148 Left = new StyleDimension(80f, 0f)
149 };
150 powerStripUIElement4.OnMouseOver += strip_OnMouseOver;
151 powerStripUIElement4.OnMouseOut += strip_OnMouseOut;
154 {
155 HAlign = 0f,
156 VAlign = 0.5f,
157 Left = new StyleDimension(80f, 0f),
158 Width = new StyleDimension(480f, 0f),
159 Height = new StyleDimension(-88f, 1f)
160 };
162 base.OnUpdate += UICreativePowersMenu_OnUpdate;
163 }
164
166 {
168 mainCategory.Buttons.Clear();
171 creativePowerUIElementRequestInfo.PreferredButtonWidth = 40;
172 creativePowerUIElementRequestInfo.PreferredButtonHeight = 40;
176 groupOptionButton.OnLeftClick += MainCategoryButtonClick;
177 groupOptionButton.OnUpdate += itemsWindowButton_OnUpdate;
182 groupOptionButton2.OnLeftClick += MainCategoryButtonClick;
183 groupOptionButton2.OnUpdate += researchWindowButton_OnUpdate;
188 groupOptionButton3.OnLeftClick += MainCategoryButtonClick;
189 groupOptionButton3.OnUpdate += timeCategoryButton_OnUpdate;
194 groupOptionButton4.OnLeftClick += MainCategoryButtonClick;
195 groupOptionButton4.OnUpdate += weatherCategoryButton_OnUpdate;
200 groupOptionButton5.OnLeftClick += MainCategoryButtonClick;
201 groupOptionButton5.OnUpdate += personalCategoryButton_OnUpdate;
206 groupOptionButton6.OnLeftClick += MainCategoryButtonClick;
208 return list;
209 }
210
212 {
214 if (affectedElement.IsMouseHovering)
215 {
216 string originalText = Language.GetTextValue(groupOptionButton.IsSelected ? (categoryNameKey + "Opened") : (categoryNameKey + "Closed"));
218 Main.instance.MouseTextNoOverride(originalText, 0, 0);
219 }
220 }
221
223 {
224 CategoryButton_OnUpdate_DisplayTooltips(affectedElement, "CreativePowers.InfiniteItemsCategory");
225 }
226
228 {
229 CategoryButton_OnUpdate_DisplayTooltips(affectedElement, "CreativePowers.ResearchItemsCategory");
230 }
231
236
241
246
248 {
249 if (_hovered)
250 {
251 Main.LocalPlayer.mouseInterface = true;
252 }
253 }
254
256 {
257 _hovered = false;
258 }
259
261 {
262 _hovered = true;
263 }
264
271
272 private void ToggleMainCategory(int option)
273 {
275 }
276
277 private void ToggleWeatherCategory(int option)
278 {
280 }
281
282 private void ToggleTimeCategory(int option)
283 {
285 }
286
287 private void TogglePersonalCategory(int option)
288 {
290 }
291
296
301
303 {
304 if (tree.CurrentOption == option)
305 {
306 option = defaultOption.ToInt32(null);
307 }
308 tree.CurrentOption = option;
309 foreach (GroupOptionButton<int> value in tree.Buttons.Values)
310 {
311 value.SetCurrentOption(option);
312 }
313 }
314
316 {
320 creativePowerUIElementRequestInfo.PreferredButtonWidth = 40;
321 creativePowerUIElementRequestInfo.PreferredButtonHeight = 40;
323 CreativePowerManager.Instance.GetPower<CreativePowers.FreezeTime>().ProvidePowerButtons(request, list);
329 groupOptionButton.OnLeftClick += TimeCategoryButtonClick;
331 return list;
332 }
333
349
368
380
382 {
384 switch (groupOptionButton.OptionValue)
385 {
386 case 2:
388 {
389 return;
390 }
391 break;
392 case 1:
394 {
395 return;
396 }
397 break;
398 }
401 }
402
413
424
425 private void RefreshElementsOrder()
426 {
429 UIElement value = null;
431 if (mainCategory.Sliders.TryGetValue(mainCategory.CurrentOption, out value))
432 {
434 }
435 if (mainCategory.CurrentOption == 1)
436 {
439 }
440 if (mainCategory.CurrentOption == 2)
441 {
444 }
445 if (mainCategory.CurrentOption == 3)
446 {
449 if (timeCategory.Sliders.TryGetValue(timeCategory.CurrentOption, out value))
450 {
452 }
453 }
454 if (mainCategory.CurrentOption == 4)
455 {
458 if (weatherCategory.Sliders.TryGetValue(weatherCategory.CurrentOption, out value))
459 {
461 }
462 }
463 if (mainCategory.CurrentOption == 6)
464 {
467 if (personalCategory.Sliders.TryGetValue(personalCategory.CurrentOption, out value))
468 {
470 }
471 }
472 }
473
474 public override void Draw(SpriteBatch spriteBatch)
475 {
476 base.Draw(spriteBatch);
477 SetupGamepadPoints(spriteBatch);
478 }
479
480 private void SetupGamepadPoints(SpriteBatch spriteBatch)
481 {
482 int currentID = 10000;
487 UILinkPoint[] array = null;
488 UILinkPoint[] array2 = null;
489 UILinkPoint[] array3 = null;
491 {
493 }
495 {
497 }
499 {
501 }
502 if (array != null && array2 != null)
503 {
504 _helper.LinkVerticalStrips(array, array2, (array.Length - array2.Length) / 2);
505 }
506 if (array2 != null && array3 != null)
507 {
508 _helper.LinkVerticalStrips(array2, array3, (array.Length - array2.Length) / 2);
509 }
513 for (int i = 0; i < snapPoints.Count; i++)
514 {
516 string name = snapPoint.Name;
517 if (!(name == "CreativeSacrificeConfirm"))
518 {
519 if (name == "CreativeInfinitesSearch")
520 {
522 Main.CreativeMenu.GamepadPointIdForInfiniteItemSearchHack = uILinkPoint3.ID;
523 }
524 }
525 else
526 {
528 }
529 }
532 UILinkPoint[] array4 = null;
534 {
536 if (uILinkPoint3 != null)
537 {
538 uILinkPoint3.Up = array4[0].ID;
539 for (int j = 0; j < array4.Length; j++)
540 {
541 array4[j].Down = uILinkPoint3.ID;
542 }
543 }
544 }
546 UILinkPoint[,] array5 = null;
548 {
551 }
552 else if (uILinkPoint3 != null)
553 {
555 }
556 if (uILinkPoint3 != null && array5 != null)
557 {
559 }
560 if (uILinkPoint != null && IsShowingResearchMenu)
561 {
563 }
564 if (uILinkPoint2 != null)
565 {
567 uILinkPoint2.Left = array[0].ID;
568 }
569 if (Main.CreativeMenu.GamepadMoveToSearchButtonHack)
570 {
571 Main.CreativeMenu.GamepadMoveToSearchButtonHack = false;
572 if (uILinkPoint3 != null)
573 {
575 }
576 }
577 }
578}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
static void AddDescriptionIfNeeded(ref string originalText, string descriptionKey)
static void UpdateUnlockStateByPower(ICreativePower power, UIElement button, Color colorWhenSelected)
static UIImageFramed GetIconImage(Point iconLocation)
void personalCategoryButton_OnUpdate(UIElement affectedElement)
void WeatherCategoryButtonClick(UIMouseEvent evt, UIElement listeningElement)
void TimeCategoryButtonClick(UIMouseEvent evt, UIElement listeningElement)
void weatherCategoryButton_OnUpdate(UIElement affectedElement)
void ToggleCategory< TEnum >(MenuTree< TEnum > tree, int option, TEnum defaultOption)
static void CategoryButton_OnUpdate_DisplayTooltips(UIElement affectedElement, string categoryNameKey)
void MainCategoryButtonClick(UIMouseEvent evt, UIElement listeningElement)
void researchWindowButton_OnUpdate(UIElement affectedElement)
void UICreativePowersMenu_OnUpdate(UIElement affectedElement)
void strip_OnMouseOver(UIMouseEvent evt, UIElement listeningElement)
void strip_OnMouseOut(UIMouseEvent evt, UIElement listeningElement)
void PersonalCategoryButtonClick(UIMouseEvent evt, UIElement listeningElement)
GroupOptionButton< int > CreateSubcategoryButton< T >(ref CreativePowerUIElementRequestInfo request, int subcategoryDepth, string subcategoryName, int subcategoryIndex, int currentSelectedInSubcategory, Dictionary< int, GroupOptionButton< int > > subcategoryButtons, Dictionary< int, UIElement > slidersSet)
static string GetTextValue(string key)
Definition Language.cs:15
static CreativeUI CreativeMenu
Definition Main.cs:369
static Main instance
Definition Main.cs:283
static Dictionary< int, UILinkPoint > Points
StyleDimension Height
Definition UIElement.cs:29
void Append(UIElement element)
Definition UIElement.cs:166
StyleDimension Left
Definition UIElement.cs:25
StyleDimension Width
Definition UIElement.cs:27
virtual List< SnapPoint > GetSnapPoints()
Definition UIElement.cs:267
StyleDimension Top
Definition UIElement.cs:23
void LinkVerticalStrips(UILinkPoint[] stripOnLeft, UILinkPoint[] stripOnRight, int leftStripStartOffset)
List< SnapPoint > GetOrderedPointsByCategoryName(List< SnapPoint > pts, string name)
UILinkPoint[,] CreateUILinkPointGrid(ref int currentID, List< SnapPoint > pointsForGrid, int pointsPerLine, UILinkPoint topLinkPoint, UILinkPoint leftLinkPoint, UILinkPoint rightLinkPoint, UILinkPoint bottomLinkPoint)
UILinkPoint[] CreateUILinkStripHorizontal(ref int currentID, List< SnapPoint > currentStrip)
void PairUpDown(UILinkPoint upSide, UILinkPoint downSide)
void LinkVerticalStripRightSideToSingle(UILinkPoint[] strip, UILinkPoint theSingle)
UILinkPoint[] CreateUILinkStripVertical(ref int currentID, List< SnapPoint > currentStrip)
UILinkPoint MakeLinkPointFromSnapPoint(int id, SnapPoint snap)