Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIAchievementsMenu.cs
Go to the documentation of this file.
9using Terraria.ID;
11using Terraria.UI;
13
15
17{
19
21
23
25
27
28 public void InitializePage()
29 {
33 _achievementsList = null;
34 bool flag = true;
35 int num = flag.ToInt() * 100;
37 uIElement.Width.Set(0f, 0.8f);
38 uIElement.MaxWidth.Set(800f + (float)num, 0f);
39 uIElement.MinWidth.Set(600f + (float)num, 0f);
40 uIElement.Top.Set(220f, 0f);
41 uIElement.Height.Set(-220f, 1f);
42 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 uIPanel.PaddingTop = 0f;
50 uIElement.Append(uIPanel);
52 _achievementsList.Width.Set(-25f, 1f);
54 _achievementsList.Top.Set(50f, 0f);
55 _achievementsList.ListPadding = 5f;
58 uITextPanel.HAlign = 0.5f;
59 uITextPanel.Top.Set(-33f, 0f);
60 uITextPanel.SetPadding(13f);
61 uITextPanel.BackgroundColor = new Color(73, 94, 171);
62 uIElement.Append(uITextPanel);
64 uITextPanel2.Width.Set(-10f, 0.5f);
65 uITextPanel2.Height.Set(50f, 0f);
66 uITextPanel2.VAlign = 1f;
67 uITextPanel2.HAlign = 0.5f;
68 uITextPanel2.Top.Set(-45f, 0f);
69 uITextPanel2.OnMouseOver += FadedMouseOver;
70 uITextPanel2.OnMouseOut += FadedMouseOut;
71 uITextPanel2.OnLeftClick += GoBackClick;
72 uIElement.Append(uITextPanel2);
74 List<Achievement> list = Main.Achievements.CreateAchievementsList();
75 for (int i = 0; i < list.Count; i++)
76 {
77 UIAchievementListItem item = new UIAchievementListItem(list[i], flag);
80 }
82 uIScrollbar.SetView(100f, 1000f);
83 uIScrollbar.Height.Set(-50f, 1f);
84 uIScrollbar.Top.Set(50f, 0f);
85 uIScrollbar.HAlign = 1f;
86 uIPanel.Append(uIScrollbar);
89 uIElement2.Width.Set(0f, 1f);
90 uIElement2.Height.Set(32f, 0f);
91 uIElement2.Top.Set(10f, 0f);
92 Asset<Texture2D> texture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Categories", (AssetRequestMode)1);
93 for (int j = 0; j < 4; j++)
94 {
95 UIToggleImage uIToggleImage = new UIToggleImage(texture, 32, 32, new Point(34 * j, 0), new Point(34 * j, 34));
96 uIToggleImage.Left.Set(j * 36 + 8, 0f);
97 uIToggleImage.SetState(value: true);
98 uIToggleImage.OnLeftClick += FilterList;
101 }
102 uIPanel.Append(uIElement2);
103 }
104
105 public override void Draw(SpriteBatch spriteBatch)
106 {
107 base.Draw(spriteBatch);
108 for (int i = 0; i < _categoryButtons.Count; i++)
109 {
111 {
112 string text = "";
113 text = i switch
114 {
115 3 => Language.GetTextValue("Achievements.ChallengerCategory"),
116 1 => Language.GetTextValue("Achievements.CollectorCategory"),
117 2 => Language.GetTextValue("Achievements.ExplorerCategory"),
118 0 => Language.GetTextValue("Achievements.SlayerCategory"),
119 -1 => Language.GetTextValue("Achievements.NoCategory"),
120 _ => Language.GetTextValue("Achievements.NoCategory"),
121 };
122 float x = FontAssets.MouseText.Value.MeasureString(text).X;
123 Vector2 vector = new Vector2(Main.mouseX, Main.mouseY) + new Vector2(16f);
124 if (vector.Y > (float)(Main.screenHeight - 30))
125 {
126 vector.Y = Main.screenHeight - 30;
127 }
128 if (vector.X > (float)Main.screenWidth - x)
129 {
130 vector.X = Main.screenWidth - 460;
131 }
133 break;
134 }
135 }
136 SetupGamepadPoints(spriteBatch);
137 }
138
139 public void GotoAchievement(Achievement achievement)
140 {
141 _achievementsList.Goto((UIElement element) => element is UIAchievementListItem uIAchievementListItem && uIAchievementListItem.GetAchievement() == achievement);
142 }
143
145 {
146 Main.menuMode = 0;
148 }
149
151 {
153 ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171);
154 ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
155 }
156
158 {
159 ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.8f;
160 ((UIPanel)evt.Target).BorderColor = Color.Black;
161 }
162
164 {
168 {
169 if (_categoryButtons[(int)achievementElement.GetAchievement().Category].IsOn)
170 {
172 }
173 }
174 Recalculate();
175 }
176
177 public override void OnActivate()
178 {
180 if (Main.gameMenu)
181 {
182 _outerContainer.Top.Set(220f, 0f);
183 _outerContainer.Height.Set(-220f, 1f);
184 }
185 else
186 {
187 _outerContainer.Top.Set(120f, 0f);
188 _outerContainer.Height.Set(-120f, 1f);
189 }
192 {
194 }
195 }
196
197 private void SetupGamepadPoints(SpriteBatch spriteBatch)
198 {
199 UILinkPointNavigator.Shortcuts.BackButtonCommand = 3;
200 int num = 3000;
203 int num2 = num;
205 uILinkPoint.Unlink();
206 uILinkPoint.Up = num2 + 1;
207 num2++;
209 uILinkPoint2.Unlink();
210 uILinkPoint2.Up = num2 + 1;
211 uILinkPoint2.Down = num2 - 1;
212 for (int i = 0; i < _categoryButtons.Count; i++)
213 {
214 num2 = (UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num2 + 1);
217 uILinkPoint3.Unlink();
218 uILinkPoint3.Left = ((i == 0) ? (-3) : (num2 - 1));
219 uILinkPoint3.Right = ((i == _categoryButtons.Count - 1) ? (-4) : (num2 + 1));
220 uILinkPoint3.Down = num;
221 }
222 }
223}
static void PlaySound(int type, Vector2 position, int style=1)
static Asset< DynamicSpriteFont > MouseText
Definition FontAssets.cs:10
virtual void Add(UIElement item)
Definition UIList.cs:82
void SetScrollbar(UIScrollbar scrollbar)
Definition UIList.cs:141
void Goto(ElementSearchMethod searchMethod)
Definition UIList.cs:70
override void Draw(SpriteBatch spriteBatch)
void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
void FilterList(UIMouseEvent evt, UIElement listeningElement)
void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
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 AchievementManager Achievements
Definition Main.cs:2756
static int screenHeight
Definition Main.cs:1721
static byte mouseTextColor
Definition Main.cs:1751
static int screenWidth
Definition Main.cs:1719
static int mouseY
Definition Main.cs:606
static IAssetRepository Assets
Definition Main.cs:209
static bool gameMenu
Definition Main.cs:1926
static int mouseX
Definition Main.cs:604
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
CalculatedStyle GetInnerDimensions()
Definition UIElement.cs:377
StyleDimension Width
Definition UIElement.cs:27
virtual void Recalculate()
Definition UIElement.cs:281
StyleDimension Top
Definition UIElement.cs:23
static void DrawBorderStringFourWay(SpriteBatch sb, DynamicSpriteFont font, string text, float x, float y, Color textColor, Color borderColor, Vector2 origin, float scale=1f)
Definition Utils.cs:1857
void Set(float pixels, float precent)