various 'improvements'
This commit is contained in:
@@ -48,7 +48,7 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
private readonly ImGuiWindowFlags _unpinnedWindowFlags;
|
||||
private float _currentWindowOpacity = DefaultWindowOpacity;
|
||||
private bool _isWindowPinned;
|
||||
private bool _showRulesOverlay = true;
|
||||
private bool _showRulesOverlay;
|
||||
|
||||
private string? _selectedChannelKey;
|
||||
private bool _scrollToBottom = true;
|
||||
@@ -165,7 +165,7 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawHeader(ChatChannelSnapshot channel)
|
||||
private static void DrawHeader(ChatChannelSnapshot channel)
|
||||
{
|
||||
var prefix = channel.Type == ChatChannelType.Zone ? "Zone" : "Syncshell";
|
||||
Vector4 color;
|
||||
@@ -577,12 +577,10 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
ImGui.Separator();
|
||||
|
||||
ImGui.TextUnformatted("Reason (required)");
|
||||
if (ImGui.InputTextMultiline("##chat_report_reason", ref _reportReason, ReportReasonMaxLength, new Vector2(-1, 80f * ImGuiHelpers.GlobalScale)))
|
||||
if (ImGui.InputTextMultiline("##chat_report_reason", ref _reportReason, ReportReasonMaxLength, new Vector2(-1, 80f * ImGuiHelpers.GlobalScale))
|
||||
&& _reportReason.Length > ReportReasonMaxLength)
|
||||
{
|
||||
if (_reportReason.Length > ReportReasonMaxLength)
|
||||
{
|
||||
_reportReason = _reportReason[..(int)ReportReasonMaxLength];
|
||||
}
|
||||
_reportReason = _reportReason[..ReportReasonMaxLength];
|
||||
}
|
||||
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey3);
|
||||
@@ -591,12 +589,10 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.TextUnformatted("Additional context (optional)");
|
||||
if (ImGui.InputTextMultiline("##chat_report_context", ref _reportAdditionalContext, ReportContextMaxLength, new Vector2(-1, 120f * ImGuiHelpers.GlobalScale)))
|
||||
if (ImGui.InputTextMultiline("##chat_report_context", ref _reportAdditionalContext, ReportContextMaxLength, new Vector2(-1, 120f * ImGuiHelpers.GlobalScale))
|
||||
&& _reportAdditionalContext.Length > ReportContextMaxLength)
|
||||
{
|
||||
if (_reportAdditionalContext.Length > ReportContextMaxLength)
|
||||
{
|
||||
_reportAdditionalContext = _reportAdditionalContext[..(int)ReportContextMaxLength];
|
||||
}
|
||||
_reportAdditionalContext = _reportAdditionalContext[..ReportContextMaxLength];
|
||||
}
|
||||
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey3);
|
||||
@@ -768,7 +764,7 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryCreateCopyMessageAction(ChatMessageEntry message, out ChatMessageContextAction action)
|
||||
private static bool TryCreateCopyMessageAction(ChatMessageEntry message, out ChatMessageContextAction action)
|
||||
{
|
||||
var text = message.Payload.Message;
|
||||
if (string.IsNullOrEmpty(text))
|
||||
@@ -920,7 +916,7 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
|
||||
private void EnsureSelectedChannel(IReadOnlyList<ChatChannelSnapshot> channels)
|
||||
{
|
||||
if (_selectedChannelKey is not null && channels.Any(channel => channel.Key == _selectedChannelKey))
|
||||
if (_selectedChannelKey is not null && channels.Any(channel => string.Equals(channel.Key, _selectedChannelKey, StringComparison.Ordinal)))
|
||||
return;
|
||||
|
||||
_selectedChannelKey = channels.Count > 0 ? channels[0].Key : null;
|
||||
@@ -1264,11 +1260,7 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
var isSelected = string.Equals(channel.Key, _selectedChannelKey, StringComparison.Ordinal);
|
||||
var showBadge = !isSelected && channel.UnreadCount > 0;
|
||||
var isZoneChannel = channel.Type == ChatChannelType.Zone;
|
||||
var badgeText = string.Empty;
|
||||
var badgePadding = Vector2.Zero;
|
||||
var badgeTextSize = Vector2.Zero;
|
||||
float badgeWidth = 0f;
|
||||
float badgeHeight = 0f;
|
||||
(string Text, Vector2 TextSize, float Width, float Height)? badgeMetrics = null;
|
||||
|
||||
var normal = isSelected ? UIColors.Get("LightlessPurpleDefault") : UIColors.Get("ButtonDefault");
|
||||
var hovered = isSelected
|
||||
@@ -1285,15 +1277,16 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
if (showBadge)
|
||||
{
|
||||
var badgeSpacing = 4f * ImGuiHelpers.GlobalScale;
|
||||
badgePadding = new Vector2(4f, 1.5f) * ImGuiHelpers.GlobalScale;
|
||||
badgeText = channel.UnreadCount > MaxBadgeDisplay
|
||||
var badgePadding = new Vector2(4f, 1.5f) * ImGuiHelpers.GlobalScale;
|
||||
var badgeText = channel.UnreadCount > MaxBadgeDisplay
|
||||
? $"{MaxBadgeDisplay}+"
|
||||
: channel.UnreadCount.ToString(CultureInfo.InvariantCulture);
|
||||
badgeTextSize = ImGui.CalcTextSize(badgeText);
|
||||
badgeWidth = badgeTextSize.X + badgePadding.X * 2f;
|
||||
badgeHeight = badgeTextSize.Y + badgePadding.Y * 2f;
|
||||
var badgeTextSize = ImGui.CalcTextSize(badgeText);
|
||||
var badgeWidth = badgeTextSize.X + badgePadding.X * 2f;
|
||||
var badgeHeight = badgeTextSize.Y + badgePadding.Y * 2f;
|
||||
var customPadding = new Vector2(baseFramePadding.X + badgeWidth + badgeSpacing, baseFramePadding.Y);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, customPadding);
|
||||
badgeMetrics = (badgeText, badgeTextSize, badgeWidth, badgeHeight);
|
||||
}
|
||||
|
||||
var clicked = ImGui.Button($"{channel.DisplayName}##chat_channel_{channel.Key}");
|
||||
@@ -1324,20 +1317,20 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
drawList.AddRect(itemMin, itemMax, borderColorU32, style.FrameRounding, ImDrawFlags.None, borderThickness);
|
||||
}
|
||||
|
||||
if (showBadge)
|
||||
if (showBadge && badgeMetrics is { } metrics)
|
||||
{
|
||||
var buttonSizeY = itemMax.Y - itemMin.Y;
|
||||
var badgeMin = new Vector2(
|
||||
itemMin.X + baseFramePadding.X,
|
||||
itemMin.Y + (buttonSizeY - badgeHeight) * 0.5f);
|
||||
var badgeMax = badgeMin + new Vector2(badgeWidth, badgeHeight);
|
||||
itemMin.Y + (buttonSizeY - metrics.Height) * 0.5f);
|
||||
var badgeMax = badgeMin + new Vector2(metrics.Width, metrics.Height);
|
||||
var badgeColor = UIColors.Get("DimRed");
|
||||
var badgeColorU32 = ImGui.ColorConvertFloat4ToU32(badgeColor);
|
||||
drawList.AddRectFilled(badgeMin, badgeMax, badgeColorU32, badgeHeight * 0.5f);
|
||||
drawList.AddRectFilled(badgeMin, badgeMax, badgeColorU32, metrics.Height * 0.5f);
|
||||
var textPos = new Vector2(
|
||||
badgeMin.X + (badgeWidth - badgeTextSize.X) * 0.5f,
|
||||
badgeMin.Y + (badgeHeight - badgeTextSize.Y) * 0.5f);
|
||||
drawList.AddText(textPos, ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudWhite), badgeText);
|
||||
badgeMin.X + (metrics.Width - metrics.TextSize.X) * 0.5f,
|
||||
badgeMin.Y + (metrics.Height - metrics.TextSize.Y) * 0.5f);
|
||||
drawList.AddText(textPos, ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudWhite), metrics.Text);
|
||||
}
|
||||
|
||||
first = false;
|
||||
|
||||
Reference in New Issue
Block a user