add chat message scaling
This commit is contained in:
@@ -12,4 +12,5 @@ public sealed class ChatConfig : ILightlessConfiguration
|
|||||||
public float ChatWindowOpacity { get; set; } = .97f;
|
public float ChatWindowOpacity { get; set; } = .97f;
|
||||||
public bool IsWindowPinned { get; set; } = false;
|
public bool IsWindowPinned { get; set; } = false;
|
||||||
public bool AutoOpenChatOnPluginLoad { get; set; } = false;
|
public bool AutoOpenChatOnPluginLoad { get; set; } = false;
|
||||||
|
public float ChatFontScale { get; set; } = 1.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
|||||||
private const float DefaultWindowOpacity = .97f;
|
private const float DefaultWindowOpacity = .97f;
|
||||||
private const float MinWindowOpacity = 0.05f;
|
private const float MinWindowOpacity = 0.05f;
|
||||||
private const float MaxWindowOpacity = 1f;
|
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 ReportReasonMaxLength = 500;
|
||||||
private const int ReportContextMaxLength = 1000;
|
private const int ReportContextMaxLength = 1000;
|
||||||
|
|
||||||
@@ -215,6 +217,14 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
|||||||
if (!child)
|
if (!child)
|
||||||
return;
|
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 drawList = ImGui.GetWindowDrawList();
|
||||||
var windowPos = ImGui.GetWindowPos();
|
var windowPos = ImGui.GetWindowPos();
|
||||||
var windowSize = ImGui.GetWindowSize();
|
var windowSize = ImGui.GetWindowSize();
|
||||||
@@ -284,6 +294,11 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
|||||||
ImGui.SetScrollHereY(1f);
|
ImGui.SetScrollHereY(1f);
|
||||||
_scrollToBottom = false;
|
_scrollToBottom = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (restoreFontScale)
|
||||||
|
{
|
||||||
|
ImGui.SetWindowFontScale(1f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawInput(ChatChannelSnapshot channel)
|
private void DrawInput(ChatChannelSnapshot channel)
|
||||||
@@ -1122,6 +1137,25 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
|||||||
ImGui.SetTooltip("Toggles the timestamp prefix on messages.");
|
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 windowOpacity = Math.Clamp(chatConfig.ChatWindowOpacity, MinWindowOpacity, MaxWindowOpacity);
|
||||||
var opacityChanged = ImGui.SliderFloat("Window transparency", ref windowOpacity, MinWindowOpacity, MaxWindowOpacity, "%.2f");
|
var opacityChanged = ImGui.SliderFloat("Window transparency", ref windowOpacity, MinWindowOpacity, MaxWindowOpacity, "%.2f");
|
||||||
var resetOpacity = ImGui.IsItemClicked(ImGuiMouseButton.Right);
|
var resetOpacity = ImGui.IsItemClicked(ImGuiMouseButton.Right);
|
||||||
|
|||||||
Reference in New Issue
Block a user