Use new icon buttons on legacy UI too

This commit is contained in:
Loporrit
2025-02-18 12:03:27 +00:00
parent d48dcaf555
commit 54ee56dbc8
6 changed files with 26 additions and 32 deletions

View File

@@ -275,13 +275,9 @@ public class CompactUi : WindowMediatorSubscriberBase
ImGui.InputTextWithHint("##otheruid", "Other players UID/Alias", ref _pairToAdd, 20); ImGui.InputTextWithHint("##otheruid", "Other players UID/Alias", ref _pairToAdd, 20);
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X); ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
var canAdd = !_pairManager.DirectPairs.Any(p => string.Equals(p.UserData.UID, _pairToAdd, StringComparison.Ordinal) || string.Equals(p.UserData.Alias, _pairToAdd, StringComparison.Ordinal)); var canAdd = !_pairManager.DirectPairs.Any(p => string.Equals(p.UserData.UID, _pairToAdd, StringComparison.Ordinal) || string.Equals(p.UserData.Alias, _pairToAdd, StringComparison.Ordinal));
if (!canAdd) using (ImRaii.Disabled(!canAdd))
{ {
ImGuiComponents.DisabledButton(FontAwesomeIcon.Plus); if (_uiSharedService.IconButton(FontAwesomeIcon.Plus))
}
else
{
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus))
{ {
_ = _apiController.UserAddPair(new(new(_pairToAdd))); _ = _apiController.UserAddPair(new(new(_pairToAdd)));
_pairToAdd = string.Empty; _pairToAdd = string.Empty;
@@ -334,13 +330,14 @@ public class CompactUi : WindowMediatorSubscriberBase
break; break;
} }
var button = _buttonState ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; if (_timeout.ElapsedMilliseconds > 5000)
if (!_timeout.IsRunning || _timeout.ElapsedMilliseconds > 15000)
{
_timeout.Reset(); _timeout.Reset();
if (ImGuiComponents.IconButton(button) && UiSharedService.CtrlPressed()) var button = _buttonState ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
using (ImRaii.Disabled(_timeout.IsRunning))
{
if (_uiSharedService.IconButton(button) && UiSharedService.CtrlPressed())
{ {
foreach (var entry in users) foreach (var entry in users)
{ {
@@ -352,13 +349,10 @@ public class CompactUi : WindowMediatorSubscriberBase
_timeout.Start(); _timeout.Start();
_buttonState = !_buttonState; _buttonState = !_buttonState;
} }
UiSharedService.AttachToolTip($"Hold Control to {(button == FontAwesomeIcon.Play ? "resume" : "pause")} pairing with {users.Count} out of {userCount} displayed users."); if (!_timeout.IsRunning)
} UiSharedService.AttachToolTip($"Hold Control to {(button == FontAwesomeIcon.Play ? "resume" : "pause")} pairing with {users.Count} out of {userCount} displayed users.");
else else
{ UiSharedService.AttachToolTip($"Next execution is available at {(5000 - _timeout.ElapsedMilliseconds) / 1000} seconds");
var availableAt = (15000 - _timeout.ElapsedMilliseconds) / 1000;
ImGuiComponents.DisabledButton(button);
UiSharedService.AttachToolTip($"Next execution is available at {availableAt} seconds");
} }
} }
@@ -431,7 +425,7 @@ public class CompactUi : WindowMediatorSubscriberBase
if (_apiController.ServerState is ServerState.Connected) if (_apiController.ServerState is ServerState.Connected)
{ {
ImGui.SetCursorPosX(0 + ImGui.GetStyle().ItemSpacing.X); ImGui.SetCursorPosX(0 + ImGui.GetStyle().ItemSpacing.X);
if (ImGuiComponents.IconButton(FontAwesomeIcon.UserCircle)) if (_uiSharedService.IconButton(FontAwesomeIcon.UserCircle))
{ {
Mediator.Publish(new UiToggleMessage(typeof(EditProfileUi))); Mediator.Publish(new UiToggleMessage(typeof(EditProfileUi)));
} }
@@ -536,7 +530,7 @@ public class CompactUi : WindowMediatorSubscriberBase
buttonSizeX -= buttonSize.X - ImGui.GetStyle().ItemSpacing.X * 2; buttonSizeX -= buttonSize.X - ImGui.GetStyle().ItemSpacing.X * 2;
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X); ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2); ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Cog)) if (_uiSharedService.IconButton(FontAwesomeIcon.Cog))
{ {
Mediator.Publish(new OpenSettingsUiMessage()); Mediator.Publish(new OpenSettingsUiMessage());
} }
@@ -549,7 +543,7 @@ public class CompactUi : WindowMediatorSubscriberBase
{ {
buttonSizeX += _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Copy).X - ImGui.GetStyle().ItemSpacing.X * 2; buttonSizeX += _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Copy).X - ImGui.GetStyle().ItemSpacing.X * 2;
ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2); ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy)) if (_uiSharedService.IconButton(FontAwesomeIcon.Copy))
{ {
ImGui.SetClipboardText(_apiController.DisplayName); ImGui.SetClipboardText(_apiController.DisplayName);
} }

