Skip to content

Commit

Permalink
fix light textures not being created, fixes #69
Browse files Browse the repository at this point in the history
  • Loading branch information
xorus committed Oct 5, 2024
1 parent d6d5151 commit 9e9e036
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions Plugin/Ui/Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ private static void ShowField<T>(T instance, FieldType? foundType, PropertyInfo
if (!ImGui.Checkbox(label, ref value)) return;
prop.SetValue(instance, value);
Plugin.Config.Save();
customApply?.Invoke();
}
else if (foundType == FieldType.InputInt)
{
Expand Down
17 changes: 9 additions & 8 deletions Plugin/Ui/NumberTextures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public void CreateTextures()
var watch = Stopwatch.StartNew();
MaxTextureHeight = 0;
MaxTextureWidth = 0;

var createAltTextures = Plugin.Config.Countdown.Animate;

var success = false;
for (var i = 0; i < 10; i++)
Expand All @@ -156,24 +158,23 @@ public void CreateTextures()
{
var bytes = image.Data.ToArray();
var bytesAlt = new byte[bytes.Length];
var configuration = Plugin.Config;
if (image.NumChannels == 4)
for (var p = 0; p < bytes.Length; p += 4)
{
var originalRgb = new HslConv.Rgb(bytes[p], bytes[p + 1], bytes[p + 2]);
var hsl = HslConv.RgbToHsl(originalRgb);
if (configuration.Countdown.NumberRecolorMode)
hsl.H = Math.Clamp(configuration.Countdown.Hue, 0, 360);
if (Plugin.Config.Countdown.NumberRecolorMode)
hsl.H = Math.Clamp(Plugin.Config.Countdown.Hue, 0, 360);
else
hsl.H += configuration.Countdown.Hue;
hsl.S = Math.Clamp(hsl.S + configuration.Countdown.Saturation, 0f, 1f);
hsl.L = Math.Clamp(hsl.L + configuration.Countdown.Luminance, 0f, 1f);
hsl.H += Plugin.Config.Countdown.Hue;
hsl.S = Math.Clamp(hsl.S + Plugin.Config.Countdown.Saturation, 0f, 1f);
hsl.L = Math.Clamp(hsl.L + Plugin.Config.Countdown.Luminance, 0f, 1f);
var modifiedRgb = HslConv.HslToRgb(hsl);
bytes[p] = modifiedRgb.R;
bytes[p + 1] = modifiedRgb.G;
bytes[p + 2] = modifiedRgb.B;

if (!configuration.Countdown.Animate) continue;
if (!createAltTextures) continue;
var hslAlt = new HslConv.Hsl(hsl.H, hsl.S, hsl.L);
hslAlt.L = Math.Clamp(hslAlt.L + .3f, 0f, 1f);
var modifiedRgbAlt = HslConv.HslToRgb(hslAlt);
Expand All @@ -197,7 +198,7 @@ public void CreateTextures()
_numberTextures.Add(i, texture);
success = true;

if (!configuration.Countdown.Animate) continue;
if (!createAltTextures) continue;
_numberTexturesAlt.Remove(i);
_numberTexturesAlt.Add(i, textureAlt);
}
Expand Down
2 changes: 0 additions & 2 deletions Plugin/Ui/SettingsTab/CountdownTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public static void DebounceTextureCreation()


private static bool _mocking;
private static double _mockStart;
private static double _mockTarget;

public static void UpdateMock()
Expand All @@ -75,7 +74,6 @@ private static void ToggleMock()
Plugin.State.InCombat = false;
Plugin.State.CountDownValue = 12.23f;
Plugin.State.CountingDown = true;
_mockStart = ImGui.GetTime();
}
else
{
Expand Down

0 comments on commit 9e9e036

Please sign in to comment.