115 lines
4.4 KiB
C#
115 lines
4.4 KiB
C#
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, $"<BASEFONT COLOR=#FCCA03>Fame:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Fame}</BASEFONT>", false, false);
|
|
AddHtml(15, 40, 120, 20, $"<BASEFONT COLOR=#FCCA03>Karma:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Karma}</BASEFONT>", false, false);
|
|
AddHtml(15, 65, 120, 20, $"<BASEFONT COLOR=#FCCA03>Hunger:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Hunger}/20</BASEFONT>", false, false);
|
|
AddHtml(15, 90, 120, 20, $"<BASEFONT COLOR=#FCCA03>Thirst:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Thirst}/20</BASEFONT>", false, false);
|
|
AddHtml(15, 115, 120, 20, $"<BASEFONT COLOR=#FCCA03>Tithing:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.TithingPoints}</BASEFONT>", false, false);
|
|
|
|
AddButton(115, 142, 9720, 9722, 2, GumpButtonType.Reply, 0);
|
|
}
|
|
else
|
|
{
|
|
AddBackground(0, 0, 550, 45, 9270);
|
|
|
|
AddHtml(15, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Fame:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Fame}</BASEFONT>", false, false);
|
|
AddHtml(110, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Karma:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Karma}</BASEFONT>", false, false);
|
|
AddHtml(215, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Hunger:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Hunger}/20</BASEFONT>", false, false);
|
|
AddHtml(315, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Thirst:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Thirst}/20</BASEFONT>", false, false);
|
|
AddHtml(410, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Tithing:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.TithingPoints}</BASEFONT>", 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;
|
|
}
|
|
}
|
|
}
|
|
}
|