Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIGamepadHelper.cs
Go to the documentation of this file.
1using System;
3using System.Linq;
8using Terraria.UI;
10
12
13[StructLayout(LayoutKind.Sequential, Size = 1)]
14public struct UIGamepadHelper
15{
17 {
18 int num = (int)Math.Ceiling((float)pointsForGrid.Count / (float)pointsPerLine);
20 for (int i = 0; i < pointsForGrid.Count; i++)
21 {
22 int num2 = i % pointsPerLine;
23 int num3 = i / pointsPerLine;
25 }
26 for (int j = 0; j < array.GetLength(0); j++)
27 {
28 for (int k = 0; k < array.GetLength(1); k++)
29 {
31 if (uILinkPoint == null)
32 {
33 continue;
34 }
35 if (j < array.GetLength(0) - 1)
36 {
38 if (uILinkPoint2 != null)
39 {
41 }
42 }
43 if (k < array.GetLength(1) - 1)
44 {
46 if (uILinkPoint3 != null)
47 {
49 }
50 }
51 if (leftLinkPoint != null && j == 0)
52 {
53 uILinkPoint.Left = leftLinkPoint.ID;
54 }
55 if (topLinkPoint != null && k == 0)
56 {
57 uILinkPoint.Up = topLinkPoint.ID;
58 }
59 if (rightLinkPoint != null && j == pointsPerLine - 1)
60 {
61 uILinkPoint.Right = rightLinkPoint.ID;
62 }
63 if (bottomLinkPoint != null && k == num - 1)
64 {
65 uILinkPoint.Down = bottomLinkPoint.ID;
66 }
67 }
68 }
69 return array;
70 }
71
73 {
74 if (stripOnLeft == null || stripOnRight == null)
75 {
76 return;
77 }
78 int num = Math.Max(stripOnLeft.Length, stripOnRight.Length);
79 int num2 = Math.Min(stripOnLeft.Length, stripOnRight.Length);
80 for (int i = 0; i < leftStripStartOffset; i++)
81 {
83 }
84 for (int j = 0; j < num2; j++)
85 {
87 }
88 for (int k = num2; k < num; k++)
89 {
90 if (stripOnLeft.Length > k)
91 {
92 stripOnLeft[k].Right = stripOnRight[stripOnRight.Length - 1].ID;
93 }
94 if (stripOnRight.Length > k)
95 {
96 stripOnRight[k].Left = stripOnLeft[stripOnLeft.Length - 1].ID;
97 }
98 }
99 }
100
102 {
103 if (strip == null || theSingle == null)
104 {
105 return;
106 }
107 int num = Math.Max(strip.Length, 1);
108 int num2 = Math.Min(strip.Length, 1);
109 for (int i = 0; i < num2; i++)
110 {
112 }
113 for (int j = num2; j < num; j++)
114 {
115 if (strip.Length > j)
116 {
117 strip[j].Right = theSingle.ID;
118 }
119 }
120 }
121
123 {
124 float num = 1f / Main.UIScale;
125 Rectangle clippingRectangle = containerPanel.GetClippingRectangle(spriteBatch);
126 Vector2 minimum = clippingRectangle.TopLeft() * num;
127 Vector2 maximum = clippingRectangle.BottomRight() * num;
128 for (int i = 0; i < pts.Count; i++)
129 {
130 if (!pts[i].Position.Between(minimum, maximum))
131 {
132 pts.Remove(pts[i]);
133 i--;
134 }
135 }
136 }
137
139 {
140 if (strip != null && theSingle != null)
141 {
142 for (int num = strip.Length - 1; num >= 0; num--)
143 {
145 }
146 }
147 }
148
150 {
151 if (strip != null && theSingle != null)
152 {
153 for (int num = strip.Length - 1; num >= 0; num--)
154 {
156 }
157 }
158 }
159
161 {
162 if (strip != null && theSingle != null)
163 {
164 PairUpDown(strip[strip.Length - 1], theSingle);
165 }
166 }
167
169 {
171 for (int i = 0; i < currentStrip.Count; i++)
172 {
174 }
175 for (int j = 0; j < currentStrip.Count - 1; j++)
176 {
177 PairUpDown(array[j], array[j + 1]);
178 }
179 return array;
180 }
181
183 {
185 for (int i = 0; i < currentStrip.Count; i++)
186 {
188 }
189 for (int j = 0; j < currentStrip.Count - 1; j++)
190 {
191 PairLeftRight(array[j], array[j + 1]);
192 }
193 return array;
194 }
195
208
226
228 {
229 return (from x in pts
230 where x.Name == name
231 orderby x.Id
232 select x).ToList();
233 }
234
236 {
237 if (leftSide != null && rightSide != null)
238 {
239 leftSide.Right = rightSide.ID;
240 rightSide.Left = leftSide.ID;
241 }
242 }
243
245 {
246 if (upSide != null && downSide != null)
247 {
248 upSide.Down = downSide.ID;
249 downSide.Up = upSide.ID;
250 }
251 }
252
260
261 public UILinkPoint GetLinkPoint(int id, UIElement element)
262 {
263 if (element.GetSnapPoint(out var point))
264 {
265 return MakeLinkPointFromSnapPoint(id, point);
266 }
267 return null;
268 }
269
271 {
272 if (snap == null)
273 {
274 return null;
275 }
276 return MakeLinkPointFromSnapPoint(id++, snap);
277 }
278
289
315
317 {
318 float num = 1f / Main.UIScale;
319 Rectangle clippingRectangle = container.GetClippingRectangle(spriteBatch);
320 Vector2 minimum = clippingRectangle.TopLeft() * num;
321 Vector2 maximum = clippingRectangle.BottomRight() * num;
322 for (int i = 0; i < pointsAtMiddle.Count; i++)
323 {
324 if (!pointsAtMiddle[i].Position.Between(minimum, maximum))
325 {
327 i--;
328 }
329 }
330 }
331}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Ceiling(double a)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static float UIScale
Definition Main.cs:2624
static Vector2 MouseScreen
Definition Main.cs:2773
static Dictionary< int, UILinkPoint > Points
static void SetPosition(int ID, Vector2 Position)
bool GetSnapPoint(out SnapPoint point)
Definition UIElement.cs:135
Rectangle GetClippingRectangle(SpriteBatch spriteBatch)
Definition UIElement.cs:246
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91
void LinkVerticalStrips(UILinkPoint[] stripOnLeft, UILinkPoint[] stripOnRight, int leftStripStartOffset)
UILinkPoint TryMakeLinkPoint(ref int id, SnapPoint snap)
void CullPointsOutOfElementArea(SpriteBatch spriteBatch, List< SnapPoint > pointsAtMiddle, UIElement container)
void TryMovingBackIntoCreativeGridIfOutOfIt(int start, int currentID)
List< SnapPoint > GetOrderedPointsByCategoryName(List< SnapPoint > pts, string name)
void RemovePointsOutOfView(List< SnapPoint > pts, UIElement containerPanel, SpriteBatch spriteBatch)
UILinkPoint[,] CreateUILinkPointGrid(ref int currentID, List< SnapPoint > pointsForGrid, int pointsPerLine, UILinkPoint topLinkPoint, UILinkPoint leftLinkPoint, UILinkPoint rightLinkPoint, UILinkPoint bottomLinkPoint)
void PairLeftRight(UILinkPoint leftSide, UILinkPoint rightSide)
void LinkHorizontalStripUpSideToSingle(UILinkPoint[] strip, UILinkPoint theSingle)
UILinkPoint[] CreateUILinkStripHorizontal(ref int currentID, List< SnapPoint > currentStrip)
void PairUpDown(UILinkPoint upSide, UILinkPoint downSide)
void LinkVerticalStripBottomSideToSingle(UILinkPoint[] strip, UILinkPoint theSingle)
void LinkVerticalStripRightSideToSingle(UILinkPoint[] strip, UILinkPoint theSingle)
UILinkPoint[] CreateUILinkStripVertical(ref int currentID, List< SnapPoint > currentStrip)
UILinkPoint GetLinkPoint(int id, UIElement element)
void LinkHorizontalStripBottomSideToSingle(UILinkPoint[] strip, UILinkPoint theSingle)
UILinkPoint MakeLinkPointFromSnapPoint(int id, SnapPoint snap)
UILinkPoint[] GetVerticalStripFromCategoryName(ref int currentID, List< SnapPoint > pts, string categoryName)
void MoveToVisuallyClosestPoint(int idRangeStartInclusive, int idRangeEndExclusive)
void MoveToVisuallyClosestPoint(List< UILinkPoint > lostrefpoints)