Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IngameFancyUI.cs
Go to the documentation of this file.
9
10namespace Terraria.UI;
11
12public class IngameFancyUI
13{
14 private static bool CoverForOneUIFrame;
15
16 public static void CoverNextFrame()
17 {
18 CoverForOneUIFrame = true;
19 }
20
21 public static bool CanCover()
22 {
24 {
25 CoverForOneUIFrame = false;
26 return true;
27 }
28 return false;
29 }
30
31 public static void OpenAchievements()
32 {
34 Main.playerInventory = false;
35 Main.editChest = false;
36 Main.npcChatText = "";
37 Main.inFancyUI = true;
38 ClearChat();
40 }
41
42 public static void OpenAchievementsAndGoto(Achievement achievement)
43 {
45 Main.AchievementsMenu.GotoAchievement(achievement);
46 }
47
48 private static void ClearChat()
49 {
51 Main.chatText = "";
52 }
53
54 public static void OpenKeybinds()
55 {
57 }
58
59 public static void OpenUIState(UIState uiState)
60 {
62 Main.playerInventory = false;
63 Main.editChest = false;
64 Main.npcChatText = "";
65 Main.inFancyUI = true;
66 ClearChat();
67 Main.InGameUI.SetState(uiState);
68 }
69
70 public static bool CanShowVirtualKeyboard(int context)
71 {
72 return UIVirtualKeyboard.CanDisplay(context);
73 }
74
75 public static void OpenVirtualKeyboard(int keyboardContext)
76 {
78 ClearChat();
80 string labelText = "";
81 switch (keyboardContext)
82 {
83 case 1:
84 Main.editSign = true;
85 labelText = Language.GetTextValue("UI.EnterMessage");
86 break;
87 case 2:
88 {
89 labelText = Language.GetTextValue("UI.EnterNewName");
90 Player player = Main.player[Main.myPlayer];
91 Main.npcChatText = Main.chest[player.chest].name;
92 Tile tile = Main.tile[player.chestX, player.chestY];
93 if (tile.type == 21)
94 {
95 Main.defaultChestName = Lang.chestType[tile.frameX / 36].Value;
96 }
97 else if (tile.type == 467 && tile.frameX / 36 == 4)
98 {
99 Main.defaultChestName = Lang.GetItemNameValue(3988);
100 }
101 else if (tile.type == 467)
102 {
103 Main.defaultChestName = Lang.chestType2[tile.frameX / 36].Value;
104 }
105 else if (tile.type == 88)
106 {
107 Main.defaultChestName = Lang.dresserType[tile.frameX / 54].Value;
108 }
109 if (Main.npcChatText == "")
110 {
111 Main.npcChatText = Main.defaultChestName;
112 }
113 Main.editChest = true;
114 break;
115 }
116 }
117 Main.clrInput();
118 if (!CanShowVirtualKeyboard(keyboardContext))
119 {
120 return;
121 }
122 Main.inFancyUI = true;
123 switch (keyboardContext)
124 {
125 case 1:
126 Main.InGameUI.SetState(new UIVirtualKeyboard(labelText, Main.npcChatText, delegate
127 {
128 Main.SubmitSignText();
129 Close();
130 }, delegate
131 {
132 Main.InputTextSignCancel();
133 Close();
134 }, keyboardContext));
135 break;
136 case 2:
137 Main.InGameUI.SetState(new UIVirtualKeyboard(labelText, Main.npcChatText, delegate
138 {
139 ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
140 Close();
141 }, delegate
142 {
143 ChestUI.RenameChestCancel();
144 Close();
145 }, keyboardContext));
146 break;
147 }
149 }
150
151 public static void Close()
152 {
153 Main.inFancyUI = false;
155 bool flag = !Main.gameMenu;
156 bool flag2 = !(Main.InGameUI.CurrentState is UIVirtualKeyboard);
157 bool flag3 = false;
158 int keyboardContext = UIVirtualKeyboard.KeyboardContext;
159 if ((uint)(keyboardContext - 2) <= 1u)
160 {
161 flag3 = true;
162 }
163 if (flag && !(flag2 || flag3))
164 {
165 flag = false;
166 }
167 if (flag)
168 {
169 Main.playerInventory = true;
170 }
171 if (!Main.gameMenu && Main.InGameUI.CurrentState is UIEmotesMenu)
172 {
173 Main.playerInventory = false;
174 }
175 Main.LocalPlayer.releaseInventory = false;
176 Main.InGameUI.SetState(null);
177 UILinkPointNavigator.Shortcuts.FANCYUI_SPECIAL_INSTRUCTIONS = 0;
178 }
179
180 public static bool Draw(SpriteBatch spriteBatch, GameTime gameTime)
181 {
182 bool result = false;
184 {
185 if (!Main.inFancyUI)
186 {
187 Main.InGameUI.SetState(null);
188 }
190 {
191 result = true;
192 }
193 }
194 if (!Main.gameMenu)
195 {
196 Main.mouseText = false;
197 if (Main.InGameUI != null && Main.InGameUI.IsElementUnderMouse())
198 {
199 Main.player[Main.myPlayer].mouseInterface = true;
200 }
201 Main.instance.GUIBarsDraw();
203 {
204 Main.instance.GUIChatDraw();
205 }
206 if (!Main.inFancyUI)
207 {
208 Main.InGameUI.SetState(null);
209 }
210 Main.instance.DrawMouseOver();
212 }
213 return result;
214 }
215
216 public static void MouseOver()
217 {
218 if (Main.inFancyUI && Main.InGameUI.IsElementUnderMouse())
219 {
220 Main.mouseText = true;
221 }
222 }
223}
static void PlaySound(int type, Vector2 position, int style=1)
static LocalizedText[] dresserType
Definition Lang.cs:40
static LocalizedText[] chestType2
Definition Lang.cs:43
static LocalizedText[] chestType
Definition Lang.cs:37
static string GetItemNameValue(int id)
Definition Lang.cs:185
static string GetTextValue(string key)
Definition Language.cs:15
static UIManageControls ManageControlsMenu
Definition Main.cs:1150
static string npcChatText
Definition Main.cs:1825
static Chest[] chest
Definition Main.cs:1699
static UserInterface InGameUI
Definition Main.cs:383
static UIAchievementsMenu AchievementsMenu
Definition Main.cs:1152
static int myPlayer
Definition Main.cs:1801
static bool inFancyUI
Definition Main.cs:706
static Vector2 DrawThickCursor(bool smart=false)
Definition Main.cs:45092
static Main instance
Definition Main.cs:283
static void DrawCursor(Vector2 bonus, bool smart=false)
Definition Main.cs:45012
static Tile[,] tile
Definition Main.cs:1675
static string defaultChestName
Definition Main.cs:1823
static void clrInput()
Definition Main.cs:18584
static int screenWidth
Definition Main.cs:1719
static bool gameMenu
Definition Main.cs:1926
static void ClosePlayerChat()
Definition Main.cs:16993
static Player[] player
Definition Main.cs:1803
ushort type
Definition Tile.cs:8
short frameX
Definition Tile.cs:22
static void GoToDefaultPage(int specialFlag=0)
static bool Draw(SpriteBatch spriteBatch, GameTime gameTime)
static void OpenAchievementsAndGoto(Achievement achievement)
static void OpenAchievements()
static bool CanShowVirtualKeyboard(int context)
static void OpenVirtualKeyboard(int keyboardContext)
static void OpenUIState(UIState uiState)