UI Update

This commit is contained in:
2025-10-31 23:58:11 +01:00
parent b4108c7803
commit 84586cac3d
5 changed files with 249 additions and 140 deletions

View File

@@ -68,6 +68,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private bool _showModalForUserAddition;
private bool _wasOpen;
private bool _nearbyOpen = true;
private bool _visibleOpen = true;
private bool _selfAnalysisOpen = false;
private List<Services.Mediator.NearbyEntry> _nearbyEntries = new();
private const long SelfAnalysisSizeWarningThreshold = 300L * 1024 * 1024;
@@ -682,6 +683,9 @@ if (showNearby && pendingInvites > 0)
var allUsers = GetFilteredUsers().OrderBy(u => u.GetPairSortKey(), StringComparer.Ordinal).ToList();
var visibleUsersSource = allUsers.Where(u => u.IsVisible).ToList();
var nonVisibleUsers = allUsers.Where(u => !u.IsVisible).ToList();
var nearbyEntriesForDisplay = _configService.Current.EnableAutoDetectDiscovery
? GetNearbyEntriesForDisplay()
: new List<Services.Mediator.NearbyEntry>();
ImGui.BeginChild("list", new Vector2(WindowContentWidth, ySize), border: false);
@@ -698,21 +702,35 @@ if (showNearby && pendingInvites > 0)
if (mode == PairContentMode.VisibleOnly)
{
var visibleUsers = visibleUsersSource.Select(c => new DrawUserPair("Visible" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService, _charaDataManager, _serverManager)).ToList();
if (visibleUsers.Count == 0)
bool showVisibleCard = visibleUsers.Count > 0;
bool showNearbyCard = nearbyEntriesForDisplay.Count > 0;
if (!showVisibleCard && !showNearbyCard)
{
UiSharedService.ColorTextWrapped("Aucune paire visible pour l'instant.", ImGuiColors.DalamudGrey3);
const string calmMessage = "C'est bien trop calme ici... Il n'y a rien pour le moment.";
using (_uiSharedService.UidFont.Push())
{
var regionMin = ImGui.GetWindowContentRegionMin();
var availableWidth = UiSharedService.GetWindowContentRegionWidth();
var regionHeight = UiSharedService.GetWindowContentRegionHeight();
var textSize = ImGui.CalcTextSize(calmMessage, hideTextAfterDoubleHash: false, availableWidth);
var xOffset = MathF.Max(0f, (availableWidth - textSize.X) / 2f);
var yOffset = MathF.Max(0f, (regionHeight - textSize.Y) / 2f);
ImGui.SetCursorPos(new Vector2(regionMin.X + xOffset, regionMin.Y + yOffset));
UiSharedService.ColorTextWrapped(calmMessage, ImGuiColors.DalamudGrey3, regionMin.X + availableWidth);
}
}
else
{
foreach (var visibleUser in visibleUsers)
if (showVisibleCard)
{
visibleUser.DrawPairedClient();
}
DrawVisibleCard(visibleUsers);
}
if (_configService.Current.EnableAutoDetectDiscovery)
if (showNearbyCard)
{
DrawNearbyCard();
DrawNearbyCard(nearbyEntriesForDisplay);
}
}
}
else
@@ -726,9 +744,10 @@ if (showNearby && pendingInvites > 0)
.ToList();
Action? drawVisibleExtras = null;
if (_configService.Current.EnableAutoDetectDiscovery)
if (nearbyEntriesForDisplay.Count > 0)
{
drawVisibleExtras = () => DrawNearbyCard();
var entriesForExtras = nearbyEntriesForDisplay;
drawVisibleExtras = () => DrawNearbyCard(entriesForExtras);
}
_pairGroupsUi.Draw(visibleUsers, onlineUsers, offlineUsers, drawVisibleExtras);
@@ -737,8 +756,71 @@ if (showNearby && pendingInvites > 0)
ImGui.EndChild();
}
private void DrawNearbyCard()
private List<Services.Mediator.NearbyEntry> GetNearbyEntriesForDisplay()
{
if (_nearbyEntries == null || _nearbyEntries.Count == 0)
{
return new List<Services.Mediator.NearbyEntry>();
}
return _nearbyEntries
.Where(e => e.IsMatch && e.AcceptPairRequests && !string.IsNullOrEmpty(e.Token) && !IsAlreadyPairedQuickMenu(e))
.OrderBy(e => e.Distance)
.ToList();
}
private void DrawVisibleCard(List<DrawUserPair> visibleUsers)
{
if (visibleUsers.Count == 0)
{
return;
}
ImGuiHelpers.ScaledDummy(4f);
using (ImRaii.PushId("group-Visible"))
{
UiSharedService.DrawCard("visible-card", () =>
{
bool visibleState = _visibleOpen;
UiSharedService.DrawArrowToggle(ref visibleState, "##visible-toggle");
if (visibleState != _visibleOpen)
{
_visibleOpen = visibleState;
}
ImGui.SameLine(0f, 6f * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted($"Visible ({visibleUsers.Count})");
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
_visibleOpen = !_visibleOpen;
}
if (!_visibleOpen)
{
return;
}
ImGuiHelpers.ScaledDummy(4f);
var indent = 18f * ImGuiHelpers.GlobalScale;
ImGui.Indent(indent);
foreach (var visibleUser in visibleUsers)
{
visibleUser.DrawPairedClient();
}
ImGui.Unindent(indent);
}, stretchWidth: true);
}
ImGuiHelpers.ScaledDummy(4f);
}
private void DrawNearbyCard(IReadOnlyList<Services.Mediator.NearbyEntry> nearbyEntries)
{
if (nearbyEntries.Count == 0)
{
return;
}
ImGuiHelpers.ScaledDummy(4f);
using (ImRaii.PushId("group-Nearby"))
{
@@ -752,7 +834,7 @@ if (showNearby && pendingInvites > 0)
}
ImGui.SameLine(0f, 6f * ImGuiHelpers.GlobalScale);
var onUmbra = _nearbyEntries?.Count(e => e.IsMatch && e.AcceptPairRequests && !string.IsNullOrEmpty(e.Token) && !IsAlreadyPairedQuickMenu(e)) ?? 0;
var onUmbra = nearbyEntries.Count;
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted($"Nearby ({onUmbra})");
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
@@ -768,21 +850,12 @@ if (showNearby && pendingInvites > 0)
ImGuiHelpers.ScaledDummy(4f);
var indent = 18f * ImGuiHelpers.GlobalScale;
ImGui.Indent(indent);
var nearby = _nearbyEntries == null
? new List<Services.Mediator.NearbyEntry>()
: _nearbyEntries.Where(e => e.IsMatch && e.AcceptPairRequests && !string.IsNullOrEmpty(e.Token) && !IsAlreadyPairedQuickMenu(e))
.OrderBy(e => e.Distance)
.ToList();
if (nearby.Count == 0)
{
UiSharedService.ColorTextWrapped("Aucun nouveau joueur detecté.", ImGuiColors.DalamudGrey3);
}
else
{
foreach (var e in nearby)
foreach (var e in nearbyEntries)
{
if (!e.AcceptPairRequests || string.IsNullOrEmpty(e.Token))
{
continue;
}
var name = e.DisplayName ?? e.Name;
ImGui.AlignTextToFramePadding();
@@ -814,7 +887,6 @@ if (showNearby && pendingInvites > 0)
UiSharedService.AttachToolTip("Impossible d'inviter ce joueur");
}
}
}
ImGui.Unindent(indent);
}, stretchWidth: true);
}

