From d79e6871621eb6781958bfd3e774803e03756b99 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Oct 2025 15:44:26 +0200 Subject: [PATCH] Update file watcher for Luna. --- Luna | 2 +- Penumbra.GameData | 2 +- Penumbra/Services/FileWatcher.cs | 18 ++++++------- Penumbra/Services/InstallNotification.cs | 32 ++++++++++++++++-------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Luna b/Luna index 8fc11b99..c764db88 160000 --- a/Luna +++ b/Luna @@ -1 +1 @@ -Subproject commit 8fc11b993d8504982acd95b8d39e6ee7046c1347 +Subproject commit c764db88097c88cd49f2bed4f60268d617f97fdb diff --git a/Penumbra.GameData b/Penumbra.GameData index 182cca56..cf3d868e 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 182cca56a49411430233d73d7a8a6bb3d983f8f0 +Subproject commit cf3d868eeeb4ea3ea728ae15a8d09ec127ce80e9 diff --git a/Penumbra/Services/FileWatcher.cs b/Penumbra/Services/FileWatcher.cs index 1d572f05..92f5bebe 100644 --- a/Penumbra/Services/FileWatcher.cs +++ b/Penumbra/Services/FileWatcher.cs @@ -1,15 +1,14 @@ -using OtterGui.Services; +using Luna; using Penumbra.Mods.Manager; namespace Penumbra.Services; public class FileWatcher : IDisposable, IService { - // TODO: use ConcurrentSet when it supports comparers in Luna. - private readonly ConcurrentDictionary _pending = new(StringComparer.OrdinalIgnoreCase); - private readonly ModImportManager _modImportManager; - private readonly MessageService _messageService; - private readonly Configuration _config; + private readonly ConcurrentSet _pending = new(StringComparer.OrdinalIgnoreCase); + private readonly ModImportManager _modImportManager; + private readonly MessageService _messageService; + private readonly Configuration _config; private bool _pausedConsumer; private FileSystemWatcher? _fsw; @@ -89,6 +88,7 @@ public class FileWatcher : IDisposable, IService _cts.Cancel(); _cts = null; } + _consumer = null; } @@ -125,13 +125,13 @@ public class FileWatcher : IDisposable, IService } private void OnPath(object? sender, FileSystemEventArgs e) - => _pending.TryAdd(e.FullPath, 0); + => _pending.TryAdd(e.FullPath); private async Task ConsumerLoopAsync(CancellationToken token) { while (true) { - var (path, _) = _pending.FirstOrDefault(); + var path = _pending.FirstOrDefault(); if (path is null || _pausedConsumer) { await Task.Delay(500, token).ConfigureAwait(false); @@ -152,7 +152,7 @@ public class FileWatcher : IDisposable, IService } finally { - _pending.TryRemove(path, out _); + _pending.TryRemove(path); } } } diff --git a/Penumbra/Services/InstallNotification.cs b/Penumbra/Services/InstallNotification.cs index e3956076..7b0da414 100644 --- a/Penumbra/Services/InstallNotification.cs +++ b/Penumbra/Services/InstallNotification.cs @@ -1,39 +1,49 @@ using Dalamud.Bindings.ImGui; +using Dalamud.Game.Text.SeStringHandling; using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.EventArgs; -using OtterGui.Text; +using ImSharp; using Penumbra.Mods.Manager; namespace Penumbra.Services; -public class InstallNotification(ModImportManager modImportManager, string filePath) : OtterGui.Classes.MessageService.IMessage +public class InstallNotification(ModImportManager modImportManager, string filePath) : Luna.IMessage { - public string Message - => "A new mod has been found!"; - public NotificationType NotificationType => NotificationType.Info; - public uint NotificationDuration - => uint.MaxValue; + public string NotificationMessage + => "A new mod has been found!"; + + public TimeSpan NotificationDuration + => TimeSpan.MaxValue; public string NotificationTitle { get; } = Path.GetFileNameWithoutExtension(filePath); public string LogMessage => $"A new mod has been found: {Path.GetFileName(filePath)}"; + public SeString ChatMessage + => SeString.Empty; + + public StringU8 StoredMessage + => StringU8.Empty; + + public StringU8 StoredTooltip + => StringU8.Empty; + public void OnNotificationActions(INotificationDrawArgs args) { - var region = ImGui.GetContentRegionAvail(); - var buttonSize = new Vector2((region.X - ImGui.GetStyle().ItemSpacing.X) / 2, 0); - if (ImUtf8.ButtonEx("Install"u8, ""u8, buttonSize)) + var region = Im.ContentRegion.Available; + var buttonSize = new Vector2((region.X - Im.Style.ItemSpacing.X) / 2, 0); + if (Im.Button("Install"u8, buttonSize)) { modImportManager.AddUnpack(filePath); args.Notification.DismissNow(); } ImGui.SameLine(); - if (ImUtf8.ButtonEx("Ignore"u8, ""u8, buttonSize)) + if (Im.Button("Ignore"u8, buttonSize)) args.Notification.DismissNow(); } }