View File

@@ -249,7 +249,7 @@ public class DrawGroupPair : DrawPairBase
{ {
ImGui.SetCursorPosY(originalY); ImGui.SetCursorPosY(originalY);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus)) if (_uiSharedService.IconButton(FontAwesomeIcon.Plus))
{ {
_ = _apiController.UserAddPair(new UserDto(new(_pair.UserData.UID))); _ = _apiController.UserAddPair(new UserDto(new(_pair.UserData.UID)));
} }
@@ -261,7 +261,7 @@ public class DrawGroupPair : DrawPairBase
{ {
ImGui.SetCursorPosY(originalY); ImGui.SetCursorPosY(originalY);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars)) if (_uiSharedService.IconButton(FontAwesomeIcon.Bars))
{ {
ImGui.OpenPopup("Popup"); ImGui.OpenPopup("Popup");
} }

View File

@@ -172,7 +172,7 @@ public class DrawUserPair : DrawPairBase
} }
ImGui.SameLine(windowEndX - barButtonSize.X - spacingX - pauseIconSize.X); ImGui.SameLine(windowEndX - barButtonSize.X - spacingX - pauseIconSize.X);
ImGui.SetCursorPosY(originalY); ImGui.SetCursorPosY(originalY);
if (ImGuiComponents.IconButton(pauseIcon)) if (_uiSharedService.IconButton(pauseIcon))
{ {
var perm = _pair.UserPair!.OwnPermissions; var perm = _pair.UserPair!.OwnPermissions;
perm.SetPaused(!perm.IsPaused()); perm.SetPaused(!perm.IsPaused());
@@ -191,7 +191,7 @@ public class DrawUserPair : DrawPairBase
ImGui.SameLine(windowEndX - barButtonSize.X); ImGui.SameLine(windowEndX - barButtonSize.X);
ImGui.SetCursorPosY(originalY); ImGui.SetCursorPosY(originalY);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars)) if (_uiSharedService.IconButton(FontAwesomeIcon.Bars))
{ {
ImGui.OpenPopup("User Flyout Menu"); ImGui.OpenPopup("User Flyout Menu");
} }

View File

