v1.0.2.2: Fix ColorUtils.GetColorByScale crash that prevented hotbars from showing

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-01-31 02:49:34 -05:00
parent 481f1cd45a
commit 1011d126d8
6 changed files with 26 additions and 11 deletions
+14 -1
View File
@@ -47,6 +47,12 @@ namespace HSUI.Helpers
//min and max are used for color thresholds. for instance return colorLeft if i < min or return ColorRight if i > max
public static PluginConfigColor GetColorByScale(float i, float min, float max, PluginConfigColor colorLeft, PluginConfigColor colorRight, PluginConfigColor colorMax, bool useMaxColor, BlendMode blendMode)
{
try
{
// Guard against null/invalid config (can happen with corrupted or migrated config)
if (colorLeft == null || colorRight == null || colorMax == null)
return PluginConfigColor.FromHex(0xFF808080);
//Set our thresholds where the ratio is the range of values we will use for interpolation.
//Values outside this range will either return colorLeft or colorRight
float ratio = i;
@@ -63,7 +69,8 @@ namespace HSUI.Helpers
else
{
float range = max - min;
ratio = (i - min) / range;
if (MathF.Abs(range) < 0.0001f) ratio = 1; // avoid divide-by-zero when min==max
else ratio = (i - min) / range;
}
}
@@ -224,6 +231,12 @@ namespace HSUI.Helpers
}
}
return new(Vector4.One);
}
catch (Exception ex)
{
Plugin.Logger.Warning($"[HSUI] GetColorByScale failed (config may be corrupted): {ex.Message}");
return PluginConfigColor.FromHex(0xFF808080);
}
}
public static PluginConfigColor ColorForActor(IGameObject? actor)