From 39aa244a9f55ea42e692821d565566ae027582ff Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Mon, 25 Mar 2024 19:34:15 +0100 Subject: [PATCH] fix code dupe --- MareSynchronos/UI/CompactUI.cs | 2 +- MareSynchronos/UI/Components/DrawFolderBase.cs | 2 +- MareSynchronos/UI/Components/DrawFolderGroup.cs | 2 +- MareSynchronos/UI/Components/DrawFolderTag.cs | 2 +- MareSynchronos/UI/Components/DrawUserPair.cs | 4 ++-- MareSynchronos/UI/UISharedService.cs | 9 +-------- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/MareSynchronos/UI/CompactUI.cs b/MareSynchronos/UI/CompactUI.cs index 867131c..9de6dc6 100644 --- a/MareSynchronos/UI/CompactUI.cs +++ b/MareSynchronos/UI/CompactUI.cs @@ -257,7 +257,7 @@ public class CompactUi : WindowMediatorSubscriberBase } private void DrawServerStatus() { - var buttonSize = _uiSharedService.IconButtonSize(FontAwesomeIcon.Link); + var buttonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Link); var userCount = _apiController.OnlineUsers.ToString(CultureInfo.InvariantCulture); var userSize = ImGui.CalcTextSize(userCount); var textSize = ImGui.CalcTextSize("Users Online"); diff --git a/MareSynchronos/UI/Components/DrawFolderBase.cs b/MareSynchronos/UI/Components/DrawFolderBase.cs index d685c47..5cdaaff 100644 --- a/MareSynchronos/UI/Components/DrawFolderBase.cs +++ b/MareSynchronos/UI/Components/DrawFolderBase.cs @@ -98,7 +98,7 @@ public abstract class DrawFolderBase : IDrawFolder private float DrawRightSideInternal() { - var barButtonSize = _uiSharedService.IconButtonSize(FontAwesomeIcon.EllipsisV); + var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.EllipsisV); var spacingX = ImGui.GetStyle().ItemSpacing.X; var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth(); diff --git a/MareSynchronos/UI/Components/DrawFolderGroup.cs b/MareSynchronos/UI/Components/DrawFolderGroup.cs index 621fb5b..e21295b 100644 --- a/MareSynchronos/UI/Components/DrawFolderGroup.cs +++ b/MareSynchronos/UI/Components/DrawFolderGroup.cs @@ -169,7 +169,7 @@ public class DrawFolderGroup : DrawFolderBase var spacingX = ImGui.GetStyle().ItemSpacing.X; FontAwesomeIcon pauseIcon = _groupFullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; - var pauseButtonSize = _uiSharedService.IconButtonSize(pauseIcon); + var pauseButtonSize = _uiSharedService.GetIconButtonSize(pauseIcon); var userCogButtonSize = _uiSharedService.GetIconData(FontAwesomeIcon.UsersCog); diff --git a/MareSynchronos/UI/Components/DrawFolderTag.cs b/MareSynchronos/UI/Components/DrawFolderTag.cs index 0a901a1..0dba36e 100644 --- a/MareSynchronos/UI/Components/DrawFolderTag.cs +++ b/MareSynchronos/UI/Components/DrawFolderTag.cs @@ -137,7 +137,7 @@ public class DrawFolderTag : DrawFolderBase var allArePaused = _allPairs.All(pair => pair.UserPair!.OwnPermissions.IsPaused()); var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; - var pauseButtonX = _uiSharedService.IconButtonSize(pauseButton).X; + var pauseButtonX = _uiSharedService.GetIconButtonSize(pauseButton).X; var buttonPauseOffset = currentRightSideX - pauseButtonX; ImGui.SameLine(buttonPauseOffset); diff --git a/MareSynchronos/UI/Components/DrawUserPair.cs b/MareSynchronos/UI/Components/DrawUserPair.cs index e8b0078..c79d0d0 100644 --- a/MareSynchronos/UI/Components/DrawUserPair.cs +++ b/MareSynchronos/UI/Components/DrawUserPair.cs @@ -301,8 +301,8 @@ public class DrawUserPair private float DrawRightSide() { var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; - var pauseIconSize = _uiSharedService.IconButtonSize(pauseIcon); - var barButtonSize = _uiSharedService.IconButtonSize(FontAwesomeIcon.EllipsisV); + var pauseIconSize = _uiSharedService.GetIconButtonSize(pauseIcon); + var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.EllipsisV); var spacingX = ImGui.GetStyle().ItemSpacing.X; var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth(); float currentRightSide = windowEndX - barButtonSize.X; diff --git a/MareSynchronos/UI/UISharedService.cs b/MareSynchronos/UI/UISharedService.cs index bca4511..f1a1876 100644 --- a/MareSynchronos/UI/UISharedService.cs +++ b/MareSynchronos/UI/UISharedService.cs @@ -810,8 +810,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase public Vector2 GetIconButtonSize(FontAwesomeIcon icon) { using var font = IconFont.Push(); - var buttonSize = ImGuiHelpers.GetButtonSize(icon.ToIconString()); - return buttonSize; + return ImGuiHelpers.GetButtonSize(icon.ToIconString()); } public Vector2 GetIconData(FontAwesomeIcon icon) @@ -820,12 +819,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase return ImGui.CalcTextSize(icon.ToIconString()); } - public Vector2 IconButtonSize(FontAwesomeIcon icon) - { - using var font = IconFont.Push(); - return ImGuiHelpers.GetButtonSize(icon.ToIconString()); - } - public void IconText(FontAwesomeIcon icon, uint color) { FontText(icon.ToIconString(), IconFont, color);