Skip to content

Commit

Permalink
fix countdown being rounded instead of floored in floating window whe…
Browse files Browse the repository at this point in the history
…n disabling decimals
  • Loading branch information
xorus committed Jul 5, 2024
1 parent 41bc560 commit 8173ff5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Plugin/EngageTimer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AssemblyVersion>2.4.0.0</AssemblyVersion>
<AssemblyVersion>2.4.0.1</AssemblyVersion>
<Deterministic>false</Deterministic>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
2 changes: 1 addition & 1 deletion Plugin/EngageTimer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ changelog: |-
- Use new texture loading for countdown
- Migrate to the new font system, the floating window contents might be blurry, this will be fixed soon when I
can implement font customization instead of always using the default dalamud one
- Fix countdown being rounded instead of floored in floating window when disabling decimals
5 changes: 3 additions & 2 deletions Plugin/Ui/FloatingWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void DrawWindow(bool stopwatchActive, bool countdownActive)
pushVar = true;
ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0);
}

ImGui.PushStyleColor(ImGuiCol.WindowBg, Plugin.Config.FloatingWindow.BackgroundColor);

var flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoScrollbar |
Expand All @@ -94,7 +94,7 @@ private void DrawWindow(bool stopwatchActive, bool countdownActive)

ImGui.PushStyleColor(ImGuiCol.Text, color);
ImGui.SetWindowFontScale(Plugin.Config.FloatingWindow.Scale);

var stopwatchDecimals = Plugin.Config.FloatingWindow.DecimalStopwatchPrecision > 0;

var text = ""; // text to be displayed
Expand All @@ -117,6 +117,7 @@ private void DrawWindow(bool stopwatchActive, bool countdownActive)
var format = "{0:0." + new string('0', Plugin.Config.FloatingWindow.DecimalCountdownPrecision) +
"}";
var number = Plugin.State.CountDownValue + (Plugin.Config.FloatingWindow.AccurateMode ? 0 : 1);
if (Plugin.Config.FloatingWindow.DecimalCountdownPrecision == 0) number = (float)Math.Floor(number);
text = negative + string.Format(CultureInfo.InvariantCulture, format, number);
displayed = true;
}
Expand Down

0 comments on commit 8173ff5

Please sign in to comment.