Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIResourcePackInfoMenu.cs
Go to the documentation of this file.
7using Terraria.ID;
8using Terraria.IO;
10using Terraria.UI;
12
14
16{
18
20
22
23 private UIList _list;
24
26
28
29 private const string _backPointName = "GoBack";
30
32
34 {
35 _resourceMenu = parent;
36 _pack = pack;
37 BuildPage();
38 }
39
40 private void BuildPage()
41 {
44 uIElement.Width.Set(0f, 0.8f);
45 uIElement.MaxWidth.Set(500f, 0f);
46 uIElement.MinWidth.Set(300f, 0f);
47 uIElement.Top.Set(230f, 0f);
48 uIElement.Height.Set(0f - uIElement.Top.Pixels, 1f);
49 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 {
60 };
61 uIPanel.Append(uIElement2);
63 {
64 Width = new StyleDimension(0f, 1f),
65 Height = new StyleDimension(52f, 0f)
66 };
67 uIElement3.SetPadding(0f);
68 uIElement2.Append(uIElement3);
69 UIText uIText = new UIText(_pack.Name, 0.7f, large: true)
70 {
71 TextColor = Color.Gold
72 };
73 uIText.HAlign = 0.5f;
74 uIText.VAlign = 0f;
75 uIElement3.Append(uIText);
76 UIText uIText2 = new UIText(Language.GetTextValue("UI.Author", _pack.Author), 0.9f)
77 {
78 HAlign = 0f,
79 VAlign = 1f
80 };
81 uIText2.Top.Set(-6f, 0f);
82 uIElement3.Append(uIText2);
84 {
85 HAlign = 1f,
86 VAlign = 1f,
87 TextColor = Color.Silver
88 };
89 uIText3.Top.Set(-6f, 0f);
90 uIElement3.Append(uIText3);
91 Asset<Texture2D> val = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode)1);
92 UIImage uIImage = new UIImage(val)
93 {
95 Height = StyleDimension.FromPixels(val.Height()),
96 ScaleToFit = true
97 };
98 uIImage.Top.Set(52f, 0f);
99 uIImage.SetPadding(6f);
100 uIElement2.Append(uIImage);
102 {
103 HAlign = 0.5f,
104 VAlign = 1f,
107 };
108 uIElement2.Append(uIElement4);
110 UIText item = new UIText(_pack.Description)
111 {
112 HAlign = 0.5f,
113 VAlign = 0f,
116 IsWrapped = true,
117 WrappedTextBottomPadding = 0f
118 };
119 UIList uIList = new UIList
120 {
121 HAlign = 0.5f,
122 VAlign = 0f,
125 PaddingRight = 20f
126 };
127 uIList.ListPadding = 5f;
128 uIList.Add(item);
129 uIElement4.Append(uIList);
130 _list = uIList;
132 uIScrollbar.SetView(100f, 1000f);
133 uIScrollbar.Height.Set(0f, 1f);
134 uIScrollbar.HAlign = 1f;
136 uIList.SetScrollbar(uIScrollbar);
138 uITextPanel.Width.Set(-10f, 0.5f);
139 uITextPanel.Height.Set(50f, 0f);
140 uITextPanel.VAlign = 1f;
141 uITextPanel.HAlign = 0.5f;
142 uITextPanel.Top.Set(-45f, 0f);
143 uITextPanel.OnMouseOver += FadedMouseOver;
144 uITextPanel.OnMouseOut += FadedMouseOut;
145 uITextPanel.OnLeftClick += GoBackClick;
146 uITextPanel.SetSnapPoint("GoBack", 0);
147 uIElement.Append(uITextPanel);
148 }
149
150 public override void Recalculate()
151 {
152 if (_scrollbar != null)
153 {
155 {
157 _isScrollbarAttached = false;
158 _list.Width.Set(0f, 1f);
159 }
161 {
164 _list.Width.Set(-25f, 1f);
165 }
166 }
167 base.Recalculate();
168 }
169
174
176 {
178 ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171);
179 ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
180 }
181
183 {
184 ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.8f;
185 ((UIPanel)evt.Target).BorderColor = Color.Black;
186 }
187
188 public override void Draw(SpriteBatch spriteBatch)
189 {
190 base.Draw(spriteBatch);
191 SetupGamepadPoints(spriteBatch);
192 }
193
194 private void SetupGamepadPoints(SpriteBatch spriteBatch)
195 {
196 UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
197 int num = 3000;
198 int idRangeEndExclusive = num;
200 for (int i = 0; i < snapPoints.Count; i++)
201 {
203 string name = snapPoint.Name;
204 if (name == "GoBack")
205 {
207 }
208 }
210 }
211}
void Add(TKey key, TValue value)
static void PlaySound(int type, Vector2 position, int style=1)
static void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
UIResourcePackInfoMenu(UIResourcePackSelectionMenu parent, ResourcePack pack)
static void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
static readonly Color FancyUIFatButtonMouseOver
Definition Colors.cs:91
ResourcePackVersion Version
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 Width
Definition UIElement.cs:27
void RemoveChild(UIElement child)
Definition UIElement.cs:182
virtual List< SnapPoint > GetSnapPoints()
Definition UIElement.cs:267
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)