implemened game sound effects for notifs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Plugin.Services;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.LightlessConfiguration.Models;
|
||||
using LightlessSync.Services.Mediator;
|
||||
@@ -6,6 +7,8 @@ using LightlessSync.UI;
|
||||
using LightlessSync.UI.Models;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
|
||||
namespace LightlessSync.Services;
|
||||
public class LightlessNotificationService : DisposableMediatorSubscriberBase, IHostedService
|
||||
{
|
||||
@@ -48,7 +51,6 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
SoundEffectId = soundEffectId ?? NotificationSounds.GetDefaultSound(type)
|
||||
};
|
||||
|
||||
// Play sound effect if specified
|
||||
if (notification.SoundEffectId.HasValue)
|
||||
{
|
||||
PlayNotificationSound(notification.SoundEffectId.Value);
|
||||
@@ -100,7 +102,6 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
}
|
||||
};
|
||||
|
||||
// Play sound effect
|
||||
if (notification.SoundEffectId.HasValue)
|
||||
{
|
||||
PlayNotificationSound(notification.SoundEffectId.Value);
|
||||
@@ -140,7 +141,6 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
SoundEffectId = NotificationSounds.DownloadComplete
|
||||
};
|
||||
|
||||
// Play sound effect
|
||||
if (notification.SoundEffectId.HasValue)
|
||||
{
|
||||
PlayNotificationSound(notification.SoundEffectId.Value);
|
||||
@@ -188,7 +188,6 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
SoundEffectId = NotificationSounds.Error
|
||||
};
|
||||
|
||||
// Play sound effect
|
||||
if (notification.SoundEffectId.HasValue)
|
||||
{
|
||||
PlayNotificationSound(notification.SoundEffectId.Value);
|
||||
@@ -198,7 +197,6 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
}
|
||||
public void ShowPairDownloadNotification(List<(string playerName, float progress, string status)> downloadStatus, int queueWaiting = 0)
|
||||
{
|
||||
// Filter out queue status from user downloads
|
||||
var userDownloads = downloadStatus.Where(x => x.playerName != "Pair Queue").ToList();
|
||||
|
||||
var totalProgress = userDownloads.Count > 0 ? userDownloads.Average(x => x.progress) : 0f;
|
||||
@@ -207,13 +205,11 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
|
||||
var message = "";
|
||||
|
||||
// Add queue status at the top if there are waiting items
|
||||
if (queueWaiting > 0)
|
||||
{
|
||||
message = $"Queue: {queueWaiting} waiting";
|
||||
}
|
||||
|
||||
// Add download progress if there are downloads
|
||||
if (totalCount > 0)
|
||||
{
|
||||
var progressMessage = $"Progress: {completedCount}/{totalCount} completed";
|
||||
@@ -240,7 +236,6 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
message += string.IsNullOrEmpty(message) ? downloadLines : $"\n{downloadLines}";
|
||||
}
|
||||
|
||||
// Check if all downloads are completed
|
||||
var allDownloadsCompleted = userDownloads.All(x => x.progress >= 1.0f) && userDownloads.Any();
|
||||
|
||||
var notification = new LightlessNotification
|
||||
@@ -259,6 +254,7 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
DismissPairDownloadNotification();
|
||||
}
|
||||
}
|
||||
|
||||
public void DismissPairDownloadNotification()
|
||||
{
|
||||
Mediator.Publish(new LightlessNotificationDismissMessage("pair_download_progress"));
|
||||
@@ -268,15 +264,15 @@ public class LightlessNotificationService : DisposableMediatorSubscriberBase, IH
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: Implement proper sound playback
|
||||
// The ChatGui.PlaySoundEffect method doesn't exist in the current Dalamud API
|
||||
// For now, just log what sound would be played
|
||||
_logger.LogDebug("Would play notification sound effect {SoundId}", soundEffectId);
|
||||
|
||||
// Future implementation options:
|
||||
// 1. Use UIModule->PlaySound() with proper unsafe interop
|
||||
// 2. Use game's sound system through SigScanner
|
||||
// 3. Wait for official Dalamud sound API
|
||||
try
|
||||
{
|
||||
UIGlobals.PlayChatSoundEffect(soundEffectId);
|
||||
_logger.LogDebug("Played notification sound effect {SoundId} via ChatGui", soundEffectId);
|
||||
}
|
||||
catch (Exception chatEx)
|
||||
{
|
||||
_logger.LogWarning(chatEx, "Failed to play sound via ChatGui for ID {SoundId}", soundEffectId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user