using System; using Server; using Server.Gumps; using Server.Mobiles; using Server.Commands; using Server.Network; namespace Server.Custom.UI { public class StatusBar { public static void Initialize() { CommandSystem.Register("Status", AccessLevel.Player, new CommandEventHandler(OnCommand)); } [Usage("Status")] [Description("Opens a quick-view status bar for Fame, Karma, Hunger, Thirst, and Tithing.")] public static void OnCommand(CommandEventArgs e) { if (e.Mobile is PlayerMobile) { PlayerMobile pm = (PlayerMobile)e.Mobile; pm.CloseGump(typeof(StatusBarGump)); pm.SendGump(new StatusBarGump(pm, false)); } } public static void Refresh(Mobile from, bool force = false) { if (from is PlayerMobile && from.NetState != null) { if (from.HasGump(typeof(StatusBarGump)) || force) { bool isVert = false; foreach (Gump gump in from.NetState.Gumps) { if (gump is StatusBarGump) { isVert = ((StatusBarGump)gump).IsVertical; break; } } from.CloseGump(typeof(StatusBarGump)); from.SendGump(new StatusBarGump((PlayerMobile)from, isVert)); } } } } public class StatusBarGump : Gump { private PlayerMobile m_Player; private bool m_IsVertical; public bool IsVertical { get { return m_IsVertical; } } public StatusBarGump(PlayerMobile pm, bool isVertical) : base(50, 50) { m_Player = pm; m_IsVertical = isVertical; Closable = true; Disposable = true; Dragable = true; Resizable = false; AddPage(0); if (m_IsVertical) { AddBackground(0, 0, 150, 175, 9270); AddHtml(15, 15, 120, 20, $"Fame: {pm.Fame}", false, false); AddHtml(15, 40, 120, 20, $"Karma: {pm.Karma}", false, false); AddHtml(15, 65, 120, 20, $"Hunger: {pm.Hunger}/20", false, false); AddHtml(15, 90, 120, 20, $"Thirst: {pm.Thirst}/20", false, false); AddHtml(15, 115, 120, 20, $"Tithing: {pm.TithingPoints}", false, false); AddButton(115, 142, 9720, 9722, 2, GumpButtonType.Reply, 0); } else { AddBackground(0, 0, 550, 45, 9270); AddHtml(15, 12, 110, 20, $"Fame: {pm.Fame}", false, false); AddHtml(110, 12, 110, 20, $"Karma: {pm.Karma}", false, false); AddHtml(215, 12, 110, 20, $"Hunger: {pm.Hunger}/20", false, false); AddHtml(315, 12, 110, 20, $"Thirst: {pm.Thirst}/20", false, false); AddHtml(410, 12, 110, 20, $"Tithing: {pm.TithingPoints}", false, false); AddButton(525, 15, 9720, 9722, 2, GumpButtonType.Reply, 0); } } public override void OnResponse(NetState sender, RelayInfo info) { if (m_Player == null || m_Player.Deleted) return; switch (info.ButtonID) { case 1: m_Player.SendGump(new StatusBarGump(m_Player, m_IsVertical)); break; case 2: m_Player.SendGump(new StatusBarGump(m_Player, !m_IsVertical)); break; } } } }