improved settings with sounds bug fix

This commit is contained in:
choco
2025-10-11 00:46:18 +02:00
parent f5339dc1d2
commit e13fde3d43
7 changed files with 325 additions and 172 deletions

View File

@@ -3140,24 +3140,20 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Separator();
if (_uiShared.MediumTreeNode("Basic Settings", UIColors.Get("LightlessPurple")))
{
int defaultDuration = _configService.Current.DefaultNotificationDurationSeconds;
if (ImGui.SliderInt("Default Duration (seconds)", ref defaultDuration, 3, 60))
int maxNotifications = _configService.Current.MaxSimultaneousNotifications;
if (ImGui.SliderInt("Max Simultaneous Notifications", ref maxNotifications, 1, 10))
{
_configService.Current.DefaultNotificationDurationSeconds = defaultDuration;
_configService.Current.MaxSimultaneousNotifications = maxNotifications;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.DefaultNotificationDurationSeconds = 10;
_configService.Current.MaxSimultaneousNotifications = 5;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (10 seconds).");
_uiShared.DrawHelpText("How long notifications stay visible by default.");
ImGui.SetTooltip("Right click to reset to default (5).");
_uiShared.DrawHelpText("Maximum number of notifications that can be shown at once.");
bool showTimestamp = _configService.Current.ShowNotificationTimestamp;
if (ImGui.Checkbox("Show Timestamps", ref showTimestamp))
@@ -3205,32 +3201,38 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Transparency level of notification windows.");
bool enableAnimations = _configService.Current.EnableNotificationAnimations;
if (ImGui.Checkbox("Enable Animations", ref enableAnimations))
ImGui.Spacing();
ImGui.TextUnformatted("Size & Layout");
float notifWidth = _configService.Current.NotificationWidth;
if (ImGui.SliderFloat("Notification Width", ref notifWidth, 250f, 600f, "%.0f"))
{
_configService.Current.EnableNotificationAnimations = enableAnimations;
_configService.Current.NotificationWidth = notifWidth;
_configService.Save();
}
_uiShared.DrawHelpText("Enable slide-in/out animations for notifications.");
int maxNotifications = _configService.Current.MaxSimultaneousNotifications;
if (ImGui.SliderInt("Max Simultaneous Notifications", ref maxNotifications, 1, 10))
{
_configService.Current.MaxSimultaneousNotifications = maxNotifications;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.MaxSimultaneousNotifications = 5;
_configService.Current.NotificationWidth = 350f;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (5).");
ImGui.SetTooltip("Right click to reset to default (350).");
_uiShared.DrawHelpText("Width of notification windows.");
_uiShared.DrawHelpText("Maximum number of notifications that can be shown at once.");
float notifSpacing = _configService.Current.NotificationSpacing;
if (ImGui.SliderFloat("Notification Spacing", ref notifSpacing, 0f, 30f, "%.0f"))
{
_configService.Current.NotificationSpacing = notifSpacing;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.NotificationSpacing = 8f;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (8).");
_uiShared.DrawHelpText("Gap between stacked notifications.");
ImGui.Spacing();
ImGui.TextUnformatted("Position");
@@ -3241,23 +3243,151 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.NotificationOffsetY = offsetY;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.NotificationOffsetY = 50;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (50).");
_uiShared.DrawHelpText("Move notifications down from the top-right corner.");
_uiShared.DrawHelpText("Move notifications down from the top-right corner. 0 aligns to the very top.");
int offsetX = _configService.Current.NotificationOffsetX;
if (ImGui.SliderInt("Horizontal Offset", ref offsetX, 0, 500))
{
_configService.Current.NotificationOffsetX = offsetX;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.NotificationOffsetX = 0;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (0).");
_uiShared.DrawHelpText("Move notifications left from the right edge.");
ImGui.Spacing();
ImGui.TextUnformatted("Animation Settings");
float animSpeed = _configService.Current.NotificationAnimationSpeed;
if (ImGui.SliderFloat("Animation Speed", ref animSpeed, 1f, 30f, "%.1f"))
{
_configService.Current.NotificationAnimationSpeed = animSpeed;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.NotificationAnimationSpeed = 10f;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (10).");
_uiShared.DrawHelpText("How fast notifications slide in/out. Higher = faster.");
ImGui.Spacing();
ImGui.TextUnformatted("Visual Effects");
float accentWidth = _configService.Current.NotificationAccentBarWidth;
if (ImGui.SliderFloat("Accent Bar Width", ref accentWidth, 0f, 10f, "%.1f"))
{
_configService.Current.NotificationAccentBarWidth = accentWidth;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.NotificationAccentBarWidth = 3f;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (3).");
_uiShared.DrawHelpText("Width of the colored accent bar on the left side.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
}
ImGui.Separator();
if (_uiShared.MediumTreeNode("Duration Settings", UIColors.Get("LightlessPurple")))
{
UiSharedService.ColorTextWrapped("Configure how long each notification type stays visible.", ImGuiColors.DalamudGrey);
ImGuiHelpers.ScaledDummy(5);
int infoDuration = _configService.Current.InfoNotificationDurationSeconds;
if (ImGui.SliderInt("Info Duration (seconds)", ref infoDuration, 3, 60))
{
_configService.Current.InfoNotificationDurationSeconds = infoDuration;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.InfoNotificationDurationSeconds = 10;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (10).");
int warningDuration = _configService.Current.WarningNotificationDurationSeconds;
if (ImGui.SliderInt("Warning Duration (seconds)", ref warningDuration, 3, 60))
{
_configService.Current.WarningNotificationDurationSeconds = warningDuration;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.WarningNotificationDurationSeconds = 15;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (15).");
int errorDuration = _configService.Current.ErrorNotificationDurationSeconds;
if (ImGui.SliderInt("Error Duration (seconds)", ref errorDuration, 3, 120))
{
_configService.Current.ErrorNotificationDurationSeconds = errorDuration;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.ErrorNotificationDurationSeconds = 20;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (20).");
int pairRequestDuration = _configService.Current.PairRequestDurationSeconds;
if (ImGui.SliderInt("Pair Request Duration (seconds)", ref pairRequestDuration, 30, 600))
{
_configService.Current.PairRequestDurationSeconds = pairRequestDuration;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.PairRequestDurationSeconds = 180;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (180).");
int downloadDuration = _configService.Current.DownloadNotificationDurationSeconds;
if (ImGui.SliderInt("Download Duration (seconds)", ref downloadDuration, 60, 600))
{
_configService.Current.DownloadNotificationDurationSeconds = downloadDuration;
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
_configService.Current.DownloadNotificationDurationSeconds = 300;
_configService.Save();
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (300).");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
if (_uiShared.MediumTreeNode("Sound Settings", UIColors.Get("LightlessPurple")))
{
@@ -3399,10 +3529,10 @@ public class SettingsUi : WindowMediatorSubscriberBase
var soundEffects = new[]
{
(1u, "Se1 - Soft chime"), (2u, "Se2 - Higher chime"), (3u, "Se3 - Bell tone"), (4u, "Se4 - Harp tone"),
(5u, "Se5 - Drum/percussion"), (6u, "Se6 - Mechanical click"), (7u, "Se7 - Metallic chime"),
(8u, "Se8 - Wooden tone"), (9u, "Se9 - Wind/flute tone"), (10u, "Se10 - Magical sparkle"),
(11u, "Se11 - Metallic ring"), (12u, "Se12 - Deep thud"), (13u, "Se13 - Tell received ping"),
(14u, "Se14 - Success fanfare"), (15u, "Se15 - System warning"), (16u, "Se16 - Error/failure")
(5u, "Se5 - Mechanical click"), (6u, "Se6 - Drum/percussion"), (7u, "Se7 - Metallic chime"),
(8u, "Se8 - Wooden tone"), (9u, "Se9 - Wind/flute tone"), (11u, "Se10 - Magical sparkle"),
(12u, "Se11 - Metallic ring"), (13u, "Se12 - Deep thud"), (14u, "Se13 - Tell received ping"),
(15u, "Se14 - Success fanfare"), (16u, "Se15 - System warning")
};
if (ImGui.BeginTable("##SoundTable", 3,
@@ -3410,15 +3540,16 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, 120 * ImGuiHelpers.GlobalScale);
ImGui.TableSetupColumn("Sound", ImGuiTableColumnFlags.WidthStretch, 280 * ImGuiHelpers.GlobalScale);
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.WidthFixed, 80 * ImGuiHelpers.GlobalScale);
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.WidthFixed, 120 * ImGuiHelpers.GlobalScale);
ImGui.TableHeadersRow();
var soundTypes = new[]
{
("Info", 0, _configService.Current.CustomInfoSoundId, _configService.Current.DisableInfoSound, 2u),
("Warning", 1, _configService.Current.CustomWarningSoundId, _configService.Current.DisableWarningSound, 15u),
("Warning", 1, _configService.Current.CustomWarningSoundId, _configService.Current.DisableWarningSound, 16u),
("Error", 2, _configService.Current.CustomErrorSoundId, _configService.Current.DisableErrorSound, 16u),
("Pair Request", 3, _configService.Current.PairRequestSoundId, _configService.Current.DisablePairRequestSound, 5u)
("Pair Request", 3, _configService.Current.PairRequestSoundId, _configService.Current.DisablePairRequestSound, 5u),
("Download", 4, _configService.Current.DownloadSoundId, _configService.Current.DisableDownloadSound, 15u)
};
foreach (var (typeName, typeIndex, currentSoundId, isDisabled, defaultSoundId) in soundTypes)
@@ -3448,56 +3579,38 @@ public class SettingsUi : WindowMediatorSubscriberBase
case 1: _configService.Current.CustomWarningSoundId = newSoundId; break;
case 2: _configService.Current.CustomErrorSoundId = newSoundId; break;
case 3: _configService.Current.PairRequestSoundId = newSoundId; break;
case 4: _configService.Current.DownloadSoundId = newSoundId; break;
}
_configService.Save();
}
ImGui.SameLine();
ImGui.PushID($"test_{typeIndex}");
if (_uiShared.IconButton(FontAwesomeIcon.Play))
{
try
{
FFXIVClientStructs.FFXIV.Client.UI.UIGlobals.PlayChatSoundEffect(currentSoundId);
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Failed to play test sound");
}
}
ImGui.PopID();
UiSharedService.AttachToolTip("Test this sound");
}
// Actions column
ImGui.TableSetColumnIndex(2);
var availableWidth = ImGui.GetContentRegionAvail().X;
var buttonWidth = (availableWidth - ImGui.GetStyle().ItemSpacing.X) / 2;
var buttonWidth = (availableWidth - ImGui.GetStyle().ItemSpacing.X * 2) / 3;
// Reset button
using var resetId = ImRaii.PushId($"Reset_{typeIndex}");
bool isDefault = currentSoundId == defaultSoundId;
using (ImRaii.Disabled(isDefault))
// Play button
using var playId = ImRaii.PushId($"Play_{typeIndex}");
using (ImRaii.Disabled(isDisabled))
{
using (ImRaii.PushFont(UiBuilder.IconFont))
{
if (ImGui.Button(FontAwesomeIcon.Undo.ToIconString(), new Vector2(buttonWidth, 0)))
if (ImGui.Button(FontAwesomeIcon.Play.ToIconString(), new Vector2(buttonWidth, 0)))
{
switch (typeIndex)
try
{
case 0: _configService.Current.CustomInfoSoundId = defaultSoundId; break;
case 1: _configService.Current.CustomWarningSoundId = defaultSoundId; break;
case 2: _configService.Current.CustomErrorSoundId = defaultSoundId; break;
case 3: _configService.Current.PairRequestSoundId = defaultSoundId; break;
FFXIVClientStructs.FFXIV.Client.UI.UIGlobals.PlayChatSoundEffect(currentSoundId);
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Failed to play test sound");
}
_configService.Save();
}
}
}
UiSharedService.AttachToolTip(isDefault ? "Sound is already at default value" : "Reset to default sound");
UiSharedService.AttachToolTip("Test this sound");
// Disable toggle button
ImGui.SameLine();
@@ -3520,6 +3633,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
case 1: _configService.Current.DisableWarningSound = newDisabled; break;
case 2: _configService.Current.DisableErrorSound = newDisabled; break;
case 3: _configService.Current.DisablePairRequestSound = newDisabled; break;
case 4: _configService.Current.DisableDownloadSound = newDisabled; break;
}
_configService.Save();
}
@@ -3527,6 +3641,31 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.PopStyleColor(3);
}
UiSharedService.AttachToolTip(isDisabled ? "Sound is disabled - click to enable" : "Sound is enabled - click to disable");
// Reset button
ImGui.SameLine();
using var resetId = ImRaii.PushId($"Reset_{typeIndex}");
bool isDefault = currentSoundId == defaultSoundId;
using (ImRaii.Disabled(isDefault))
{
using (ImRaii.PushFont(UiBuilder.IconFont))
{
if (ImGui.Button(FontAwesomeIcon.Undo.ToIconString(), new Vector2(buttonWidth, 0)))
{
switch (typeIndex)
{
case 0: _configService.Current.CustomInfoSoundId = defaultSoundId; break;
case 1: _configService.Current.CustomWarningSoundId = defaultSoundId; break;
case 2: _configService.Current.CustomErrorSoundId = defaultSoundId; break;
case 3: _configService.Current.PairRequestSoundId = defaultSoundId; break;
case 4: _configService.Current.DownloadSoundId = defaultSoundId; break;
}
_configService.Save();
}
}
}
UiSharedService.AttachToolTip(isDefault ? "Sound is already at default value" : "Reset to default sound");
}
ImGui.EndTable();