From 9ca6931bb850ec387670fa22113f453919a047f3 Mon Sep 17 00:00:00 2001 From: Eauldane Date: Wed, 3 Sep 2025 15:41:47 +0100 Subject: [PATCH] Fixed syncshell UI messing up if there were members you didn't have an individual pair with --- MareSynchronos/UI/Components/DrawGroupPair.cs | 46 ++++++++++--------- MareSynchronos/UI/Components/DrawUserPair.cs | 4 ++ MareSynchronos/UI/Components/GroupPanel.cs | 2 +- MareSynchronos/UI/SettingsUi.cs | 2 + 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/MareSynchronos/UI/Components/DrawGroupPair.cs b/MareSynchronos/UI/Components/DrawGroupPair.cs index 9382f74..0bff181 100644 --- a/MareSynchronos/UI/Components/DrawGroupPair.cs +++ b/MareSynchronos/UI/Components/DrawGroupPair.cs @@ -20,7 +20,7 @@ public class DrawGroupPair : DrawPairBase private readonly GroupPairFullInfoDto _fullInfoDto; private readonly GroupFullInfoDto _group; private readonly CharaDataManager _charaDataManager; - public long _VRAMBytes; + public long VramUsage { get; set; } public DrawGroupPair(string id, Pair entry, ApiController apiController, MareMediator mareMediator, GroupFullInfoDto group, GroupPairFullInfoDto fullInfoDto, @@ -87,7 +87,7 @@ public class DrawGroupPair : DrawPairBase presenceText += "Files Size: " + UiSharedService.ByteToString(_pair.LastAppliedDataBytes, true); if (_pair.LastAppliedApproximateVRAMBytes >= 0) { - _VRAMBytes = _pair.LastAppliedApproximateVRAMBytes; + VramUsage = _pair.LastAppliedApproximateVRAMBytes; presenceText += Environment.NewLine + "Approx. VRAM Usage: " + UiSharedService.ByteToString(_pair.LastAppliedApproximateVRAMBytes, true); } if (_pair.LastAppliedDataTris >= 0) @@ -130,7 +130,7 @@ public class DrawGroupPair : DrawPairBase protected override float DrawRightSide(float textPosY, float originalY) { - var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; + var pauseIcon = _fullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; var pauseIconSize = _uiSharedService.GetIconButtonSize(pauseIcon); var spacingX = ImGui.GetStyle().ItemSpacing.X; var entryUID = _fullInfoDto.UserAliasOrUID; @@ -158,6 +158,8 @@ public class DrawGroupPair : DrawPairBase var runningIconWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Running).X; var infoIconWidth = UiSharedService.GetIconSize(permIcon).X; var plusButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus).X; + var pauseButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus).X; + var barButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X; var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars); @@ -169,6 +171,7 @@ public class DrawGroupPair : DrawPairBase - (showShared ? (runningIconWidth + spacing) : 0) - (showInfo ? (infoIconWidth + spacing) : 0) - (showPlus ? (plusButtonWidth + spacing) : 0) + - (showPause ? (pauseButtonWidth + spacing) : 0) - (showBars ? (barButtonWidth + spacing) : 0); ImGui.SameLine(pos); @@ -287,6 +290,24 @@ public class DrawGroupPair : DrawPairBase UiSharedService.AttachToolTip("Pair with " + entryUID + " individually"); ImGui.SameLine(); } + if (showPause) + { + //rightSidePos -= pauseIconSize.X + spacingX; + ImGui.SetCursorPosY(originalY); + + if (_uiSharedService.IconButton(pauseIcon)) + { + var perm = _fullInfoDto.GroupUserPermissions; + var newPaused = !perm.IsPaused(); + perm.SetPaused(newPaused); + } + + UiSharedService.AttachToolTip(!_fullInfoDto.GroupUserPermissions.IsPaused() + ? "Pause pairing with " + entryUID + : "Resume pairing with " + entryUID); + ImGui.SameLine(); + + } if (showBars) { ImGui.SetCursorPosY(originalY); @@ -295,26 +316,7 @@ public class DrawGroupPair : DrawPairBase { ImGui.OpenPopup("Popup"); } - ImGui.SameLine(); } - if (showPause) - { - rightSidePos -= pauseIconSize.X + spacingX; - ImGui.SameLine(rightSidePos); - ImGui.SetCursorPosY(originalY); - - if (_uiSharedService.IconButton(pauseIcon)) - { - var perm = _pair.UserPair!.OwnPermissions; - perm.SetPaused(!perm.IsPaused()); - _ = _apiController.UserSetPairPermissions(new(_pair.UserData, perm)); - } - - UiSharedService.AttachToolTip(!_pair.UserPair!.OwnPermissions.IsPaused() - ? "Pause pairing with " + entryUID - : "Resume pairing with " + entryUID); - } - if (ImGui.BeginPopup("Popup")) { if ((userIsModerator || userIsOwner) && !(entryIsMod || entryIsOwner)) diff --git a/MareSynchronos/UI/Components/DrawUserPair.cs b/MareSynchronos/UI/Components/DrawUserPair.cs index 23989b7..57b22fb 100644 --- a/MareSynchronos/UI/Components/DrawUserPair.cs +++ b/MareSynchronos/UI/Components/DrawUserPair.cs @@ -19,6 +19,7 @@ public class DrawUserPair : DrawPairBase protected readonly MareMediator _mediator; private readonly SelectGroupForPairUi _selectGroupForPairUi; private readonly CharaDataManager _charaDataManager; + public long VramUsage { get; set; } public DrawUserPair(string id, Pair entry, UidDisplayHandler displayHandler, ApiController apiController, MareMediator mareMediator, SelectGroupForPairUi selectGroupForPairUi, @@ -84,6 +85,7 @@ public class DrawUserPair : DrawPairBase visibleTooltip += "Files Size: " + UiSharedService.ByteToString(_pair.LastAppliedDataBytes, true); if (_pair.LastAppliedApproximateVRAMBytes >= 0) { + VramUsage = _pair.LastAppliedApproximateVRAMBytes; visibleTooltip += Environment.NewLine + "Approx. VRAM Usage: " + UiSharedService.ByteToString(_pair.LastAppliedApproximateVRAMBytes, true); } if (_pair.LastAppliedDataTris >= 0) @@ -97,6 +99,8 @@ public class DrawUserPair : DrawPairBase } } + + protected override float DrawRightSide(float textPosY, float originalY) { var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; diff --git a/MareSynchronos/UI/Components/GroupPanel.cs b/MareSynchronos/UI/Components/GroupPanel.cs index 10010ab..322712b 100644 --- a/MareSynchronos/UI/Components/GroupPanel.cs +++ b/MareSynchronos/UI/Components/GroupPanel.cs @@ -454,7 +454,7 @@ internal sealed class GroupPanel ImGui.Separator(); if (_mareConfig.Current.SortSyncshellsByVRAM) { - List sortedVisibleUsers = visibleUsers.OrderBy(o=>o._VRAMBytes).ToList(); + List sortedVisibleUsers = visibleUsers.OrderBy(o=>o.VramUsage).ToList(); _uidDisplayHandler.RenderPairList(sortedVisibleUsers); } else diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index 1b3788b..a1cf491 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -1078,6 +1078,8 @@ public class SettingsUi : WindowMediatorSubscriberBase if (ImGui.Checkbox("Sort visible syncshell users by VRAM usage", ref sortSyncshellByVRAM)) { _configService.Current.SortSyncshellsByVRAM = sortSyncshellByVRAM; + _logger.LogWarning("Changing value: {sortSyncshellsByVRAM}", sortSyncshellByVRAM); + _configService.Save(); } _uiShared.DrawHelpText("This will put users using the most VRAM in a syncshell at the top of the list.");