Skip to content

Commit cdcd5e3

Browse files
committed
fix sfx and disable font picker
1 parent b40650d commit cdcd5e3

File tree

8 files changed

+81
-60
lines changed

8 files changed

+81
-60
lines changed

Plugin/Configuration/FloatingWindowConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public class FloatingWindowConfiguration
8484

8585
public int FontSize { get; set; } = 16;
8686

87-
[JsonIgnore] public IFontSpec? FontSpec { get; set; } = null;
88-
public IFontId? FontId { get; set; } = null;
87+
// [JsonIgnore] public IFontSpec? FontSpec { get; set; } = null;
88+
// public IFontSpec? Font { get; set; } = null;
8989

9090
[AutoField("Settings_FWTab_AutoHide_Left")]
9191
public bool AutoHide { get; set; } = true;

Plugin/EngageTimer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
99
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1010
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
11-
<AssemblyVersion>2.3.4.0</AssemblyVersion>
11+
<AssemblyVersion>2.4.0.0</AssemblyVersion>
1212
<Deterministic>false</Deterministic>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1414
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

Plugin/EngageTimer.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ image_urls:
3333
category_tags:
3434
- jobs
3535
changelog: |-
36-
- Fix not being able to disable alarms
37-
- Missing translation strings in web server config
38-
- Hide floating window border by default (you can re-enable it in Floating Window -> styling)
36+
- DT compatibility
37+
- Update for API10:
38+
- Use new texture loading for countdown
39+
- Migrate to the new font system, the floating window contents might be blurry, this will be fixed soon when I
40+
can implement font customization instead of always using the default dalamud one
41+

Plugin/Game/SFXPlay.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ namespace EngageTimer.Game;
2121
/**
2222
* thanks aers
2323
* sig taken from https://github.com/philpax/plogonscript/blob/main/PlogonScript/Script/Bindings/Sound.cs
24+
* https://github.com/0ceal0t/JobBars/blob/2c9bef8dd4f0bf9ebc91c07e03da6c841ac2bd35/JobBars/Helper/UiHelper.GameFunctions.cs#L61
2425
* ---
2526
* https://discord.com/channels/581875019861328007/653504487352303619/988123102116450335
2627
*/
2728
internal unsafe class GameSound
2829
{
29-
[Signature("E8 ?? ?? ?? ?? 4D 39 BE ?? ?? ?? ??")]
30+
[Signature("E8 ?? ?? ?? ?? 48 63 45 80")]
3031
public readonly delegate* unmanaged<uint, IntPtr, IntPtr, byte, void> PlaySoundEffect = null;
3132

3233
public GameSound()
@@ -45,10 +46,10 @@ public class SfxPlay
4546
public SfxPlay()
4647
{
4748
/* Force a sound to play on load as a workaround for the CLR taking some time to init the pointy method call,
48-
* we dont want a freeze midway through a countdown
49+
* we don't want a freeze midway through a countdown (or midway in combat for alarms)
4950
* https://discord.com/channels/581875019861328007/653504487352303619/988123102116450335
5051
* https://i.imgur.com/BrLUr2p.png
51-
* */
52+
*/
5253
SoundEffect(0); // should be cursor sound
5354
}
5455

Plugin/Ui/CountDown.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public sealed class CountDown : IDisposable
4343
*
4444
* In my testing, this is about 10 to 20ms.
4545
*/
46-
private bool _firstDraw = true;
46+
private int _firstDrawTicks = 5;
4747

4848
private int _lastSecond;
4949
private bool _wasInMainViewport = true;
@@ -88,9 +88,14 @@ private void FirstDraw()
8888
if (ImGui.Begin(WindowTitle, ref visible, flags))
8989
{
9090
ImGui.Text("");
91+
for (var i = 0; i <= 9; i++)
92+
{
93+
DrawNumber(false, i, 0.001f, 0f, 1f, false);
94+
DrawNumber(true, i, 0.001f, 0f, 1f, false);
95+
}
9196
}
9297

93-
_firstDraw = false;
98+
_firstDrawTicks--;
9499
}
95100

96101
public void Draw()
@@ -112,7 +117,12 @@ public void Draw()
112117
// ImGui.End();
113118
// #endif
114119

