Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
VisibilityUI.cs
Go to the documentation of this file.
1 using Terraria;
2 using Terraria.ID;
3 using Terraria.UI;
4 
5 namespace Loot.UI.Common.Core
6 {
10  internal abstract class VisibilityUI : UIState
11  {
12  public bool Visible;
13 
14  public virtual void ToggleUI(UserInterface theInterface, UIState uiStateInstance = null)
15  {
16  uiStateInstance = uiStateInstance ?? this;
17 
18  // If new state toggled but old visibility state present, that one needs to be toggled first
19  if (theInterface.CurrentState is VisibilityUI ui
20  && theInterface.CurrentState != uiStateInstance)
21  {
22  ui.ToggleUI(theInterface, ui);
23  }
24 
25  // Toggle the state
26  Visible = !Visible;
27  theInterface.ResetLasts();
28  theInterface.SetState(Visible ? uiStateInstance : null);
29 
30  Main.PlaySound(SoundID.MenuOpen);
31  }
32  }
33 }