From 8076d63ce277cf4392ee7c9d0feb2549efb75d39 Mon Sep 17 00:00:00 2001 From: azyges Date: Sun, 30 Nov 2025 21:35:17 +0900 Subject: [PATCH] add chat message scaling --- .../Configurations/ChatConfig.cs | 1 + LightlessSync/UI/ZoneChatUi.cs | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/LightlessSync/LightlessConfiguration/Configurations/ChatConfig.cs b/LightlessSync/LightlessConfiguration/Configurations/ChatConfig.cs index 7812887..9065b81 100644 --- a/LightlessSync/LightlessConfiguration/Configurations/ChatConfig.cs +++ b/LightlessSync/LightlessConfiguration/Configurations/ChatConfig.cs @@ -12,4 +12,5 @@ public sealed class ChatConfig : ILightlessConfiguration public float ChatWindowOpacity { get; set; } = .97f; public bool IsWindowPinned { get; set; } = false; public bool AutoOpenChatOnPluginLoad { get; set; } = false; + public float ChatFontScale { get; set; } = 1.0f; } diff --git a/LightlessSync/UI/ZoneChatUi.cs b/LightlessSync/UI/ZoneChatUi.cs index c3ed2da..aeddbbb 100644 --- a/LightlessSync/UI/ZoneChatUi.cs +++ b/LightlessSync/UI/ZoneChatUi.cs @@ -33,6 +33,8 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase private const float DefaultWindowOpacity = .97f; private const float MinWindowOpacity = 0.05f; private const float MaxWindowOpacity = 1f; + private const float MinChatFontScale = 0.75f; + private const float MaxChatFontScale = 1.5f; private const int ReportReasonMaxLength = 500; private const int ReportContextMaxLength = 1000; @@ -215,6 +217,14 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase if (!child) return; + var configuredFontScale = Math.Clamp(_chatConfigService.Current.ChatFontScale, MinChatFontScale, MaxChatFontScale); + var restoreFontScale = false; + if (Math.Abs(configuredFontScale - 1f) > 0.001f) + { + ImGui.SetWindowFontScale(configuredFontScale); + restoreFontScale = true; + } + var drawList = ImGui.GetWindowDrawList(); var windowPos = ImGui.GetWindowPos(); var windowSize = ImGui.GetWindowSize(); @@ -284,6 +294,11 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase ImGui.SetScrollHereY(1f); _scrollToBottom = false; } + + if (restoreFontScale) + { + ImGui.SetWindowFontScale(1f); + } } private void DrawInput(ChatChannelSnapshot channel) @@ -1122,6 +1137,25 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase ImGui.SetTooltip("Toggles the timestamp prefix on messages."); } + var fontScale = Math.Clamp(chatConfig.ChatFontScale, MinChatFontScale, MaxChatFontScale); + var fontScaleChanged = ImGui.SliderFloat("Message font scale", ref fontScale, MinChatFontScale, MaxChatFontScale, "%.2fx"); + var resetFontScale = ImGui.IsItemClicked(ImGuiMouseButton.Right); + if (resetFontScale) + { + fontScale = 1.0f; + fontScaleChanged = true; + } + + if (fontScaleChanged) + { + chatConfig.ChatFontScale = fontScale; + _chatConfigService.Save(); + } + if (ImGui.IsItemHovered()) + { + ImGui.SetTooltip("Adjusts the scale of chat message text.\nRight-click to reset."); + } + var windowOpacity = Math.Clamp(chatConfig.ChatWindowOpacity, MinWindowOpacity, MaxWindowOpacity); var opacityChanged = ImGui.SliderFloat("Window transparency", ref windowOpacity, MinWindowOpacity, MaxWindowOpacity, "%.2f"); var resetOpacity = ImGui.IsItemClicked(ImGuiMouseButton.Right);