Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
UIReportsPage.cs
Go to the documentation of this file.
2using System.Linq;
9using Terraria.ID;
11using Terraria.UI;
13
15
16public class UIReportsPage : UIState
17{
19
20 private int _menuIdToGoBackTo;
21
23
24 private UIList _list;
25
27
29
30 private const string _backPointName = "GoBack";
31
33
35
42
43 public override void OnInitialize()
44 {
45 BuildPage();
46 }
47
48 private void BuildPage()
49 {
52 uIElement.Width.Set(0f, 0.8f);
53 uIElement.MaxWidth.Set(500f, 0f);
54 uIElement.MinWidth.Set(300f, 0f);
55 uIElement.Top.Set(230f, 0f);
56 uIElement.Height.Set(0f - uIElement.Top.Pixels, 1f);
57 uIElement.HAlign = 0.5f;
59 UIPanel uIPanel = new UIPanel();
60 uIPanel.Width.Set(0f, 1f);
61 uIPanel.Height.Set(-110f, 1f);
62 uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
63 uIElement.Append(uIPanel);
65 {
68 };
69 uIPanel.Append(uIElement2);
71 {
72 Width = new StyleDimension(0f, 1f),
73 Height = new StyleDimension(28f, 0f)
74 };
75 uIElement3.SetPadding(0f);
76 uIElement2.Append(uIElement3);
77 UIText uIText = new UIText(Language.GetTextValue("UI.ReportsPage"), 0.7f, large: true);
78 uIText.HAlign = 0.5f;
79 uIText.VAlign = 0f;
80 uIElement3.Append(uIText);
82 {
83 HAlign = 0.5f,
84 VAlign = 1f,
87 Top = new StyleDimension(-2f, 0f)
88 };
89 uIElement2.Append(uIElement4);
91 float num = 0f;
92 UISlicedImage uISlicedImage = new UISlicedImage(Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode)1))
93 {
94 HAlign = 0.5f,
95 VAlign = 1f,
96 Width = StyleDimension.FromPixelsAndPercent((0f - num) * 2f, 1f),
97 Left = StyleDimension.FromPixels(0f - num),
100 };
101 uISlicedImage.SetSliceDepths(10);
102 uISlicedImage.Color = Color.LightGray * 0.5f;
104 UIList uIList = new UIList
105 {
106 HAlign = 0.5f,
107 VAlign = 0f,
110 PaddingRight = 20f
111 };
112 uIList.ListPadding = 40f;
113 uIList.ManualSortMethod = ManualIfnoSortingMethod;
114 UIElement item = new UIElement();
115 uIList.Add(item);
117 uIElement4.Append(uIList);
118 _list = uIList;
120 uIScrollbar.SetView(100f, 1000f);
121 uIScrollbar.Height.Set(0f, 1f);
122 uIScrollbar.HAlign = 1f;
124 uIList.SetScrollbar(uIScrollbar);
125 uIScrollbar.GoToBottom();
127 uITextPanel.Width.Set(-10f, 0.5f);
128 uITextPanel.Height.Set(50f, 0f);
129 uITextPanel.VAlign = 1f;
130 uITextPanel.HAlign = 0.5f;
131 uITextPanel.Top.Set(-45f, 0f);
132 uITextPanel.OnMouseOver += FadedMouseOver;
133 uITextPanel.OnMouseOut += FadedMouseOut;
134 uITextPanel.OnLeftClick += GoBackClick;
135 uITextPanel.SetSnapPoint("GoBack", 0);
136 uIElement.Append(uITextPanel);
137 }
138
140 {
141 }
142
144 {
145 List<IssueReport> list = (from report in _reporters.SelectMany((IProvideReports reporter) => reporter.GetReports())
146 orderby report.timeReported
147 select report).ToList();
148 if (list.Count == 0)
149 {
150 UIText item = new UIText(Language.GetTextValue("Workshop.ReportLogsInitialMessage"))
151 {
152 HAlign = 0f,
153 VAlign = 0f,
156 IsWrapped = true,
157 WrappedTextBottomPadding = 0f,
158 TextOriginX = 0.5f,
159 TextColor = Color.Gray
160 };
161 listContents.Add(item);
162 }
163 for (int i = 0; i < list.Count; i++)
164 {
165 UIText uIText = new UIText(list[i].reportText)
166 {
167 HAlign = 0f,
168 VAlign = 0f,
171 IsWrapped = true,
172 WrappedTextBottomPadding = 0f,
173 TextOriginX = 0f
174 };
176 Asset<Texture2D> val = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode)1);
177 UIImage element = new UIImage(val)
178 {
180 Height = StyleDimension.FromPixels(val.Height()),
181 ScaleToFit = true,
182 VAlign = 1f
183 };
184 uIText.Append(element);
185 }
186 UIElement item2 = new UIElement();
188 }
189
190 public override void Recalculate()
191 {
192 if (_scrollbar != null)
193 {
195 {
197 _isScrollbarAttached = false;
198 _list.Width.Set(0f, 1f);
199 }
201 {
204 _list.Width.Set(-25f, 1f);
205 }
206 }
207 base.Recalculate();
208 }
209
211 {
212 Main.MenuUI.SetState(_previousUIState);
214 Main.menuMode = _menuIdToGoBackTo;
215 }
216
218 {
220 ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171);
221 ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
222 }
223
225 {
226 ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.8f;
227 ((UIPanel)evt.Target).BorderColor = Color.Black;
228 }
229
230 public override void Draw(SpriteBatch spriteBatch)
231 {
232 base.Draw(spriteBatch);
233 SetupGamepadPoints(spriteBatch);
234 }
235
236 private void SetupGamepadPoints(SpriteBatch spriteBatch)
237 {
238 UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
239 int num = 3000;
240 int idRangeEndExclusive = num;
242 for (int i = 0; i < snapPoints.Count; i++)
243 {
245 string name = snapPoint.Name;
246 if (name == "GoBack")
247 {
249 }
250 }
252 }
253}
void Add(TKey key, TValue value)
static void PlaySound(int type, Vector2 position, int style=1)
void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
void SetupGamepadPoints(SpriteBatch spriteBatch)
void ManualIfnoSortingMethod(List< UIElement > list)
static void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
override void Draw(SpriteBatch spriteBatch)
static void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
UIReportsPage(UIState stateToGoBackTo, int menuIdToGoBackTo, List< IProvideReports > reporters)
static readonly Color FancyUIFatButtonMouseOver
Definition Colors.cs:91
static LocalizedText GetText(string key)
Definition Language.cs:10
static string GetTextValue(string key)
Definition Language.cs:15
static UserInterface MenuUI
Definition Main.cs:381
static IAssetRepository Assets
Definition Main.cs:209
StyleDimension Height
Definition UIElement.cs:29
void Append(UIElement element)
Definition UIElement.cs:166
StyleDimension Left
Definition UIElement.cs:25
StyleDimension Width
Definition UIElement.cs:27
void RemoveChild(UIElement child)
Definition UIElement.cs:182
virtual List< SnapPoint > GetSnapPoints()
Definition UIElement.cs:267
StyleDimension Top
Definition UIElement.cs:23
UILinkPoint MakeLinkPointFromSnapPoint(int id, SnapPoint snap)
void MoveToVisuallyClosestPoint(List< UILinkPoint > lostrefpoints)
static StyleDimension Fill
static StyleDimension FromPixels(float pixels)
void Set(float pixels, float precent)
static StyleDimension FromPixelsAndPercent(float pixels, float percent)