From 1125077be3746b2184c0bf386db37da8c686fd97 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Fri, 8 Jul 2022 14:19:50 +0200 Subject: [PATCH] fix empty comment crashing mare main UI --- MareSynchronos/MareSynchronos.csproj | 2 +- MareSynchronos/UI/CompactUI.cs | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/MareSynchronos/MareSynchronos.csproj b/MareSynchronos/MareSynchronos.csproj index 607b84d..569fcb4 100644 --- a/MareSynchronos/MareSynchronos.csproj +++ b/MareSynchronos/MareSynchronos.csproj @@ -3,7 +3,7 @@ - 0.1.2.0 + 0.1.3.0 https://github.com/Penumbra-Sync/client diff --git a/MareSynchronos/UI/CompactUI.cs b/MareSynchronos/UI/CompactUI.cs index b5c542b..93ddad4 100644 --- a/MareSynchronos/UI/CompactUI.cs +++ b/MareSynchronos/UI/CompactUI.cs @@ -134,7 +134,7 @@ namespace MareSynchronos.UI } private string _editCharComment = string.Empty; - + private void DrawPairedClient(ClientPairDto entry) { ImGui.PushID(entry.OtherUID); @@ -143,7 +143,7 @@ namespace MareSynchronos.UI var buttonSize = GetIconButtonSize(pauseIcon); var trashButtonSize = GetIconButtonSize(FontAwesomeIcon.Trash); - var textSize = ImGui.CalcTextSize(_apiController.SystemInfoDto.CpuUsage.ToString("0.00") + "%"); + var textSize = ImGui.CalcTextSize(entry.OtherUID); var originalY = ImGui.GetCursorPosY(); var textPos = originalY + buttonSize.Y / 2 - textSize.Y / 2; @@ -178,14 +178,18 @@ namespace MareSynchronos.UI _showUidForEntry.TryGetValue(entry.OtherUID, out bool showUidInsteadOfName); if (!showUidInsteadOfName && _configuration.GetCurrentServerUidComments().TryGetValue(entry.OtherUID, out playerText)) { - if (!playerText.IsNullOrEmpty()) - { - textIsUid = false; - } - else + if (playerText.IsNullOrEmpty()) { playerText = entry.OtherUID; } + else + { + textIsUid = false; + } + } + else + { + playerText = entry.OtherUID; } ImGui.SameLine(); @@ -193,7 +197,7 @@ namespace MareSynchronos.UI { ImGui.SetCursorPosY(textPos); if (textIsUid) ImGui.PushFont(UiBuilder.MonoFont); - ImGui.Text(playerText); + ImGui.TextUnformatted(playerText); if (textIsUid) ImGui.PopFont(); AttachToolTip("Left click to switch between UID display and nick" + Environment.NewLine + "Right click to change nick for " + entry.OtherUID); @@ -244,7 +248,7 @@ namespace MareSynchronos.UI } AttachToolTip("Hold CTRL and click to unpair permanently from " + entry.OtherUID); - ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + ImGui.GetWindowContentRegionWidth() - buttonSize.X - trashButtonSize.X); + ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + ImGui.GetWindowContentRegionWidth() - buttonSize.X - ImGui.GetStyle().ItemSpacing.X - trashButtonSize.X); ImGui.SetCursorPosY(originalY); if (ImGuiComponents.IconButton(pauseIcon)) {