From c610970f037925fa0752fda5d59d1850d5e715dd Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Sun, 22 Jan 2023 11:49:43 +0100 Subject: [PATCH] fix window size --- .../UI/Components/SelectGroupForPairUi.cs | 24 ++++++++----------- .../UI/Components/SelectPairForGroupUi.cs | 18 +++++++------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/MareSynchronos/UI/Components/SelectGroupForPairUi.cs b/MareSynchronos/UI/Components/SelectGroupForPairUi.cs index fbd2a32..46eaeca 100644 --- a/MareSynchronos/UI/Components/SelectGroupForPairUi.cs +++ b/MareSynchronos/UI/Components/SelectGroupForPairUi.cs @@ -61,7 +61,13 @@ public class SelectGroupForPairUi return; } - var name = PairName(showUidForEntry, _pair.OtherUID); + // Is the popup not supposed to show? Set _opened to false so we can re-open it. + if (!_show) + { + _opened = false; + } + + var name = PairName(showUidForEntry, _pair.OtherUID, _pair.VanityUID); var popupName = $"Choose Groups for {name}"; // Is the popup supposed to show but did not open yet? Open it if (_show && !_opened) @@ -70,12 +76,6 @@ public class SelectGroupForPairUi _opened = true; } - // Is the popup not supposed to show? Set _opened to false so we can re-open it. - if (!_show) - { - _opened = false; - } - if (ImGui.BeginPopupModal(popupName, ref _show, UiShared.PopupWindowFlags)) { UiShared.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont); @@ -136,17 +136,13 @@ public class SelectGroupForPairUi } } - private string PairName(Dictionary showUidForEntry, string otherUid) + private string PairName(Dictionary showUidForEntry, string otherUid, string vanityUid) { showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName); _configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText); - if (showUidInsteadOfName) + if (showUidInsteadOfName || string.IsNullOrEmpty(playerText)) { - playerText = otherUid; - } - else if (string.IsNullOrEmpty(playerText)) - { - playerText = otherUid; + playerText = string.IsNullOrEmpty(vanityUid) ? otherUid : vanityUid; } return playerText; } diff --git a/MareSynchronos/UI/Components/SelectPairForGroupUi.cs b/MareSynchronos/UI/Components/SelectPairForGroupUi.cs index b961ec7..26630ac 100644 --- a/MareSynchronos/UI/Components/SelectPairForGroupUi.cs +++ b/MareSynchronos/UI/Components/SelectPairForGroupUi.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using Dalamud.Interface; +using FFXIVClientStructs.FFXIV.Common.Math; using ImGuiNET; using MareSynchronos.API; using MareSynchronos.UI.Handlers; @@ -40,7 +41,8 @@ public class SelectPairForGroupUi if (_show && !_opened) { - ImGui.SetWindowSize(new System.Numerics.Vector2(300, 400)); + ImGui.SetNextWindowSize(new Vector2(300, 400)); + ImGui.SetNextWindowSizeConstraints(new Vector2(300, 400), new Vector2(300, 1000)); ImGui.OpenPopup(popupName); _opened = true; } @@ -48,10 +50,10 @@ public class SelectPairForGroupUi if (ImGui.BeginPopupModal(popupName, ref _show)) { UiShared.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont); - foreach (var item in pairs.OrderBy(p => string.IsNullOrEmpty(p.VanityUID) ? p.OtherUID : p.VanityUID, System.StringComparer.OrdinalIgnoreCase).ToList()) + foreach (var item in pairs.OrderBy(p => PairName(showUidForEntry, p.OtherUID, p.VanityUID), System.StringComparer.OrdinalIgnoreCase).ToList()) { var isInGroup = _peopleInGroup.Contains(item.OtherUID); - if (ImGui.Checkbox(PairName(showUidForEntry, item.OtherUID), ref isInGroup)) + if (ImGui.Checkbox(PairName(showUidForEntry, item.OtherUID, item.VanityUID), ref isInGroup)) { if (isInGroup) { @@ -72,17 +74,13 @@ public class SelectPairForGroupUi } } - private string PairName(Dictionary showUidForEntry, string otherUid) + private string PairName(Dictionary showUidForEntry, string otherUid, string vanityUid) { showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName); _configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText); - if (showUidInsteadOfName) + if (showUidInsteadOfName || string.IsNullOrEmpty(playerText)) { - playerText = otherUid; - } - else if (string.IsNullOrEmpty(playerText)) - { - playerText = otherUid; + playerText = string.IsNullOrEmpty(vanityUid) ? otherUid : vanityUid; } return playerText; }