Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AWorldListItem.cs
Go to the documentation of this file.
4using Terraria.IO;
6using Terraria.UI;
7
9
10public abstract class AWorldListItem : UIPanel
11{
13
14 protected int _glitchFrameCounter;
15
16 protected int _glitchFrame;
17
18 protected int _glitchVariation;
19
20 private void UpdateGlitchAnimation(UIElement affectedElement)
21 {
22 _ = _glitchFrame;
23 int minValue = 3;
24 int num = 3;
25 if (_glitchFrame == 0)
26 {
27 minValue = 15;
28 num = 120;
29 }
30 if (++_glitchFrameCounter >= Main.rand.Next(minValue, num + 1))
31 {
33 _glitchFrame = (_glitchFrame + 1) % 16;
34 if ((_glitchFrame == 4 || _glitchFrame == 8 || _glitchFrame == 12) && Main.rand.Next(3) == 0)
35 {
36 _glitchVariation = Main.rand.Next(7);
37 }
38 }
39 (affectedElement as UIImageFramed).SetFrame(7, 16, _glitchVariation, _glitchFrame, 0, 0);
40 }
41
42 protected void GetDifficulty(out string expertText, out Color gameModeColor)
43 {
44 expertText = "";
45 gameModeColor = Color.White;
46 if (_data.GameMode == 3)
47 {
48 expertText = Language.GetTextValue("UI.Creative");
49 gameModeColor = Main.creativeModeColor;
50 return;
51 }
52 int num = 1;
53 switch (_data.GameMode)
54 {
55 case 1:
56 num = 2;
57 break;
58 case 2:
59 num = 3;
60 break;
61 }
63 {
64 num++;
65 }
66 switch (num)
67 {
68 default:
69 expertText = Language.GetTextValue("UI.Normal");
70 break;
71 case 2:
72 expertText = Language.GetTextValue("UI.Expert");
73 gameModeColor = Main.mcColor;
74 break;
75 case 3:
76 expertText = Language.GetTextValue("UI.Master");
77 gameModeColor = Main.hcColor;
78 break;
79 case 4:
80 expertText = Language.GetTextValue("UI.Legendary");
81 gameModeColor = Main.legendaryModeColor;
82 break;
83 }
84 }
85
87 {
89 {
90 return Main.Assets.Request<Texture2D>("Images/UI/Icon" + (_data.IsHardMode ? "Hallow" : "") + "Everything", (AssetRequestMode)1);
91 }
92 if (_data.DrunkWorld)
93 {
94 return Main.Assets.Request<Texture2D>("Images/UI/Icon" + (_data.IsHardMode ? "Hallow" : "") + "CorruptionCrimson", (AssetRequestMode)1);
95 }
97 {
98 return GetSeedIcon("FTW");
99 }
100 if (_data.NotTheBees)
101 {
102 return GetSeedIcon("NotTheBees");
103 }
104 if (_data.Anniversary)
105 {
106 return GetSeedIcon("Anniversary");
107 }
108 if (_data.DontStarve)
109 {
110 return GetSeedIcon("DontStarve");
111 }
112 if (_data.RemixWorld)
113 {
114 return GetSeedIcon("Remix");
115 }
117 {
118 return GetSeedIcon("Traps");
119 }
120 return Main.Assets.Request<Texture2D>("Images/UI/Icon" + (_data.IsHardMode ? "Hallow" : "") + (_data.HasCorruption ? "Corruption" : "Crimson"), (AssetRequestMode)1);
121 }
122
124 {
126 {
127 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/IconEverythingAnimated", (AssetRequestMode)1);
128 UIImageFramed uIImageFramed = new UIImageFramed(obj, obj.Frame(7, 16));
129 uIImageFramed.Left = new StyleDimension(4f, 0f);
130 uIImageFramed.OnUpdate += UpdateGlitchAnimation;
131 return uIImageFramed;
132 }
133 return new UIImage(GetIcon())
134 {
135 Left = new StyleDimension(4f, 0f)
136 };
137 }
138
139 private Asset<Texture2D> GetSeedIcon(string seed)
140 {
141 return Main.Assets.Request<Texture2D>("Images/UI/Icon" + (_data.IsHardMode ? "Hallow" : "") + (_data.HasCorruption ? "Corruption" : "Crimson") + seed, (AssetRequestMode)1);
142 }
143}
void UpdateGlitchAnimation(UIElement affectedElement)
Asset< Texture2D > GetSeedIcon(string seed)
void GetDifficulty(out string expertText, out Color gameModeColor)
static string GetTextValue(string key)
Definition Language.cs:15
static Microsoft.Xna.Framework.Color hcColor
Definition Main.cs:994
static Microsoft.Xna.Framework.Color creativeModeColor
Definition Main.cs:996
static Microsoft.Xna.Framework.Color legendaryModeColor
Definition Main.cs:998
static Microsoft.Xna.Framework.Color mcColor
Definition Main.cs:992
static UnifiedRandom rand
Definition Main.cs:1387
static IAssetRepository Assets
Definition Main.cs:209
StyleDimension Left
Definition UIElement.cs:25