@@ -88,7 +88,7 @@ internal sealed class GroupPanel
|| string.Equals(p.Group.GID, _syncShellToJoin, StringComparison.Ordinal)); || string.Equals(p.Group.GID, _syncShellToJoin, StringComparison.Ordinal));
if (alreadyInGroup) ImGui.BeginDisabled(); if (alreadyInGroup) ImGui.BeginDisabled();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus)) if (_uiShared.IconButton(FontAwesomeIcon.Plus))
{ {
if (!string.IsNullOrEmpty(_syncShellToJoin)) if (!string.IsNullOrEmpty(_syncShellToJoin))
{ {
@@ -170,7 +170,7 @@ internal sealed class GroupPanel
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Syncshell Password: " + _lastCreatedGroup.Password); ImGui.TextUnformatted("Syncshell Password: " + _lastCreatedGroup.Password);
ImGui.SameLine(); ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy)) if (_uiShared.IconButton(FontAwesomeIcon.Copy))
{ {
ImGui.SetClipboardText(_lastCreatedGroup.Password); ImGui.SetClipboardText(_lastCreatedGroup.Password);
} }
@@ -584,7 +584,7 @@ internal sealed class GroupPanel
ImGui.SameLine(); ImGui.SameLine();
} }
if (ImGuiComponents.IconButton(pauseIcon)) if (_uiShared.IconButton(pauseIcon))
{ {
var userPerm = groupDto.GroupUserPermissions ^ GroupUserPermissions.Paused; var userPerm = groupDto.GroupUserPermissions ^ GroupUserPermissions.Paused;
_ = ApiController.GroupChangeIndividualPermissionState(new GroupPairUserPermissionDto(groupDto.Group, new UserData(ApiController.UID), userPerm)); _ = ApiController.GroupChangeIndividualPermissionState(new GroupPairUserPermissionDto(groupDto.Group, new UserData(ApiController.UID), userPerm));
@@ -592,7 +592,7 @@ internal sealed class GroupPanel
UiSharedService.AttachToolTip((groupDto.GroupUserPermissions.IsPaused() ? "Resume" : "Pause") + " pairing with all users in this Syncshell"); UiSharedService.AttachToolTip((groupDto.GroupUserPermissions.IsPaused() ? "Resume" : "Pause") + " pairing with all users in this Syncshell");
ImGui.SameLine(); ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars)) if (_uiShared.IconButton(FontAwesomeIcon.Bars))
{ {
ImGui.OpenPopup("ShellPopup"); ImGui.OpenPopup("ShellPopup");
} }

View File

@@ -54,7 +54,7 @@ public class PairGroupsUi
var buttonPauseOffset = windowX + windowWidth - flyoutMenuX - spacingX - pauseButtonX; var buttonPauseOffset = windowX + windowWidth - flyoutMenuX - spacingX - pauseButtonX;
ImGui.SameLine(buttonPauseOffset); ImGui.SameLine(buttonPauseOffset);
if (ImGuiComponents.IconButton(pauseButton)) if (_uiSharedService.IconButton(pauseButton))
{ {
// If all of the currently visible pairs (after applying filters to the pairs) // If all of the currently visible pairs (after applying filters to the pairs)
// are paused we display a resume button to resume all currently visible (after filters) // are paused we display a resume button to resume all currently visible (after filters)
@@ -81,7 +81,7 @@ public class PairGroupsUi
var buttonDeleteOffset = windowX + windowWidth - flyoutMenuX; var buttonDeleteOffset = windowX + windowWidth - flyoutMenuX;
ImGui.SameLine(buttonDeleteOffset); ImGui.SameLine(buttonDeleteOffset);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars)) if (_uiSharedService.IconButton(FontAwesomeIcon.Bars))
{ {
ImGui.OpenPopup("Group Flyout Menu"); ImGui.OpenPopup("Group Flyout Menu");
} }

View File

@@ -113,7 +113,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
using (ImRaii.Disabled(_filterFreeText.IsNullOrEmpty())) using (ImRaii.Disabled(_filterFreeText.IsNullOrEmpty()))
{ {
ImGui.SameLine(); ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Ban)) if (_uiSharedService.IconButton(FontAwesomeIcon.Ban))
{ {
_filterFreeText = string.Empty; _filterFreeText = string.Empty;
_filteredEvents = RecreateFilter(); _filteredEvents = RecreateFilter();