Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIWorkshopSelectResourcePackToPublish.cs
Go to the documentation of this file.
2using System.Linq;
8using Terraria.ID;
10using Terraria.IO;
12using Terraria.UI;
14
16
18{
20
22
24
26
28
30
32
33 private bool skipDraw;
34
39
40 public override void OnInitialize()
41 {
43 uIElement.Width.Set(0f, 0.8f);
44 uIElement.MaxWidth.Set(650f, 0f);
45 uIElement.Top.Set(220f, 0f);
46 uIElement.Height.Set(-220f, 1f);
47 uIElement.HAlign = 0.5f;
48 UIPanel uIPanel = new UIPanel();
49 uIPanel.Width.Set(0f, 1f);
50 uIPanel.Height.Set(-110f, 1f);
51 uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
52 uIElement.Append(uIPanel);
54 _entryList = new UIList();
55 _entryList.Width.Set(0f, 1f);
56 _entryList.Height.Set(0f, 1f);
57 _entryList.ListPadding = 5f;
58 uIPanel.Append(_entryList);
59 _scrollbar = new UIScrollbar();
60 _scrollbar.SetView(100f, 1000f);
61 _scrollbar.Height.Set(0f, 1f);
62 _scrollbar.HAlign = 1f;
64 UITextPanel<LocalizedText> uITextPanel = new UITextPanel<LocalizedText>(Language.GetText("UI.WorkshopSelectResourcePackToPublishMenuTitle"), 0.8f, large: true);
65 uITextPanel.HAlign = 0.5f;
66 uITextPanel.Top.Set(-40f, 0f);
67 uITextPanel.SetPadding(15f);
68 uITextPanel.BackgroundColor = new Color(73, 94, 171);
69 uIElement.Append(uITextPanel);
71 uITextPanel2.Width.Set(-10f, 0.5f);
72 uITextPanel2.Height.Set(50f, 0f);
73 uITextPanel2.VAlign = 1f;
74 uITextPanel2.HAlign = 0.5f;
75 uITextPanel2.Top.Set(-45f, 0f);
76 uITextPanel2.OnMouseOver += FadedMouseOver;
77 uITextPanel2.OnMouseOut += FadedMouseOut;
78 uITextPanel2.OnLeftClick += GoBackClick;
79 uIElement.Append(uITextPanel2);
82 }
83
84 public override void Recalculate()
85 {
86 if (_scrollbar != null)
87 {
89 {
92 _entryList.Width.Set(0f, 1f);
93 }
95 {
98 _entryList.Width.Set(-25f, 1f);
99 }
100 }
101 base.Recalculate();
102 }
103
108
110 {
112 Main.MenuUI.SetState(_menuToGoBackTo);
113 }
114
116 {
118 ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171);
119 ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
120 }
121
123 {
124 ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f;
125 ((UIPanel)evt.Target).BorderColor = Color.Black;
126 }
127
128 public override void OnActivate()
129 {
132 {
133 UILinkPointNavigator.ChangePoint(3000 + ((_entryList.Count != 0) ? 1 : 0));
134 }
135 }
136
137 public void PopulateEntries()
138 {
139 _entries.Clear();
141 where x.Branding == ResourcePack.BrandingType.None
142 orderby x.IsCompressed
143 select x;
144 _entries.AddRange(collection);
146 int num = 0;
147 foreach (ResourcePack entry in _entries)
148 {
149 _entryList.Add(new UIWorkshopPublishResourcePackListItem(this, entry, num++, !entry.IsCompressed));
150 }
151 }
152
153 public override void Draw(SpriteBatch spriteBatch)
154 {
155 if (skipDraw)
156 {
157 skipDraw = false;
158 return;
159 }
160 base.Draw(spriteBatch);
161 SetupGamepadPoints(spriteBatch);
162 }
163
164 private void SetupGamepadPoints(SpriteBatch spriteBatch)
165 {
166 UILinkPointNavigator.Shortcuts.BackButtonCommand = 7;
167 int num = 3000;
168 UILinkPointNavigator.SetPosition(num, _backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
169 int num2 = num;
171 uILinkPoint.Unlink();
172 uILinkPoint.Right = num2;
173 float num3 = 1f / Main.UIScale;
176 Vector2 maximum = clippingRectangle.BottomRight() * num3;
178 for (int i = 0; i < snapPoints.Count; i++)
179 {
180 if (!snapPoints[i].Position.Between(minimum, maximum))
181 {
183 i--;
184 }
185 }
186 int num4 = 1;
187 SnapPoint[,] array = new SnapPoint[_entryList.Count, num4];
188 foreach (SnapPoint item in snapPoints.Where((SnapPoint a) => a.Name == "Publish"))
189 {
190 array[item.Id, 0] = item;
191 }
192 num2 = num + 1;
193 int[] array2 = new int[_entryList.Count];
194 for (int j = 0; j < array2.Length; j++)
195 {
196 array2[j] = -1;
197 }
198 for (int k = 0; k < num4; k++)
199 {
200 int num5 = -1;
201 for (int l = 0; l < array.GetLength(0); l++)
202 {
203 if (array[l, k] != null)
204 {
206 uILinkPoint.Unlink();
208 if (num5 != -1)
209 {
210 uILinkPoint.Up = num5;
212 }
213 if (array2[l] != -1)
214 {
215 uILinkPoint.Left = array2[l];
217 }
218 uILinkPoint.Down = num;
219 if (k == 0)
220 {
222 }
223 num5 = num2;
224 array2[l] = num2;
225 UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num2;
226 num2++;
227 }
228 }
229 }
231 {
233 }
234 }
235}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void AddRange(IEnumerable< T > collection)
Definition List.cs:275
static void PlaySound(int type, Vector2 position, int style=1)
virtual void Add(UIElement item)
Definition UIList.cs:82
void SetScrollbar(UIScrollbar scrollbar)
Definition UIList.cs:141
void SetView(float viewSize, float maxViewSize)
static readonly Color FancyUIFatButtonMouseOver
Definition Colors.cs:91
static ResourcePackList CreatePublishableResourcePacksList(IServiceProvider services)
static LocalizedText GetText(string key)
Definition Language.cs:10
static UserInterface MenuUI
Definition Main.cs:381
static float UIScale
Definition Main.cs:2624
static Main instance
Definition Main.cs:283
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
StyleDimension Width
Definition UIElement.cs:27
void RemoveChild(UIElement child)
Definition UIElement.cs:182
virtual List< SnapPoint > GetSnapPoints()
Definition UIElement.cs:267
Rectangle GetClippingRectangle(SpriteBatch spriteBatch)
Definition UIElement.cs:246
void Set(float pixels, float precent)