fix empty comment crashing mare main UI

This commit is contained in:
Stanley Dimant
2022-07-08 14:19:50 +02:00
parent 32788be43b
commit 1125077be3
2 changed files with 14 additions and 10 deletions

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>0.1.2.0</Version> <Version>0.1.3.0</Version>
<Description></Description> <Description></Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl> <PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -134,7 +134,7 @@ namespace MareSynchronos.UI
} }
private string _editCharComment = string.Empty; private string _editCharComment = string.Empty;
private void DrawPairedClient(ClientPairDto entry) private void DrawPairedClient(ClientPairDto entry)
{ {
ImGui.PushID(entry.OtherUID); ImGui.PushID(entry.OtherUID);
@@ -143,7 +143,7 @@ namespace MareSynchronos.UI
var buttonSize = GetIconButtonSize(pauseIcon); var buttonSize = GetIconButtonSize(pauseIcon);
var trashButtonSize = GetIconButtonSize(FontAwesomeIcon.Trash); 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 originalY = ImGui.GetCursorPosY();
var textPos = originalY + buttonSize.Y / 2 - textSize.Y / 2; var textPos = originalY + buttonSize.Y / 2 - textSize.Y / 2;
@@ -178,14 +178,18 @@ namespace MareSynchronos.UI
_showUidForEntry.TryGetValue(entry.OtherUID, out bool showUidInsteadOfName); _showUidForEntry.TryGetValue(entry.OtherUID, out bool showUidInsteadOfName);
if (!showUidInsteadOfName && _configuration.GetCurrentServerUidComments().TryGetValue(entry.OtherUID, out playerText)) if (!showUidInsteadOfName && _configuration.GetCurrentServerUidComments().TryGetValue(entry.OtherUID, out playerText))
{ {
if (!playerText.IsNullOrEmpty()) if (playerText.IsNullOrEmpty())
{
textIsUid = false;
}
else
{ {
playerText = entry.OtherUID; playerText = entry.OtherUID;
} }
else
{
textIsUid = false;
}
}
else
{
playerText = entry.OtherUID;
} }
ImGui.SameLine(); ImGui.SameLine();
@@ -193,7 +197,7 @@ namespace MareSynchronos.UI
{ {
ImGui.SetCursorPosY(textPos); ImGui.SetCursorPosY(textPos);
if (textIsUid) ImGui.PushFont(UiBuilder.MonoFont); if (textIsUid) ImGui.PushFont(UiBuilder.MonoFont);
ImGui.Text(playerText); ImGui.TextUnformatted(playerText);
if (textIsUid) ImGui.PopFont(); if (textIsUid) ImGui.PopFont();
AttachToolTip("Left click to switch between UID display and nick" + Environment.NewLine + AttachToolTip("Left click to switch between UID display and nick" + Environment.NewLine +
"Right click to change nick for " + entry.OtherUID); "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); 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); ImGui.SetCursorPosY(originalY);
if (ImGuiComponents.IconButton(pauseIcon)) if (ImGuiComponents.IconButton(pauseIcon))
{ {