Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIDynamicItemCollection.cs
Go to the documentation of this file.
1using System;
6using Terraria.ID;
7using Terraria.UI;
9
11
13{
15
17
18 private int _itemsPerLine;
19
20 private const int sizePerEntryX = 44;
21
22 private const int sizePerEntryY = 44;
23
25
26 private Item _item = new Item();
27
29 {
30 Width = new StyleDimension(0f, 1f);
31 HAlign = 0.5f;
32 UpdateSize();
33 }
34
35 protected override void DrawSelf(SpriteBatch spriteBatch)
36 {
37 //IL_005e: Unknown result type (might be due to invalid IL or missing references)
38 //IL_0135: Unknown result type (might be due to invalid IL or missing references)
39 Main.inventoryScale = 0.84615386f;
41 int num = _itemsPerLine;
42 for (int i = startItemIndex; i < endItemIndex; i++)
43 {
47 int context = 29;
48 if ((int)TextureAssets.Item[num2].State == 0)
49 {
50 num--;
51 }
53 if (base.IsMouseHovering && itemSlotHitbox.Contains(Main.MouseScreen.ToPoint()) && !PlayerInput.IgnoreMouseInterface)
54 {
55 _item.SetDefaults(inv.type);
56 inv = _item;
57 Main.LocalPlayer.mouseInterface = true;
58 ItemSlot.OverrideHover(ref inv, context);
59 ItemSlot.LeftClick(ref inv, context);
60 ItemSlot.RightClick(ref inv, context);
61 ItemSlot.MouseHover(ref inv, context);
63 }
64 UILinkPointNavigator.Shortcuts.CREATIVE_ItemSlotShouldHighlightAsSelected = cREATIVE_ItemSlotShouldHighlightAsSelected;
65 ItemSlot.Draw(spriteBatch, ref inv, context, itemSlotHitbox.TopLeft());
66 if (num <= 0)
67 {
68 break;
69 }
70 }
71 while (_itemIdsToLoadTexturesFor.Count > 0 && num > 0)
72 {
75 if ((int)TextureAssets.Item[num3].State == 0)
76 {
77 Main.instance.LoadItem(num3);
78 num -= 4;
79 }
80 }
81 }
82
84 {
85 int num = i - startItemIndex;
86 int num2 = num % _itemsPerLine;
87 int num3 = num / _itemsPerLine;
88 return new Rectangle(startX + num2 * 44, startY + num3 * 44, 44, 44);
89 }
90
92 {
94 Rectangle viewCullingArea = base.Parent.GetViewCullingArea();
95 int x = rectangle.Center.X;
96 startX = x - (int)((float)(44 * _itemsPerLine) * 0.5f);
97 startY = rectangle.Top;
100 int num = (Math.Min(viewCullingArea.Top, rectangle.Top) - viewCullingArea.Top) / 44;
101 startY += -num * 44;
103 int num2 = (int)Math.Ceiling((float)viewCullingArea.Height / 44f) * _itemsPerLine;
105 {
107 }
108 }
109
110 public override void Recalculate()
111 {
112 base.Recalculate();
113 UpdateSize();
114 }
115
116 public override void Update(GameTime gameTime)
117 {
118 base.Update(gameTime);
119 if (base.IsMouseHovering)
120 {
121 Main.LocalPlayer.mouseInterface = true;
122 }
123 }
124
133
134 public int GetItemsPerLine()
135 {
136 return _itemsPerLine;
137 }
138
140 {
144 Rectangle viewCullingArea = base.Parent.GetViewCullingArea();
145 int num = endItemIndex - startItemIndex;
146 while (_dummySnapPoints.Count < num)
147 {
148 _dummySnapPoints.Add(new SnapPoint("CreativeInfinitesSlot", 0, Vector2.Zero, Vector2.Zero));
149 }
150 int num2 = 0;
152 for (int i = startItemIndex; i < endItemIndex; i++)
153 {
156 {
158 snapPoint.ThisIsAHackThatChangesTheSnapPointsInfo(Vector2.Zero, center.ToVector2() - vector, num2);
159 snapPoint.Calculate(this);
160 num2++;
162 }
163 }
164 foreach (UIElement element in Elements)
165 {
166 list.AddRange(element.GetSnapPoints());
167 }
168 return list;
169 }
170
171 public void UpdateSize()
172 {
173 int num = (_itemsPerLine = GetDimensions().ToRectangle().Width / 44);
174 int num2 = (int)Math.Ceiling((float)_itemIdsAvailableToShow.Count / (float)num);
175 MinHeight.Set(44 * num2, 0f);
176 }
177}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
void Add(TKey key, TValue value)
void AddRange(IEnumerable< T > collection)
Definition List.cs:275
void RemoveAt(int index)
Definition List.cs:824
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Ceiling(double a)
static Asset< Texture2D >[] Item
Rectangle GetItemSlotHitbox(int startX, int startY, int startItemIndex, int i)
void GetGridParameters(out int startX, out int startY, out int startItemIndex, out int endItemIndex)
static Dictionary< int, Item > ItemsByType
void SetDefaults(int Type=0)
Definition Item.cs:47332
static Main instance
Definition Main.cs:283
static Vector2 MouseScreen
Definition Main.cs:2773
static void Draw(SpriteBatch spriteBatch, ref Item inv, int context, Vector2 position, Color lightColor=default(Color))
Definition ItemSlot.cs:1777
static void OverrideHover(ref Item inv, int context=0)
Definition ItemSlot.cs:322
static void RightClick(ref Item inv, int context=0)
Definition ItemSlot.cs:1313
static void LeftClick(ref Item inv, int context=0)
Definition ItemSlot.cs:630
static void MouseHover(int context=0)
Definition ItemSlot.cs:2445
StyleDimension Width
Definition UIElement.cs:27
StyleDimension MinHeight
Definition UIElement.cs:37
CalculatedStyle GetDimensions()
Definition UIElement.cs:382
virtual List< SnapPoint > GetSnapPoints()
Definition UIElement.cs:267
void Set(float pixels, float precent)