settings styling and sound disabled not working bugfix

This commit is contained in:
choco
2025-10-09 20:21:01 +02:00
parent cd817487e4
commit 85ecea6391
4 changed files with 990 additions and 640 deletions

View File

@@ -87,6 +87,7 @@ public class LightlessConfig : ILightlessConfiguration
public bool EnableNotificationAnimations { get; set; } = true;
public int MaxSimultaneousNotifications { get; set; } = 5;
public bool AutoDismissOnAction { get; set; } = true;
public bool DismissNotificationOnClick { get; set; } = false;
public bool ShowNotificationTimestamp { get; set; } = false;
public bool EnableNotificationHistory { get; set; } = true;
public int NotificationHistorySize { get; set; } = 50;
@@ -95,6 +96,11 @@ public class LightlessConfig : ILightlessConfiguration
public uint CustomWarningSoundId { get; set; } = 15; // Se15
public uint CustomErrorSoundId { get; set; } = 16; // Se16
public bool UseCustomSounds { get; set; } = false;
public uint PairRequestSoundId { get; set; } = 5; // Se5
public bool DisableInfoSound { get; set; } = false;
public bool DisableWarningSound { get; set; } = false;
public bool DisableErrorSound { get; set; } = false;
public bool DisablePairRequestSound { get; set; } = false;
// till here c:
public bool UseFocusTarget { get; set; } = false;
public bool overrideFriendColor { get; set; } = false;

View File

@@ -75,7 +75,7 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
}
}
if (notification.SoundEffectId.HasValue && _configService.Current.EnableNotificationSounds)
if (notification.SoundEffectId.HasValue)
{
PlayNotificationSound(notification.SoundEffectId.Value);
}
@@ -90,7 +90,7 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
Message = $"{senderName} wants to pair with you.",
Type = NotificationType.PairRequest,
Duration = TimeSpan.FromSeconds(180),
SoundEffectId = NotificationSounds.PairRequest,
SoundEffectId = !_configService.Current.DisablePairRequestSound ? _configService.Current.PairRequestSoundId : null,
Actions = new List<LightlessNotificationAction>
{
new()
@@ -286,39 +286,37 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
private uint? GetSoundEffectId(NotificationType type, uint? overrideSoundId)
{
if (!_configService.Current.EnableNotificationSounds)
return null;
if (overrideSoundId.HasValue)
return overrideSoundId;
if (_configService.Current.UseCustomSounds)
{
return type switch
{
NotificationType.Info => _configService.Current.CustomInfoSoundId,
NotificationType.Warning => _configService.Current.CustomWarningSoundId,
NotificationType.Error => _configService.Current.CustomErrorSoundId,
_ => NotificationSounds.GetDefaultSound(type)
};
}
return NotificationSounds.GetDefaultSound(type);
// Check if this specific notification type is disabled
bool isDisabled = type switch
{
NotificationType.Info => _configService.Current.DisableInfoSound,
NotificationType.Warning => _configService.Current.DisableWarningSound,
NotificationType.Error => _configService.Current.DisableErrorSound,
_ => false
};
if (isDisabled)
return null;
// Return the configured sound for this type
return type switch
{
NotificationType.Info => _configService.Current.CustomInfoSoundId,
NotificationType.Warning => _configService.Current.CustomWarningSoundId,
NotificationType.Error => _configService.Current.CustomErrorSoundId,
_ => NotificationSounds.GetDefaultSound(type)
};
}
private void PlayNotificationSound(uint soundEffectId)
{
try
{
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);
}
UIGlobals.PlayChatSoundEffect(soundEffectId);
_logger.LogDebug("Played notification sound effect {SoundId} via ChatGui", soundEffectId);
}
catch (Exception ex)
{
@@ -390,27 +388,8 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
private void ShowLightlessNotification(NotificationMessage msg)
{
var duration = msg.TimeShownOnScreen ?? TimeSpan.FromSeconds(_configService.Current.DefaultNotificationDurationSeconds);
uint? soundId = null;
if (_configService.Current.EnableNotificationSounds)
{
if (_configService.Current.UseCustomSounds)
{
soundId = msg.Type switch
{
NotificationType.Info => _configService.Current.CustomInfoSoundId,
NotificationType.Warning => _configService.Current.CustomWarningSoundId,
NotificationType.Error => _configService.Current.CustomErrorSoundId,
_ => NotificationSounds.GetDefaultSound(msg.Type)
};
}
else
{
soundId = NotificationSounds.GetDefaultSound(msg.Type);
}
}
ShowNotification(msg.Title ?? "Lightless Sync", msg.Message ?? string.Empty, msg.Type, duration, null, soundId);
// GetSoundEffectId will handle checking if the sound is disabled
ShowNotification(msg.Title ?? "Lightless Sync", msg.Message ?? string.Empty, msg.Type, duration, null, null);
}
private void ShowToast(NotificationMessage msg)

View File

@@ -248,6 +248,15 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
{
bgColor = bgColor * 1.1f;
bgColor.W = Math.Min(bgColor.W, 0.98f);
// Handle click-to-dismiss for notifications without actions
if (_configService.Current.DismissNotificationOnClick &&
!notification.Actions.Any() &&
ImGui.IsMouseClicked(ImGuiMouseButton.Left))
{
notification.IsDismissed = true;
notification.IsAnimatingOut = true;
}
}
drawList.AddRectFilled(

File diff suppressed because it is too large Load Diff