diff --git a/Intersect.Client.Core/Interface/Game/Character/CharacterWindow.cs b/Intersect.Client.Core/Interface/Game/Character/CharacterWindow.cs
index 27d3416265..3291eea65e 100644
--- a/Intersect.Client.Core/Interface/Game/Character/CharacterWindow.cs
+++ b/Intersect.Client.Core/Interface/Game/Character/CharacterWindow.cs
@@ -9,8 +9,6 @@
using Intersect.Enums;
using Intersect.Framework.Core.GameObjects.Items;
using Intersect.Framework.Core.GameObjects.PlayerClass;
-using Intersect.GameObjects;
-using Intersect.Network.Packets.Server;
namespace Intersect.Client.Interface.Game.Character;
@@ -71,40 +69,24 @@ public partial class CharacterWindow
public int Y;
//Extra Buffs
+ Button _detailsButton;
+
ClassDescriptor mPlayer;
- Label mHpRegen;
-
long HpRegenAmount;
- Label mManaRegen;
-
long ManaRegenAmount;
- Label mLifeSteal;
-
int LifeStealAmount = 0;
- Label mAttackSpeed;
-
- Label mExtraExp;
-
int ExtraExpAmount = 0;
- Label mLuck;
-
int LuckAmount = 0;
- Label mTenacity;
-
int TenacityAmount = 0;
- Label mCooldownReduction;
-
int CooldownAmount = 0;
- Label mManaSteal;
-
int ManaStealAmount = 0;
//Init
@@ -168,18 +150,12 @@ public CharacterWindow(Canvas gameCanvas)
Items[i].Setup();
}
- var extraBuffsLabel = new Label(mCharacterWindow, "ExtraBuffsLabel");
- extraBuffsLabel.SetText(Strings.Character.ExtraBuffs);
-
- mHpRegen = new Label(mCharacterWindow, "HpRegen");
- mManaRegen = new Label(mCharacterWindow, "ManaRegen");
- mLifeSteal = new Label(mCharacterWindow, "Lifesteal");
- mAttackSpeed = new Label(mCharacterWindow, "AttackSpeed");
- mExtraExp = new Label(mCharacterWindow, "ExtraExp");
- mLuck = new Label(mCharacterWindow, "Luck");
- mTenacity = new Label(mCharacterWindow, "Tenacity");
- mCooldownReduction = new Label(mCharacterWindow, "CooldownReduction");
- mManaSteal = new Label(mCharacterWindow, "Manasteal");
+ _detailsButton = new Button(mCharacterWindow, nameof(_detailsButton))
+ {
+ Text = Strings.Character.ExtraBuffDetails,
+ };
+ _detailsButton.HoverEnter += UpdateExtraBuffTooltip; // Update Tooltip on hover.
+ UpdateExtraBuffTooltip(null, null); // Initial tooltip update.
mCharacterWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
}
@@ -213,7 +189,7 @@ void _addAttackBtn_Clicked(Base sender, MouseButtonState arguments)
//Methods
public void Update()
{
- if (mCharacterWindow.IsHidden)
+ if (mCharacterWindow.IsHidden || Globals.Me is null)
{
return;
}
@@ -375,72 +351,45 @@ public void Update()
mAddSpeedBtn.IsHidden =
Globals.Me.StatPoints == 0 || Globals.Me.Stat[(int) Stat.Speed] == Options.Instance.Player.MaxStat;
- UpdateExtraBuffs();
+ UpdateEquippedItems();
+ }
+
+ private void UpdateEquippedItems(bool updateExtraBuffs = false)
+ {
+ if (Globals.Me is not { } player)
+ {
+ return;
+ }
for (var i = 0; i < Options.Instance.Equipment.Slots.Count; i++)
{
- if (Globals.Me.MyEquipment[i] > -1 && Globals.Me.MyEquipment[i] < Options.Instance.Player.MaxInventory)
+ var invSlot = player.MyEquipment[i];
+ if (invSlot < 0 || invSlot >= Options.Instance.Player.MaxInventory)
{
- if (Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId != Guid.Empty)
- {
- Items[i]
- .Update(
- Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId,
- Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemProperties
- );
-
- UpdateExtraBuffs(Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId);
- }
- else
- {
- Items[i].Update(Guid.Empty, mItemProperties);
- }
+ Items[i].Update(Guid.Empty, mItemProperties);
+ continue;
}
- else
+
+ var item = player.Inventory[invSlot];
+ if (item.ItemId == Guid.Empty)
{
Items[i].Update(Guid.Empty, mItemProperties);
+ continue;
}
- }
- }
- ///
- /// Update Extra Buffs Effects like hp/mana regen and items effect types
- ///
- public void UpdateExtraBuffs()
- {
- mPlayer = ClassDescriptor.Get(Globals.Me?.Class ?? Guid.Empty);
-
- //Getting HP and Mana Regen
- if (mPlayer != null)
- {
- HpRegenAmount = mPlayer.VitalRegen[0];
- mHpRegen.SetText(Strings.Character.HealthRegen.ToString(HpRegenAmount));
- ManaRegenAmount = mPlayer.VitalRegen[1];
- mManaRegen.SetText(Strings.Character.ManaRegen.ToString(ManaRegenAmount));
+ Items[i].Update(item.ItemId, item.ItemProperties);
+ if (updateExtraBuffs)
+ {
+ UpdateExtraBuffs(item.ItemId);
+ }
}
-
- CooldownAmount = 0;
- LifeStealAmount = 0;
- TenacityAmount = 0;
- LuckAmount = 0;
- ExtraExpAmount = 0;
- ManaStealAmount = 0;
-
- mLifeSteal.SetText(Strings.Character.Lifesteal.ToString(0));
- mExtraExp.SetText(Strings.Character.ExtraExp.ToString(0));
- mLuck.SetText(Strings.Character.Luck.ToString(0));
- mTenacity.SetText(Strings.Character.Tenacity.ToString(0));
- mCooldownReduction.SetText(Strings.Character.CooldownReduction.ToString(0));
- mManaSteal.SetText(Strings.Character.Manasteal.ToString(0));
-
- mAttackSpeed.SetText(Strings.Character.AttackSpeed.ToString(Globals.Me.CalculateAttackTime() / 1000f));
}
///
/// Update Extra Buffs Effects like hp/mana regen and items effect types
///
/// Id of item to update extra buffs
- public void UpdateExtraBuffs(Guid itemId)
+ private void UpdateExtraBuffs(Guid itemId)
{
var item = ItemDescriptor.Get(itemId);
@@ -449,23 +398,21 @@ public void UpdateExtraBuffs(Guid itemId)
return;
}
- //Getting HP and Mana Regen
- if (item.VitalsRegen[0] != 0)
+ //Getting HP and Mana Regen from items
+ if (item.VitalsRegen[(int)Vital.Health] != 0)
{
- HpRegenAmount += item.VitalsRegen[0];
- mHpRegen?.SetText(Strings.Character.HealthRegen.ToString(HpRegenAmount));
+ HpRegenAmount += item.VitalsRegen[(int)Vital.Health];
}
- if (item.VitalsRegen[1] != 0)
+ if (item.VitalsRegen[(int)Vital.Mana] != 0)
{
- ManaRegenAmount += item.VitalsRegen[1];
- mManaRegen?.SetText(Strings.Character.ManaRegen.ToString(ManaRegenAmount));
+ ManaRegenAmount += item.VitalsRegen[(int)Vital.Mana];
}
- //Getting extra buffs
+ //Getting extra buffs from items
if (item.Effects.Find(effect => effect.Type != ItemEffect.None && effect.Percentage > 0) != default)
{
- foreach(var effect in item.Effects)
+ foreach (var effect in item.Effects)
{
if (effect.Percentage <= 0)
{
@@ -476,39 +423,56 @@ public void UpdateExtraBuffs(Guid itemId)
{
case ItemEffect.CooldownReduction:
CooldownAmount += effect.Percentage;
- mCooldownReduction?.SetText(Strings.Character.CooldownReduction.ToString(CooldownAmount));
-
break;
case ItemEffect.Lifesteal:
LifeStealAmount += effect.Percentage;
- mLifeSteal?.SetText(Strings.Character.Lifesteal.ToString(LifeStealAmount));
-
break;
case ItemEffect.Tenacity:
TenacityAmount += effect.Percentage;
- mTenacity?.SetText(Strings.Character.Tenacity.ToString(TenacityAmount));
-
break;
case ItemEffect.Luck:
LuckAmount += effect.Percentage;
- mLuck?.SetText(Strings.Character.Luck.ToString(LuckAmount));
-
break;
case ItemEffect.EXP:
ExtraExpAmount += effect.Percentage;
- mExtraExp?.SetText(Strings.Character.ExtraExp.ToString(ExtraExpAmount));
-
break;
case ItemEffect.Manasteal:
ManaStealAmount += effect.Percentage;
- mManaSteal?.SetText(Strings.Character.Manasteal.ToString(ManaStealAmount));
-
break;
}
}
}
}
+ private void UpdateExtraBuffTooltip(Base? sender, EventArgs? arguments)
+ {
+ //Reset all values
+ HpRegenAmount = mPlayer?.VitalRegen[(int)Vital.Health] ?? 0;
+ ManaRegenAmount = mPlayer?.VitalRegen[(int)Vital.Mana] ?? 0;
+ CooldownAmount = 0;
+ LifeStealAmount = 0;
+ TenacityAmount = 0;
+ LuckAmount = 0;
+ ExtraExpAmount = 0;
+ ManaStealAmount = 0;
+
+ // Update extra buffs from equipped items
+ UpdateEquippedItems(true);
+
+ // Update tooltip with the current extra buffs
+ var tooltip = new System.Text.StringBuilder();
+ tooltip.AppendLine(Strings.Character.HealthRegen.ToString(HpRegenAmount));
+ tooltip.AppendLine(Strings.Character.ManaRegen.ToString(ManaRegenAmount));
+ tooltip.AppendLine(Strings.Character.Lifesteal.ToString(LifeStealAmount));
+ tooltip.AppendLine(Strings.Character.AttackSpeed.ToString(Globals.Me?.CalculateAttackTime() / 1000f));
+ tooltip.AppendLine(Strings.Character.ExtraExp.ToString(ExtraExpAmount));
+ tooltip.AppendLine(Strings.Character.Luck.ToString(LuckAmount));
+ tooltip.AppendLine(Strings.Character.Tenacity.ToString(TenacityAmount));
+ tooltip.AppendLine(Strings.Character.CooldownReduction.ToString(CooldownAmount));
+ tooltip.AppendLine(Strings.Character.Manasteal.ToString(ManaStealAmount));
+ _detailsButton.SetToolTipText(tooltip.ToString());
+ }
+
///
/// Show the window
///
diff --git a/Intersect.Client.Core/Interface/Game/Character/EquipmentItem.cs b/Intersect.Client.Core/Interface/Game/Character/EquipmentItem.cs
index 9e708d0c11..622fdf7050 100644
--- a/Intersect.Client.Core/Interface/Game/Character/EquipmentItem.cs
+++ b/Intersect.Client.Core/Interface/Game/Character/EquipmentItem.cs
@@ -1,3 +1,5 @@
+using System.Diagnostics;
+using Intersect.Client.Framework.File_Management;
using Intersect.Client.Framework.GenericClasses;
using Intersect.Client.Framework.Gwen.Control;
using Intersect.Client.Framework.Gwen.Control.EventArguments;
@@ -20,7 +22,7 @@ public partial class EquipmentItem
private ItemProperties mItemProperties = null;
- private bool mTexLoaded;
+ private string? _loadedTexture;
private int mYindex;
@@ -110,32 +112,31 @@ public FloatRect RenderBounds()
public void Update(Guid currentItemId, ItemProperties itemProperties)
{
- if (currentItemId != mCurrentItemId || !mTexLoaded)
+ if (!ItemDescriptor.TryGet(currentItemId, out var item))
{
- mCurrentItemId = currentItemId;
- mItemProperties = itemProperties;
- var item = ItemDescriptor.Get(mCurrentItemId);
- if (item != null)
- {
- var itemTex = Globals.ContentManager.GetTexture(Framework.Content.TextureType.Item, item.Icon);
- if (itemTex != null)
- {
- ContentPanel.Show();
- ContentPanel.Texture = itemTex;
- ContentPanel.RenderColor = item.Color;
- }
- else
- {
- ContentPanel.Hide();
- }
- }
- else
- {
- ContentPanel.Hide();
- }
+ ContentPanel.Hide();
+ _loadedTexture = default;
+ return;
+ }
- mTexLoaded = true;
+ if (currentItemId == mCurrentItemId && ContentPanel.Texture?.Name == _loadedTexture)
+ {
+ return;
}
- }
+ mCurrentItemId = currentItemId;
+ mItemProperties = itemProperties;
+
+ if (GameContentManager.Current.GetTexture(Framework.Content.TextureType.Item, item.Icon) is not { } itemTexture)
+ {
+ ContentPanel.Hide();
+ _loadedTexture = default;
+ return;
+ }
+
+ ContentPanel.Show();
+ ContentPanel.Texture = itemTexture;
+ ContentPanel.RenderColor = item.Color;
+ _loadedTexture = ContentPanel.Texture?.Name;
+ }
}
diff --git a/Intersect.Client.Core/Localization/Strings.cs b/Intersect.Client.Core/Localization/Strings.cs
index 3f10edd4c8..e7d315fc32 100644
--- a/Intersect.Client.Core/Localization/Strings.cs
+++ b/Intersect.Client.Core/Localization/Strings.cs
@@ -637,7 +637,7 @@ public partial struct Character
public static LocalizedString Equipment = @"Equipment:";
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
- public static LocalizedString ExtraBuffs = @"Extra Buffs";
+ public static LocalizedString ExtraBuffDetails = @"Details";
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString ExtraExp = @"Bonus EXP: {00}%";