diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5566f6a..9514d2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@ All notable changes to this library will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [4.7.0] - Unreleased
+## [4.7.0] - 2023-06-16
### Added
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Spell Rotation Mode` renamed `Default Spell Queue Rotation` to better describe it can be overriden
- `UserSettings` are now version `1.5`
+- Now format health/mana using `k` and `m` suffixes for thousands/millions (ex: `256k`, `1.2m`)
### Fixed
diff --git a/SleepHunter/App.xaml b/SleepHunter/App.xaml
index a70d187..fe10862 100644
--- a/SleepHunter/App.xaml
+++ b/SleepHunter/App.xaml
@@ -16,6 +16,7 @@
+
diff --git a/SleepHunter/Converters/NumericConverter.cs b/SleepHunter/Converters/NumericConverter.cs
index ac4d450..48e39ec 100644
--- a/SleepHunter/Converters/NumericConverter.cs
+++ b/SleepHunter/Converters/NumericConverter.cs
@@ -6,23 +6,43 @@ namespace SleepHunter.Converters
{
public sealed class NumericConverter : IValueConverter
{
+ private const int ThousandsThreshold = 1_000;
+ private const int MillionsThreshold = 1_000_000;
+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var isHexadecimal = string.Equals("Hexadecimal", parameter as string, StringComparison.OrdinalIgnoreCase);
+ var isThousands = string.Equals("Thousands", parameter as string, StringComparison.OrdinalIgnoreCase);
+
+ var integerValue = System.Convert.ToInt64(value, CultureInfo.InvariantCulture);
if (isHexadecimal)
{
- var hexValue = (uint)value;
- return hexValue.ToString("X");
+ return integerValue.ToString("X");
+ }
+
+ if (isThousands && integerValue > ThousandsThreshold)
+ {
+ if (integerValue >= MillionsThreshold)
+ {
+ var fractionalMillions = integerValue / (double)MillionsThreshold;
+ return $"{fractionalMillions:0.0}m";
+ }
+ else if (integerValue >= ThousandsThreshold)
+ {
+ var fractionalThousands = integerValue / (double)ThousandsThreshold;
+ return $"{fractionalThousands:0}k";
+ }
}
- var decValue = (double)value;
- return decValue.ToString();
+ return value.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var isHexadecimal = string.Equals("Hexadecimal", parameter as string, StringComparison.OrdinalIgnoreCase);
+ var isThousands = string.Equals("Thousands", parameter as string, StringComparison.OrdinalIgnoreCase);
+
var valueString = value as string;
if (isHexadecimal)
@@ -33,11 +53,30 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return hexValue;
}
+ if (isThousands)
+ {
+ if (valueString.EndsWith("m"))
+ {
+ var trimmedString = valueString.TrimEnd('m');
+ if (!double.TryParse(trimmedString, NumberStyles.Float, null, out var doubleValue))
+ return 0;
+ else
+ return (int)Math.Round(doubleValue * 1_000_000.0);
+ }
+ else if (valueString.EndsWith("k"))
+ {
+ var trimmedString = valueString.TrimEnd('m');
+ if (!double.TryParse(trimmedString, NumberStyles.Float, null, out var doubleValue))
+ return 0;
+ else
+ return (int)Math.Round(doubleValue * 1_000.0);
+ }
+ }
+
if (!double.TryParse(valueString, out var decValue))
return 0;
else
return decValue;
-
}
}
}
diff --git a/SleepHunter/Macro/PlayerMacroState.cs b/SleepHunter/Macro/PlayerMacroState.cs
index 070aa6b..43fef8c 100644
--- a/SleepHunter/Macro/PlayerMacroState.cs
+++ b/SleepHunter/Macro/PlayerMacroState.cs
@@ -1100,7 +1100,7 @@ private bool SwitchToBestStaff(SpellQueueItem item, out int? numberOfLines, out
if (item == null)
throw new ArgumentNullException(nameof(item));
- client.Update(PlayerFieldFlags.Inventory | PlayerFieldFlags.Equipment | PlayerFieldFlags.Stats);
+ client.Update( PlayerFieldFlags.Inventory | PlayerFieldFlags.Equipment | PlayerFieldFlags.Stats | PlayerFieldFlags.Spellbook);
var equippedStaff = client.Equipment.GetSlot(EquipmentSlot.Weapon);
var availableList = new List(client.Inventory.ItemNames);
diff --git a/SleepHunter/SleepHunter.csproj b/SleepHunter/SleepHunter.csproj
index d2a77a6..3d7e815 100644
--- a/SleepHunter/SleepHunter.csproj
+++ b/SleepHunter/SleepHunter.csproj
@@ -18,11 +18,11 @@
git
https://github.com/ewrogers/SleepHunter4
https://github.com/ewrogers/SleepHunter4
- 4.6.1.0
+ 4.7.0.0
2023 Erik 'SiLo' Rogers
Dark Ages Automation Tool
SleepHunter
- 4.6.1.0
+ 4.7.0.0
x64
diff --git a/SleepHunter/Templates/PlayerDataTemplate.xaml b/SleepHunter/Templates/PlayerDataTemplate.xaml
index 7ea3238..188c9e4 100644
--- a/SleepHunter/Templates/PlayerDataTemplate.xaml
+++ b/SleepHunter/Templates/PlayerDataTemplate.xaml
@@ -168,8 +168,8 @@
Visibility="{Binding ElementName=HealthBar, Path=Visibility}">
-
-
+
+
@@ -200,8 +200,8 @@
Visibility="{Binding ElementName=ManaBar, Path=Visibility}">
-
-
+
+