115-
if (_firstDraw) FirstDraw();
120+
if (_firstDrawTicks > 0)
121+
{
122+
FirstDraw();
123+
return;
124+
}
125+
116126
if (!Plugin.Config.Countdown.Display || !Plugin.State.CountingDown) return;
117127

118128
var showMainCountdown = Plugin.Config.Countdown.HideOriginalAddon ||
@@ -130,7 +140,7 @@ public void Draw()
130140

131141
if (Plugin.Config.Countdown.Animate)
132142
{
133-
var second = (int) Plugin.State.CountDownValue;
143+
var second = (int)Plugin.State.CountDownValue;
134144
if (_lastSecond != second)
135145
{
136146
_easing.Restart();
@@ -143,7 +153,7 @@ public void Draw()
143153
if (Plugin.Config.Countdown.AnimateScale)
144154
{
145155
maxNumberScale = numberScale + NumberEasing.StartSize;
146-
numberScale += NumberEasing.StartSize * (1 - (float) _easing.Value);
156+
numberScale += NumberEasing.StartSize * (1 - (float)_easing.Value);
147157
}
148158
}
149159
}
@@ -190,7 +200,7 @@ public void Draw()
190200
ImGui.GetWindowPos(),
191201
ImGui.GetWindowPos() + ImGui.GetWindowSize(),
192202
ImGui.GetColorU32(ImGuiCol.Text), 0f, ImDrawFlags.None,
193-
7f + (float) Math.Sin(ImGui.GetTime() * 2) * 5f);
203+
7f + (float)Math.Sin(ImGui.GetTime() * 2) * 5f);
194204
d.AddRect(
195205
ImGui.GetWindowPos(),
196206
ImGui.GetWindowPos() + ImGui.GetWindowSize(),
@@ -202,7 +212,7 @@ public void Draw()
202212
DrawCountdown(showMainCountdown, numberScale, negativeMargin, false);
203213
if (Plugin.Config.Countdown.Animate && Plugin.Config.Countdown.AnimateOpacity)
204214
{
205-
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, (float) _easingOpacity.Value);
215+
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, (float)_easingOpacity.Value);
206216
DrawCountdown(showMainCountdown, numberScale, negativeMargin, true);
207217
ImGui.PopStyleVar();
208218
}

Plugin/Ui/FloatingWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private void DrawWindow(bool stopwatchActive, bool countdownActive)
7878
pushVar = true;
7979
ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0);
8080
}
81-
81+
8282
ImGui.PushStyleColor(ImGuiCol.WindowBg, Plugin.Config.FloatingWindow.BackgroundColor);
8383

8484
var flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoScrollbar |

Plugin/Ui/FloatingWindowFont.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public void UpdateFont()
3232
this.FontHandle?.Dispose();
3333
this.FontHandle = Plugin.PluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e => e.OnPreBuild(tk =>
3434
{
35-
// tk.AddDalamudDefaultFont(
36-
// Math.Max(8, Plugin.Config.FloatingWindow.FontSize),
37-
// FontAtlasBuildToolkitUtilities.ToGlyphRange([
38-
// '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '.'
39-
// ])
40-
// );
35+
tk.AddDalamudDefaultFont(
36+
Math.Max(8, Plugin.Config.FloatingWindow.FontSize),
37+
FontAtlasBuildToolkitUtilities.ToGlyphRange([
38+
'-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '.'
39+
])
40+
);
4141
// var spec = (SingleFontSpec)(Plugin.Config.FloatingWindow.FontSpec ??
4242
// Plugin.PluginInterface.UiBuilder.DefaultFontSpec);
4343
// var specWithRanges = new SingleFontSpec()
@@ -53,9 +53,14 @@ public void UpdateFont()
5353
// ])
5454
// };
5555

56-
var spec = Plugin.Config.FloatingWindow.FontSpec ?? Plugin.PluginInterface.UiBuilder.DefaultFontSpec;
57-
spec.AddToBuildToolkit(tk);
56+
// var spec = Plugin.PluginInterface.UiBuilder.DefaultFontSpec;
57+
// spec.AddToBuildToolkit(tk, font);
58+
/// fontAtlas.NewDelegateFontHandle(
59+
/// e =&gt; e.OnPreBuild(
60+
/// tk =&gt; tk.AddDalamudDefaultFont(UiBuilder.DefaultFontSizePx)));
5861
}));
62+
63+
// this.FontHandle = Plugin.PluginInterface.UiBuilder.DefaultFontHandle
5964
}
6065

