Skip to content

Commit

Permalink
Merge pull request #225 from elderwyn/feature/ResourceOverhead
Browse files Browse the repository at this point in the history
Feature > Nameplate colors based on status
  • Loading branch information
bittiez committed Apr 10, 2024
2 parents 9377163 + a5491c1 commit e2293a3
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 12 deletions.
96 changes: 84 additions & 12 deletions src/ClassicUO.Client/Game/UI/Gumps/NameOverheadGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private void BuildGump()
_background = new AlphaBlendControl(ProfileManager.CurrentProfile.NamePlateOpacity / 100f)
{
WantUpdateSize = false,
Hue = entity is Mobile m ? Notoriety.GetHue(m.NotorietyFlag) : (ushort)0x0481
Hue = entity is Mobile m ? Notoriety.GetHue(m.NotorietyFlag) : Notoriety.GetHue(NotorietyFlag.Gray)
}
);
}
Expand Down Expand Up @@ -734,29 +734,101 @@ out int height
batcher.DrawRectangle
(
_borderColor,
x - 1,
y - 1,
Width + 1,
Height + 1,
x,
y,
Width,
Height,
hueVector
);

base.Draw(batcher, x, y);

if (ProfileManager.CurrentProfile.NamePlateHealthBar && _isMobile)
{
batcher.Draw
(
SolidColorTextureCache.GetTexture(Color.White),
new Vector2(x, y),
new Rectangle(x, y, Math.Min((int)(Width * _hpPercent), Width), Height),
ShaderHueTranslator.GetHueVector(_background.Hue, false, ProfileManager.CurrentProfile.NamePlateHealthBarOpacity / 100f)
);
Mobile m = World.Mobiles.Get(LocalSerial);
var isPlayer = m is PlayerMobile;
var isInParty = World.Party.Contains(m.Serial);

var _alpha = ProfileManager.CurrentProfile.NamePlateHealthBarOpacity / 100f;
DrawResourceBar(batcher, m, x, y, Height / (isPlayer || isInParty ? 3 : 1), m =>
{
var hpPercent = (double)m.Hits / (double)m.HitsMax;
var _baseHue = hpPercent switch
{
1 => (m is PlayerMobile || World.Party.Contains(m.Serial)) ? 0x0058 : Notoriety.GetHue(m.NotorietyFlag),
> .8 => 0x0058,
> .4 => 0x0030,
_ => 0x0021
};
Vector3 hueVec = ShaderHueTranslator.GetHueVector(_baseHue, false, _alpha);
if (m.IsPoisoned)
{
hueVec = ShaderHueTranslator.GetHueVector(63, false, _alpha);
}
else if (m.IsYellowHits || m.IsParalyzed)
{
hueVec = ShaderHueTranslator.GetHueVector(353, false, _alpha);
}
return (hueVec, hpPercent);
}, out var nY);

if (m is PlayerMobile || isInParty)
{
DrawResourceBar(batcher, m, x, nY, Height / 3, m =>
{
var mpPercent = (double)m.Mana / (double)m.ManaMax;
var _baseHue = mpPercent switch
{
> .6 => 0x0058,
> .2 => 0x0030,
_ => 0x0021
};
Vector3 hueVec = ShaderHueTranslator.GetHueVector(_baseHue, false, _alpha);
return (hueVec, mpPercent);
}, out nY);

DrawResourceBar(batcher, m, x, nY, Height / 3, m =>
{
var spPercent = (double)m.Stamina / (double)m.StaminaMax;
var _baseHue = spPercent switch
{
> .8 => 0x0058,
> .5 => 0x0030,
_ => 0x0021
};
Vector3 hueVec = ShaderHueTranslator.GetHueVector(_baseHue, false, _alpha);
return (hueVec, spPercent);
}, out nY);
y += 20;
}
}

return _text.Draw(batcher, (int)(x + 2 + _textDrawOffset.X), (int)(y + 2 + _textDrawOffset.Y));
}

private void DrawResourceBar(UltimaBatcher2D batcher, Mobile m, int x, int y, int height, Func<Mobile, (Vector3, double)> getHueVector, out int nY)
{
var data = getHueVector == null ? (ShaderHueTranslator.GetHueVector(0x0058), 0) : getHueVector(m);
batcher.DrawRectangle
(
_borderColor,
x,
y,
Width,
height,
ShaderHueTranslator.GetHueVector(0)
);
batcher.Draw
(
SolidColorTextureCache.GetTexture(Color.White),
new Vector2(x + 1, y + 1),
new Rectangle(x, y, Math.Min((int)((Width - 1) * data.Item2), Width - 1), height - 1),
data.Item1
);
nY = y + height;
}

public override void Dispose()
{
_text.Dispose();
Expand Down
3 changes: 3 additions & 0 deletions src/ClassicUO.Client/Game/UI/Gumps/VersionHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace ClassicUO.Game.UI.Gumps
internal class VersionHistory : Gump
{
private static string[] updateTexts = {
"/c[white][3.23.0]/cd\n" +
"- Nameplate healthbar poison and invul/paralyzed colors from Elderwyn",

"/c[white][3.22.0]/cd\n" +
"- Spell book icon fix\n" +
"- Add option to add treasure maps as map markers instead of goto only\n" +
Expand Down

0 comments on commit e2293a3

Please sign in to comment.