fix window size

This commit is contained in:
rootdarkarchon
2023-01-22 11:49:43 +01:00
parent 4da73f2368
commit c610970f03
2 changed files with 18 additions and 24 deletions

View File

@@ -61,7 +61,13 @@ public class SelectGroupForPairUi
return; 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}"; var popupName = $"Choose Groups for {name}";
// Is the popup supposed to show but did not open yet? Open it // Is the popup supposed to show but did not open yet? Open it
if (_show && !_opened) if (_show && !_opened)
@@ -70,12 +76,6 @@ public class SelectGroupForPairUi
_opened = true; _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)) if (ImGui.BeginPopupModal(popupName, ref _show, UiShared.PopupWindowFlags))
{ {
UiShared.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont); UiShared.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont);
@@ -136,17 +136,13 @@ public class SelectGroupForPairUi
} }
} }
private string PairName(Dictionary<string, bool> showUidForEntry, string otherUid) private string PairName(Dictionary<string, bool> showUidForEntry, string otherUid, string vanityUid)
{ {
showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName); showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName);
_configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText); _configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText);
if (showUidInsteadOfName) if (showUidInsteadOfName || string.IsNullOrEmpty(playerText))
{ {
playerText = otherUid; playerText = string.IsNullOrEmpty(vanityUid) ? otherUid : vanityUid;
}
else if (string.IsNullOrEmpty(playerText))
{
playerText = otherUid;
} }
return playerText; return playerText;
} }

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dalamud.Interface; using Dalamud.Interface;
using FFXIVClientStructs.FFXIV.Common.Math;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.API; using MareSynchronos.API;
using MareSynchronos.UI.Handlers; using MareSynchronos.UI.Handlers;
@@ -40,7 +41,8 @@ public class SelectPairForGroupUi
if (_show && !_opened) 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); ImGui.OpenPopup(popupName);
_opened = true; _opened = true;
} }
@@ -48,10 +50,10 @@ public class SelectPairForGroupUi
if (ImGui.BeginPopupModal(popupName, ref _show)) if (ImGui.BeginPopupModal(popupName, ref _show))
{ {
UiShared.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont); 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); 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) if (isInGroup)
{ {
@@ -72,17 +74,13 @@ public class SelectPairForGroupUi
} }
} }
private string PairName(Dictionary<string, bool> showUidForEntry, string otherUid) private string PairName(Dictionary<string, bool> showUidForEntry, string otherUid, string vanityUid)
{ {
showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName); showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName);
_configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText); _configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText);
if (showUidInsteadOfName) if (showUidInsteadOfName || string.IsNullOrEmpty(playerText))
{ {
playerText = otherUid; playerText = string.IsNullOrEmpty(vanityUid) ? otherUid : vanityUid;
}
else if (string.IsNullOrEmpty(playerText))
{
playerText = otherUid;
} }
return playerText; return playerText;
} }