6166
public void Dispose()

Plugin/Ui/SettingsTab/FloatingWindowTab.cs

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace EngageTimer.Ui.SettingsTab;
2828

2929
public static class FloatingWindowTab
3030
{
31-
private static SingleFontChooserDialog? _fc;
31+
// private static SingleFontChooserDialog? _fc;
3232

3333
public static void Draw()
3434
{
@@ -102,6 +102,7 @@ private static void FwStyling()
102102
{
103103
configuration.FloatingWindow.FontSize = Math.Max(0, fontSize);
104104
configuration.Save();
105+
Plugin.FloatingWindowFont.UpdateFont();
105106

106107
// if (configuration.FloatingWindow.FontSize >= 8) Plugin.PluginInterface.UiBuilder.RebuildFonts();
107108
}
@@ -114,42 +115,43 @@ private static void FwStyling()
114115
Components.AutoField(Plugin.Config.FloatingWindow, "ForceHideWindowBorder");
115116
ImGui.EndGroup();
116117

117-
ImGui.Text("Font:");
118-
ImGui.SameLine();
119-
using (Plugin.FloatingWindowFont.FontHandle?.Push())
120-
{
121-
if (configuration.FloatingWindow.FontSpec == null)
122-
ImGui.Text("default");
123-
else
124-
ImGui.Text(configuration.FloatingWindow.FontSpec.ToString());
125-
}
126-
127-
if (ImGui.Button("change font") && !_fcO)
128-
{
129-
_fc = SingleFontChooserDialog.CreateAuto((UiBuilder)Plugin.PluginInterface.UiBuilder);
130-
_fcO = true;
131-
_fc.PreviewText = "-01:23.45 6789";
132-
_fc.ResultTask.ContinueWith(task =>
133-
{
134-
_fcO = false;
135-
if (!task.IsCompleted) return;
136-
configuration.FloatingWindow.FontId = _fc.SelectedFont.FontId;
137-
138-
configuration.Save();
139-
Plugin.FloatingWindowFont.UpdateFont();
140-
});
141-
}
142-
143-
ImGui.SameLine();
144-
if (ImGui.Button("reset font"))
145-
{
146-
configuration.FloatingWindow.FontSpec = null;
147-
configuration.Save();
148-
Plugin.FloatingWindowFont.UpdateFont();
149-
}
118+
// ImGui.Text("Font:");
119+
// ImGui.SameLine();
120+
// using (Plugin.FloatingWindowFont.FontHandle?.Push())
121+
// {
122+
// if (configuration.FloatingWindow.FontSpec == null)
123+
// ImGui.Text("default");
124+
// else
125+
// ImGui.Text(configuration.FloatingWindow.FontSpec.ToString());
126+
// }
127+
//
128+
// if (ImGui.Button("change font") && !_fcO)
129+
// {
130+
// _fc = SingleFontChooserDialog.CreateAuto((UiBuilder)Plugin.PluginInterface.UiBuilder);
131+
// _fcO = true;
132+
// _fc.PreviewText = "-01:23.45 6789";
133+
// _fc.ResultTask.ContinueWith(task =>
134+
// {
135+
// _fcO = false;
136+
// if (!task.IsCompleted) return;
137+
// configuration.FloatingWindow.Font = _fc.SelectedFont;
138+
//
139+
// Plugin.Logger.Info("font chosen: " + _fc.SelectedFont);
140+
//
141+
// configuration.Save();
142+
// Plugin.FloatingWindowFont.UpdateFont();
143+
// });
144+
// }
145+
// ImGui.SameLine();
146+
// if (ImGui.Button("reset font"))
147+
// {
148+
// configuration.FloatingWindow.FontSpec = null;
149+
// configuration.Save();
150+
// Plugin.FloatingWindowFont.UpdateFont();
151+
// }
150152

151153
ImGui.Unindent();
152154
}
153155

154-
private static bool _fcO = false;
156+
// private static bool _fcO = false;
155157
}

0 commit comments

Comments
 (0)