Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIWorkshopSelectWorldToPublish.cs
Go to the documentation of this file.
2using System.Linq;
8using Terraria.ID;
9using Terraria.IO;
11using Terraria.UI;
13
15
17{
19
21
23
25
27
29
30 private bool skipDraw;
31
36
37 public override void OnInitialize()
38 {
40 uIElement.Width.Set(0f, 0.8f);
41 uIElement.MaxWidth.Set(650f, 0f);
42 uIElement.Top.Set(220f, 0f);
43 uIElement.Height.Set(-220f, 1f);
44 uIElement.HAlign = 0.5f;
45 UIPanel uIPanel = new UIPanel();
46 uIPanel.Width.Set(0f, 1f);
47 uIPanel.Height.Set(-110f, 1f);
48 uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
49 uIElement.Append(uIPanel);
51 _entryList = new UIList();
52 _entryList.Width.Set(0f, 1f);
53 _entryList.Height.Set(0f, 1f);
54 _entryList.ListPadding = 5f;
55 uIPanel.Append(_entryList);
56 _scrollbar = new UIScrollbar();
57 _scrollbar.SetView(100f, 1000f);
58 _scrollbar.Height.Set(0f, 1f);
59 _scrollbar.HAlign = 1f;
61 UITextPanel<LocalizedText> uITextPanel = new UITextPanel<LocalizedText>(Language.GetText("UI.WorkshopSelectWorldToPublishMenuTitle"), 0.8f, large: true);
62 uITextPanel.HAlign = 0.5f;
63 uITextPanel.Top.Set(-40f, 0f);
64 uITextPanel.SetPadding(15f);
65 uITextPanel.BackgroundColor = new Color(73, 94, 171);
66 uIElement.Append(uITextPanel);
68 uITextPanel2.Width.Set(-10f, 0.5f);
69 uITextPanel2.Height.Set(50f, 0f);
70 uITextPanel2.VAlign = 1f;
71 uITextPanel2.HAlign = 0.5f;
72 uITextPanel2.Top.Set(-45f, 0f);
73 uITextPanel2.OnMouseOver += FadedMouseOver;
74 uITextPanel2.OnMouseOut += FadedMouseOut;
75 uITextPanel2.OnLeftClick += GoBackClick;
76 uIElement.Append(uITextPanel2);
79 }
80
81 public override void Recalculate()
82 {
83 if (_scrollbar != null)
84 {
86 {
89 _entryList.Width.Set(0f, 1f);
90 }
92 {
95 _entryList.Width.Set(-25f, 1f);
96 }
97 }
98 base.Recalculate();
99 }
100
105
107 {
109 Main.MenuUI.SetState(_menuToGoBackTo);
110 }
111
113 {
115 ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171);
116 ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
117 }
118
120 {
121 ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f;
122 ((UIPanel)evt.Target).BorderColor = Color.Black;
123 }
124
125 public override void OnActivate()
126 {
129 {
130 UILinkPointNavigator.ChangePoint(3000 + ((_entryList.Count != 0) ? 1 : 0));
131 }
132 }
133
134 private void PopulateEntries()
135 {
139 orderby x.IsFavorite descending, x.Name, x.GetFileName()
140 select x;
142 int num = 0;
143 foreach (WorldFileData item in orderedEnumerable)
144 {
145 _entryList.Add(new UIWorkshopPublishWorldListItem(this, item, num++));
146 }
147 }
148
149 public override void Draw(SpriteBatch spriteBatch)
150 {
151 if (skipDraw)
152 {
153 skipDraw = false;
154 return;
155 }
156 base.Draw(spriteBatch);
157 SetupGamepadPoints(spriteBatch);
158 }
159
160 private void SetupGamepadPoints(SpriteBatch spriteBatch)
161 {
162 UILinkPointNavigator.Shortcuts.BackButtonCommand = 7;
163 int num = 3000;
164 UILinkPointNavigator.SetPosition(num, _backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
165 int num2 = num;
167 uILinkPoint.Unlink();
168 uILinkPoint.Right = num2;
169 float num3 = 1f / Main.UIScale;
172 Vector2 maximum = clippingRectangle.BottomRight() * num3;
174 for (int i = 0; i < snapPoints.Count; i++)
175 {
176 if (!snapPoints[i].Position.Between(minimum, maximum))
177 {
179 i--;
180 }
181 }
182 int num4 = 1;
183 SnapPoint[,] array = new SnapPoint[_entryList.Count, num4];
184 foreach (SnapPoint item in snapPoints.Where((SnapPoint a) => a.Name == "Publish"))
185 {
186 array[item.Id, 0] = item;
187 }
188 num2 = num + 1;
189 int[] array2 = new int[_entryList.Count];
190 for (int j = 0; j < array2.Length; j++)
191 {
192 array2[j] = -1;
193 }
194 for (int k = 0; k < num4; k++)
195 {
196 int num5 = -1;
197 for (int l = 0; l < array.GetLength(0); l++)
198 {
199 if (array[l, k] != null)
200 {
202 uILinkPoint.Unlink();
204 if (num5 != -1)
205 {
206 uILinkPoint.Up = num5;
208 }
209 if (array2[l] != -1)
210 {
211 uILinkPoint.Left = array2[l];
213 }
214 uILinkPoint.Down = num;
215 if (k == 0)
216 {
218 }
219 num5 = num2;
220 array2[l] = num2;
221 UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num2;
222 num2++;
223 }
224 }
225 }
227 {
229 }
230 }
231}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
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)
void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
static readonly Color FancyUIFatButtonMouseOver
Definition Colors.cs:91
static LocalizedText GetText(string key)
Definition Language.cs:10
static List< WorldFileData > WorldList
Definition Main.cs:1944
static void LoadWorlds()
Definition Main.cs:3642
static UserInterface MenuUI
Definition Main.cs:381
static float UIScale
Definition Main.cs:2624
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)