Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIWorkshopWorldImport.cs
Go to the documentation of this file.
1using System;
3using System.Linq;
9using Terraria.ID;
10using Terraria.IO;
12using Terraria.Social;
13using Terraria.UI;
15
17
19{
21
23
25
27
29
31
33
35
36 private bool skipDraw;
37
42
43 public override void OnInitialize()
44 {
46 uIElement.Width.Set(0f, 0.8f);
47 uIElement.MaxWidth.Set(650f, 0f);
48 uIElement.Top.Set(220f, 0f);
49 uIElement.Height.Set(-220f, 1f);
50 uIElement.HAlign = 0.5f;
51 UIPanel uIPanel = new UIPanel();
52 uIPanel.Width.Set(0f, 1f);
53 uIPanel.Height.Set(-110f, 1f);
54 uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
55 uIElement.Append(uIPanel);
57 _worldList = new UIList();
58 _worldList.Width.Set(0f, 1f);
59 _worldList.Height.Set(0f, 1f);
60 _worldList.ListPadding = 5f;
61 uIPanel.Append(_worldList);
62 _scrollbar = new UIScrollbar();
63 _scrollbar.SetView(100f, 1000f);
64 _scrollbar.Height.Set(0f, 1f);
65 _scrollbar.HAlign = 1f;
67 UITextPanel<LocalizedText> uITextPanel = new UITextPanel<LocalizedText>(Language.GetText("UI.WorkshopImportWorld"), 0.8f, large: true);
68 uITextPanel.HAlign = 0.5f;
69 uITextPanel.Top.Set(-40f, 0f);
70 uITextPanel.SetPadding(15f);
71 uITextPanel.BackgroundColor = new Color(73, 94, 171);
72 uIElement.Append(uITextPanel);
74 uITextPanel2.Width.Set(-10f, 0.5f);
75 uITextPanel2.Height.Set(50f, 0f);
76 uITextPanel2.VAlign = 1f;
77 uITextPanel2.HAlign = 0.5f;
78 uITextPanel2.Top.Set(-45f, 0f);
79 uITextPanel2.OnMouseOver += FadedMouseOver;
80 uITextPanel2.OnMouseOut += FadedMouseOut;
81 uITextPanel2.OnLeftClick += GoBackClick;
82 uIElement.Append(uITextPanel2);
85 }
86
87 public override void Recalculate()
88 {
89 if (_scrollbar != null)
90 {
92 {
95 _worldList.Width.Set(0f, 1f);
96 }
98 {
101 _worldList.Width.Set(-25f, 1f);
102 }
103 }
104 base.Recalculate();
105 }
106
111
113 {
116 }
117
119 {
121 ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171);
122 ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
123 }
124
126 {
127 ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f;
128 ((UIPanel)evt.Target).BorderColor = Color.Black;
129 }
130
131 public override void OnActivate()
132 {
137 {
138 UILinkPointNavigator.ChangePoint(3000 + ((_worldList.Count == 0) ? 1 : 2));
139 }
140 }
141
143 {
144 WorkshopWorldList.Clear();
145 if (SocialAPI.Workshop == null)
146 {
147 return;
148 }
149 foreach (string listOfSubscribedWorldPath in SocialAPI.Workshop.GetListOfSubscribedWorldPaths())
150 {
152 if (allMetadata != null)
153 {
155 }
156 else
157 {
159 }
160 }
161 }
162
163 private void UpdateWorldsList()
164 {
167 orderby x.IsFavorite descending, x.Name, x.GetFileName()
168 select x;
169 int num = 0;
171 {
173 }
174 }
175
176 public override void Draw(SpriteBatch spriteBatch)
177 {
178 if (skipDraw)
179 {
180 skipDraw = false;
181 return;
182 }
183 base.Draw(spriteBatch);
184 SetupGamepadPoints(spriteBatch);
185 }
186
187 private void SetupGamepadPoints(SpriteBatch spriteBatch)
188 {
189 UILinkPointNavigator.Shortcuts.BackButtonCommand = 7;
190 int num = 3000;
191 UILinkPointNavigator.SetPosition(num, _backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
192 int key = num;
194 uILinkPoint.Unlink();
195 float num2 = 1f / Main.UIScale;
198 Vector2 maximum = clippingRectangle.BottomRight() * num2;
200 for (int i = 0; i < snapPoints.Count; i++)
201 {
202 if (!snapPoints[i].Position.Between(minimum, maximum))
203 {
205 i--;
206 }
207 }
209 foreach (SnapPoint item in snapPoints.Where((SnapPoint a) => a.Name == "Import"))
210 {
211 array[item.Id, 0] = item;
212 }
213 key = num + 2;
214 int[] array2 = new int[_worldList.Count];
215 for (int j = 0; j < array2.Length; j++)
216 {
217 array2[j] = -1;
218 }
219 for (int k = 0; k < 1; k++)
220 {
221 int num3 = -1;
222 for (int l = 0; l < array.GetLength(0); l++)
223 {
224 if (array[l, k] != null)
225 {
227 uILinkPoint.Unlink();
229 if (num3 != -1)
230 {
231 uILinkPoint.Up = num3;
233 }
234 if (array2[l] != -1)
235 {
236 uILinkPoint.Left = array2[l];
238 }
239 uILinkPoint.Down = num;
240 if (k == 0)
241 {
243 }
244 num3 = key;
245 array2[l] = key;
246 UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = key;
247 key++;
248 }
249 }
250 }
252 {
254 }
255 }
256}
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 GoBackClick(UIMouseEvent evt, UIElement listeningElement)
void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
static readonly Color FancyUIFatButtonMouseOver
Definition Colors.cs:91
static WorldFileData FromInvalidWorld(string path, bool cloudSave)
static WorldFileData GetAllMetadata(string file, bool cloudSave)
Definition WorldFile.cs:243
static LocalizedText GetText(string key)
Definition Language.cs:10
static void LoadWorlds()
Definition Main.cs:3642
static UserInterface MenuUI
Definition Main.cs:381
static float UIScale
Definition Main.cs:2624
static Terraria.Social.Base.WorkshopSocialModule Workshop
Definition SocialAPI.cs:24
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)