View File

@@ -210,23 +210,47 @@ public class DrawGroupPair : DrawPairBase
var permIcon = (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled) ? FontAwesomeIcon.ExclamationTriangle
: ((soundsDisabled || animDisabled || vfxDisabled) ? FontAwesomeIcon.InfoCircle : FontAwesomeIcon.None);
var runningIconWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Running).X;
var infoIconWidth = UiSharedService.GetIconSize(permIcon).X;
var infoIconWidth = showInfo && permIcon != FontAwesomeIcon.None ? UiSharedService.GetIconSize(permIcon).X : 0f;
var plusButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus).X;
var pauseIcon = _fullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseButtonWidth = _uiSharedService.GetIconButtonSize(pauseIcon).X;
var barButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X;
var pos = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() + spacing
- (showShared ? (runningIconWidth + spacing) : 0)
- (showInfo ? (infoIconWidth + spacing) : 0)
- (showPlus ? (plusButtonWidth + spacing) : 0)
- (showPause ? (pauseButtonWidth + spacing) : 0)
- (showBars ? (barButtonWidth + spacing) : 0);
float totalWidth = 0f;
void Accumulate(bool condition, float width)
{
if (!condition || width <= 0f) return;
if (totalWidth > 0f) totalWidth += spacing;
totalWidth += width;
}
ImGui.SameLine(pos);
Accumulate(showShared, runningIconWidth);
Accumulate(showInfo && infoIconWidth > 0f, infoIconWidth);
Accumulate(showPlus, plusButtonWidth);
Accumulate(showPause, pauseButtonWidth);
if (showBars)
{
if (totalWidth > 0f) totalWidth += spacing;
totalWidth += barButtonWidth;
}
if (showPause && showBars)
{
totalWidth -= spacing * 0.5f;
if (totalWidth < 0f) totalWidth = 0f;
}
float cardPaddingX = UiSharedService.GetCardContentPaddingX();
float rightMargin = cardPaddingX + 6f * ImGuiHelpers.GlobalScale;
float baseX = MathF.Max(ImGui.GetCursorPosX(),
ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - rightMargin - totalWidth);
float currentX = baseX;
ImGui.SameLine();
ImGui.SetCursorPosX(baseX);
if (showShared)
{
ImGui.SetCursorPosY(textPosY);
_uiSharedService.IconText(FontAwesomeIcon.Running);
UiSharedService.AttachToolTip($"This user has shared {sharedData!.Count} Character Data Sets with you." + UiSharedService.TooltipSeparator
@@ -236,12 +260,15 @@ public class DrawGroupPair : DrawPairBase
{
_mediator.Publish(new OpenCharaDataHubWithFilterMessage(_pair.UserData));
}
ImGui.SameLine();
currentX += runningIconWidth + spacing;
ImGui.SetCursorPosX(currentX);
}
if (individualAnimDisabled || individualSoundsDisabled)
if (showInfo && infoIconWidth > 0f)
{
ImGui.SetCursorPosY(textPosY);
if (individualAnimDisabled || individualSoundsDisabled)
{
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
_uiSharedService.IconText(permIcon);
ImGui.PopStyleColor();
@@ -286,11 +313,9 @@ public class DrawGroupPair : DrawPairBase
ImGui.EndTooltip();
}
ImGui.SameLine();
}
else if ((animDisabled || soundsDisabled))
else
{
ImGui.SetCursorPosY(textPosY);
_uiSharedService.IconText(permIcon);
if (ImGui.IsItemHovered())
{
@@ -324,7 +349,10 @@ public class DrawGroupPair : DrawPairBase
ImGui.EndTooltip();
}
ImGui.SameLine();
}
currentX += infoIconWidth + spacing;
ImGui.SetCursorPosX(currentX);
}
if (showPlus)
@@ -340,13 +368,14 @@ public class DrawGroupPair : DrawPairBase
}
}
UiSharedService.AttachToolTip(AppendSeenInfo("Send pairing invite to " + entryUID));
ImGui.SameLine();
currentX += plusButtonWidth + spacing;
ImGui.SetCursorPosX(currentX);
}
if (showPause)
{
float gapToBars = showBars ? spacing * 0.5f : spacing;
ImGui.SetCursorPosY(originalY);
if (_uiSharedService.IconButton(pauseIcon))
{
var newPermissions = _fullInfoDto.GroupUserPermissions ^ GroupUserPermissions.Paused;
@@ -355,19 +384,20 @@ public class DrawGroupPair : DrawPairBase
}
UiSharedService.AttachToolTip(AppendSeenInfo((_fullInfoDto.GroupUserPermissions.IsPaused() ? "Resume" : "Pause") + " syncing with " + entryUID));
ImGui.SameLine();
currentX += pauseButtonWidth + gapToBars;
ImGui.SetCursorPosX(currentX);
}
if (showBars)
{
ImGui.SetCursorPosY(originalY);
if (_uiSharedService.IconButton(FontAwesomeIcon.Bars))
{
ImGui.OpenPopup("Popup");
ImGui.OpenPopup("Syncshell Flyout Menu");
}
currentX += barButtonWidth;
ImGui.SetCursorPosX(currentX);
}
if (ImGui.BeginPopup("Popup"))
{
if ((userIsModerator || userIsOwner) && !(entryIsMod || entryIsOwner))
@@ -453,7 +483,7 @@ public class DrawGroupPair : DrawPairBase
ImGui.EndPopup();
}
return pos - spacing;
return baseX - spacing;
}
private string AppendSeenInfo(string tooltip)

