#W# Added a nice status bar. can be flipped vertical or horizontal.
This commit is contained in:
parent
48c489a256
commit
26588acf2d
3 changed files with 168 additions and 3 deletions
129
Scripts/Gumps/StatusBar.cs
Normal file
129
Scripts/Gumps/StatusBar.cs
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// This line right here is what threw the CS1061 error earlier!
|
||||||
|
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;
|
||||||
|
|
||||||
|
// --- HERE IS THE MISSING PROPERTY THAT FIXES THE CS1061 ERROR ---
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// ==========================================
|
||||||
|
// VERTICAL LAYOUT
|
||||||
|
// ==========================================
|
||||||
|
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(15, 142, 4011, 4012, 1, GumpButtonType.Reply, 0);
|
||||||
|
AddHtml(50, 143, 80, 20, "<BASEFONT COLOR=#FFFFFF>Refresh</BASEFONT>", false, false);
|
||||||
|
|
||||||
|
AddButton(115, 142, 9720, 9722, 2, GumpButtonType.Reply, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ==========================================
|
||||||
|
// HORIZONTAL LAYOUT (Widened for Tithing)
|
||||||
|
// ==========================================
|
||||||
|
AddBackground(0, 0, 580, 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, 12, 4011, 4012, 1, GumpButtonType.Reply, 0);
|
||||||
|
|
||||||
|
AddButton(555, 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -25,6 +25,7 @@ using Server.Engines.Craft;
|
||||||
using Server.Spells.Spellweaving;
|
using Server.Spells.Spellweaving;
|
||||||
using Server.Engines.PartySystem;
|
using Server.Engines.PartySystem;
|
||||||
using Server.Engines.MLQuests;
|
using Server.Engines.MLQuests;
|
||||||
|
using Server.Custom.UI;
|
||||||
|
|
||||||
namespace Server.Mobiles
|
namespace Server.Mobiles
|
||||||
{
|
{
|
||||||
|
|
@ -4203,11 +4204,13 @@ namespace Server.Mobiles
|
||||||
public override void OnKarmaChange( int oldValue )
|
public override void OnKarmaChange( int oldValue )
|
||||||
{
|
{
|
||||||
InvalidateMyRunUO();
|
InvalidateMyRunUO();
|
||||||
|
StatusBar.Refresh(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnFameChange( int oldValue )
|
public override void OnFameChange( int oldValue )
|
||||||
{
|
{
|
||||||
InvalidateMyRunUO();
|
InvalidateMyRunUO();
|
||||||
|
StatusBar.Refresh(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSkillChange( SkillName skill, double oldBase )
|
public override void OnSkillChange( SkillName skill, double oldBase )
|
||||||
|
|
@ -4226,6 +4229,21 @@ namespace Server.Mobiles
|
||||||
InvalidateMyRunUO();
|
InvalidateMyRunUO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnHungerChange(int oldValue)
|
||||||
|
{
|
||||||
|
StatusBar.Refresh(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnThirstChange(int oldValue)
|
||||||
|
{
|
||||||
|
StatusBar.Refresh(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnTithingPointsChange(int oldValue)
|
||||||
|
{
|
||||||
|
StatusBar.Refresh(this);
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnAccessLevelChanged( AccessLevel oldLevel )
|
public override void OnAccessLevelChanged( AccessLevel oldLevel )
|
||||||
{
|
{
|
||||||
if ( AccessLevel == AccessLevel.Player )
|
if ( AccessLevel == AccessLevel.Player )
|
||||||
|
|
|
||||||
|
|
@ -1549,12 +1549,16 @@ namespace Server
|
||||||
if( oldValue != value )
|
if( oldValue != value )
|
||||||
{
|
{
|
||||||
m_Hunger = value;
|
m_Hunger = value;
|
||||||
|
OnHungerChange(oldValue);
|
||||||
EventSink.InvokeHungerChanged( new HungerChangedEventArgs( this, oldValue ) );
|
EventSink.InvokeHungerChanged( new HungerChangedEventArgs( this, oldValue ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnHungerChange(int oldValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[CommandProperty( AccessLevel.GameMaster )]
|
[CommandProperty( AccessLevel.GameMaster )]
|
||||||
public int Thirst
|
public int Thirst
|
||||||
{
|
{
|
||||||
|
|
@ -1564,10 +1568,19 @@ namespace Server
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_Thirst = value;
|
int oldValue = m_Thirst;
|
||||||
|
if (oldValue != value)
|
||||||
|
{
|
||||||
|
m_Thirst = value;
|
||||||
|
OnThirstChange(oldValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnThirstChange(int oldValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[CommandProperty( AccessLevel.GameMaster )]
|
[CommandProperty( AccessLevel.GameMaster )]
|
||||||
public int BAC
|
public int BAC
|
||||||
{
|
{
|
||||||
|
|
@ -2512,13 +2525,18 @@ namespace Server
|
||||||
{
|
{
|
||||||
if( m_TithingPoints != value )
|
if( m_TithingPoints != value )
|
||||||
{
|
{
|
||||||
|
int oldValue = m_TithingPoints;
|
||||||
m_TithingPoints = value;
|
m_TithingPoints = value;
|
||||||
|
|
||||||
Delta( MobileDelta.TithingPoints );
|
Delta( MobileDelta.TithingPoints );
|
||||||
|
OnTithingPointsChange(oldValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnTithingPointsChange(int oldValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[CommandProperty( AccessLevel.GameMaster )]
|
[CommandProperty( AccessLevel.GameMaster )]
|
||||||
public int Followers
|
public int Followers
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue