math clamping sliders for notifcation settings, pair notifs disappear now when accepted with other methods

This commit is contained in:
choco
2025-10-12 00:04:10 +02:00
parent a7475a7007
commit fe419336d7
5 changed files with 122 additions and 72 deletions

View File

@@ -3674,7 +3674,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
int maxNotifications = _configService.Current.MaxSimultaneousNotifications;
if (ImGui.SliderInt("Max Simultaneous Notifications", ref maxNotifications, 1, 10))
{
_configService.Current.MaxSimultaneousNotifications = maxNotifications;
_configService.Current.MaxSimultaneousNotifications = Math.Clamp(maxNotifications, 1, 10);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3717,7 +3717,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
float opacity = _configService.Current.NotificationOpacity;
if (ImGui.SliderFloat("Notification Opacity", ref opacity, 0.1f, 1.0f, "%.2f"))
{
_configService.Current.NotificationOpacity = opacity;
_configService.Current.NotificationOpacity = Math.Clamp(opacity, 0.1f, 1.0f);
_configService.Save();
}
@@ -3738,7 +3738,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
float notifWidth = _configService.Current.NotificationWidth;
if (ImGui.SliderFloat("Notification Width", ref notifWidth, 250f, 600f, "%.0f"))
{
_configService.Current.NotificationWidth = notifWidth;
_configService.Current.NotificationWidth = Math.Clamp(notifWidth, 250f, 600f);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3753,7 +3753,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
float notifSpacing = _configService.Current.NotificationSpacing;
if (ImGui.SliderFloat("Notification Spacing", ref notifSpacing, 0f, 30f, "%.0f"))
{
_configService.Current.NotificationSpacing = notifSpacing;
_configService.Current.NotificationSpacing = Math.Clamp(notifSpacing, 0f, 30f);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3771,7 +3771,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
int offsetY = _configService.Current.NotificationOffsetY;
if (ImGui.SliderInt("Vertical Offset", ref offsetY, 0, 500))
{
_configService.Current.NotificationOffsetY = offsetY;
_configService.Current.NotificationOffsetY = Math.Clamp(offsetY, 0, 500);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3786,7 +3786,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
int offsetX = _configService.Current.NotificationOffsetX;
if (ImGui.SliderInt("Horizontal Offset", ref offsetX, 0, 500))
{
_configService.Current.NotificationOffsetX = offsetX;
_configService.Current.NotificationOffsetX = Math.Clamp(offsetX, 0, 500);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3804,7 +3804,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
float animSpeed = _configService.Current.NotificationAnimationSpeed;
if (ImGui.SliderFloat("Animation Speed", ref animSpeed, 1f, 30f, "%.1f"))
{
_configService.Current.NotificationAnimationSpeed = animSpeed;
_configService.Current.NotificationAnimationSpeed = Math.Clamp(animSpeed, 1f, 30f);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3822,7 +3822,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
float accentWidth = _configService.Current.NotificationAccentBarWidth;
if (ImGui.SliderFloat("Accent Bar Width", ref accentWidth, 0f, 10f, "%.1f"))
{
_configService.Current.NotificationAccentBarWidth = accentWidth;
_configService.Current.NotificationAccentBarWidth = Math.Clamp(accentWidth, 0f, 10f);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3848,7 +3848,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
int infoDuration = _configService.Current.InfoNotificationDurationSeconds;
if (ImGui.SliderInt("Info Duration (seconds)", ref infoDuration, 3, 60))
{
_configService.Current.InfoNotificationDurationSeconds = infoDuration;
_configService.Current.InfoNotificationDurationSeconds = Math.Clamp(infoDuration, 3, 60);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3862,7 +3862,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
int warningDuration = _configService.Current.WarningNotificationDurationSeconds;
if (ImGui.SliderInt("Warning Duration (seconds)", ref warningDuration, 3, 60))
{
_configService.Current.WarningNotificationDurationSeconds = warningDuration;
_configService.Current.WarningNotificationDurationSeconds = Math.Clamp(warningDuration, 3, 60);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3876,7 +3876,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
int errorDuration = _configService.Current.ErrorNotificationDurationSeconds;
if (ImGui.SliderInt("Error Duration (seconds)", ref errorDuration, 3, 120))
{
_configService.Current.ErrorNotificationDurationSeconds = errorDuration;
_configService.Current.ErrorNotificationDurationSeconds = Math.Clamp(errorDuration, 3, 120);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3890,7 +3890,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
int pairRequestDuration = _configService.Current.PairRequestDurationSeconds;
if (ImGui.SliderInt("Pair Request Duration (seconds)", ref pairRequestDuration, 30, 600))
{
_configService.Current.PairRequestDurationSeconds = pairRequestDuration;
_configService.Current.PairRequestDurationSeconds = Math.Clamp(pairRequestDuration, 30, 600);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
@@ -3904,7 +3904,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
int downloadDuration = _configService.Current.DownloadNotificationDurationSeconds;
if (ImGui.SliderInt("Download Duration (seconds)", ref downloadDuration, 60, 600))
{
_configService.Current.DownloadNotificationDurationSeconds = downloadDuration;
_configService.Current.DownloadNotificationDurationSeconds = Math.Clamp(downloadDuration, 60, 600);
_configService.Save();
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))