View File

@@ -132,7 +132,7 @@ public class DrawUserPair : DrawPairBase
var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
var entryUID = _pair.UserData.AliasOrUID;
var spacingX = ImGui.GetStyle().ItemSpacing.X;
var edgePadding = ImGui.GetStyle().WindowPadding.X + 4f * ImGuiHelpers.GlobalScale;
var edgePadding = UiSharedService.GetCardContentPaddingX() + 6f * ImGuiHelpers.GlobalScale;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - edgePadding;
var rightSidePos = windowEndX - barButtonSize.X;

View File

@@ -646,7 +646,8 @@ internal sealed class GroupPanel
var isOwner = string.Equals(groupDto.OwnerUID, ApiController.UID, StringComparison.Ordinal);
var spacingX = ImGui.GetStyle().ItemSpacing.X;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
var cardPaddingX = UiSharedService.GetCardContentPaddingX();
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - cardPaddingX - 6f * ImGuiHelpers.GlobalScale;
var pauseIcon = groupDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseIconSize = _uiShared.GetIconButtonSize(pauseIcon);

View File

@@ -118,7 +118,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
{
e.OnPreBuild(tk => tk.AddDalamudAssetFont(Dalamud.DalamudAsset.NotoSansJpMedium, new()
{
SizePx = 35,
SizePx = 27,
GlyphRanges = [0x20, 0x7E, 0]
}));
});
@@ -349,6 +349,12 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return state;
}
public static float GetCardContentPaddingX()
{
var style = ImGui.GetStyle();
return style.FramePadding.X + 4f * ImGuiHelpers.GlobalScale;
}
public static void DrawGroupedCenteredColorText(string text, Vector4 color, float? maxWidth = null)
{
var availWidth = ImGui.GetContentRegionAvail().X;