Popup optimisation
This commit is contained in:
@@ -160,7 +160,7 @@ public class CompactUi : Window, IDisposable
|
|||||||
_lastAddedUserComment = string.Empty;
|
_lastAddedUserComment = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.BeginPopupModal("Set Notes for New User", ref _showModalForUserAddition, ImGuiWindowFlags.AlwaysAutoResize))
|
if (ImGui.BeginPopupModal("Set Notes for New User", ref _showModalForUserAddition, UiShared.PopupWindowFlags))
|
||||||
{
|
{
|
||||||
if (_lastAddedUser == null)
|
if (_lastAddedUser == null)
|
||||||
{
|
{
|
||||||
@@ -180,6 +180,7 @@ public class CompactUi : Window, IDisposable
|
|||||||
_showModalForUserAddition = false;
|
_showModalForUserAddition = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UiShared.SetScaledWindowSize(275);
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,11 +95,12 @@ namespace MareSynchronos.UI
|
|||||||
? (userCanCreateMoreGroups ? "Create Syncshell" : $"You cannot create more than {_apiController.ServerInfo.MaxGroupsCreatedByUser} Syncshells")
|
? (userCanCreateMoreGroups ? "Create Syncshell" : $"You cannot create more than {_apiController.ServerInfo.MaxGroupsCreatedByUser} Syncshells")
|
||||||
: (userCanJoinMoreGroups ? "Join Syncshell" + _syncShellToJoin : $"You cannot join more than {_apiController.ServerInfo.MaxGroupsJoinedByUser} Syncshells"));
|
: (userCanJoinMoreGroups ? "Join Syncshell" + _syncShellToJoin : $"You cannot join more than {_apiController.ServerInfo.MaxGroupsJoinedByUser} Syncshells"));
|
||||||
|
|
||||||
if (ImGui.BeginPopupModal("Enter Syncshell Password", ref _showModalEnterPassword, ImGuiWindowFlags.AlwaysAutoResize))
|
if (ImGui.BeginPopupModal("Enter Syncshell Password", ref _showModalEnterPassword, UiShared.PopupWindowFlags))
|
||||||
{
|
{
|
||||||
UiShared.TextWrapped("Before joining any Syncshells please be aware that you will be automatically paired with everyone in the Syncshell.");
|
UiShared.TextWrapped("Before joining any Syncshells please be aware that you will be automatically paired with everyone in the Syncshell.");
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
UiShared.TextWrapped("Enter the password for Syncshell " + _syncShellToJoin + ":");
|
UiShared.TextWrapped("Enter the password for Syncshell " + _syncShellToJoin + ":");
|
||||||
|
ImGui.SetNextItemWidth(-1);
|
||||||
ImGui.InputTextWithHint("##password", _syncShellToJoin + " Password", ref _syncShellPassword, 255, ImGuiInputTextFlags.Password);
|
ImGui.InputTextWithHint("##password", _syncShellToJoin + " Password", ref _syncShellPassword, 255, ImGuiInputTextFlags.Password);
|
||||||
if (_errorGroupJoin)
|
if (_errorGroupJoin)
|
||||||
{
|
{
|
||||||
@@ -119,12 +120,12 @@ namespace MareSynchronos.UI
|
|||||||
}
|
}
|
||||||
_syncShellPassword = string.Empty;
|
_syncShellPassword = string.Empty;
|
||||||
}
|
}
|
||||||
|
UiShared.SetScaledWindowSize(290);
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.BeginPopupModal("Create Syncshell", ref _showModalCreateGroup))
|
if (ImGui.BeginPopupModal("Create Syncshell", ref _showModalCreateGroup, UiShared.PopupWindowFlags))
|
||||||
{
|
{
|
||||||
ImGui.SetWindowSize(new(400, 200));
|
|
||||||
UiShared.TextWrapped("Press the button below to create a new Syncshell.");
|
UiShared.TextWrapped("Press the button below to create a new Syncshell.");
|
||||||
ImGui.SetNextItemWidth(200);
|
ImGui.SetNextItemWidth(200);
|
||||||
if (ImGui.Button("Create Syncshell"))
|
if (ImGui.Button("Create Syncshell"))
|
||||||
@@ -145,6 +146,7 @@ namespace MareSynchronos.UI
|
|||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
_errorGroupCreate = false;
|
_errorGroupCreate = false;
|
||||||
ImGui.TextUnformatted("Syncshell ID: " + _lastCreatedGroup.GID);
|
ImGui.TextUnformatted("Syncshell ID: " + _lastCreatedGroup.GID);
|
||||||
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.TextUnformatted("Syncshell Password: " + _lastCreatedGroup.Password);
|
ImGui.TextUnformatted("Syncshell Password: " + _lastCreatedGroup.Password);
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy))
|
if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy))
|
||||||
@@ -160,6 +162,7 @@ namespace MareSynchronos.UI
|
|||||||
new Vector4(1, 0, 0, 1));
|
new Vector4(1, 0, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UiShared.SetScaledWindowSize(350);
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,9 +295,8 @@ namespace MareSynchronos.UI
|
|||||||
|
|
||||||
if (!_showModalBanList) _modalBanListOpened = false;
|
if (!_showModalBanList) _modalBanListOpened = false;
|
||||||
|
|
||||||
if (ImGui.BeginPopupModal("Manage Banlist for " + group.GID, ref _showModalBanList))
|
if (ImGui.BeginPopupModal("Manage Banlist for " + group.GID, ref _showModalBanList, UiShared.PopupWindowFlags))
|
||||||
{
|
{
|
||||||
ImGui.SetWindowSize(new Vector2(700, 300));
|
|
||||||
if (UiShared.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
|
if (UiShared.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
|
||||||
{
|
{
|
||||||
_bannedUsers = _apiController.GetBannedUsersForGroup(group.GID).Result;
|
_bannedUsers = _apiController.GetBannedUsersForGroup(group.GID).Result;
|
||||||
@@ -331,6 +333,7 @@ namespace MareSynchronos.UI
|
|||||||
|
|
||||||
ImGui.EndTable();
|
ImGui.EndTable();
|
||||||
}
|
}
|
||||||
|
UiShared.SetScaledWindowSize(700, 300);
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,10 +346,11 @@ namespace MareSynchronos.UI
|
|||||||
if (!_showModalChangePassword) _modalChangePwOpened = false;
|
if (!_showModalChangePassword) _modalChangePwOpened = false;
|
||||||
|
|
||||||
|
|
||||||
if (ImGui.BeginPopupModal("Change Syncshell Password", ref _showModalChangePassword, ImGuiWindowFlags.AlwaysAutoResize))
|
if (ImGui.BeginPopupModal("Change Syncshell Password", ref _showModalChangePassword, UiShared.PopupWindowFlags))
|
||||||
{
|
{
|
||||||
UiShared.TextWrapped("Enter the new Syncshell password for Syncshell " + name + " here.");
|
UiShared.TextWrapped("Enter the new Syncshell password for Syncshell " + name + " here.");
|
||||||
UiShared.TextWrapped("This action is irreversible");
|
UiShared.TextWrapped("This action is irreversible");
|
||||||
|
ImGui.SetNextItemWidth(-1);
|
||||||
ImGui.InputTextWithHint("##changepw", "New password for " + name, ref _newSyncShellPassword, 255);
|
ImGui.InputTextWithHint("##changepw", "New password for " + name, ref _newSyncShellPassword, 255);
|
||||||
if (ImGui.Button("Change password"))
|
if (ImGui.Button("Change password"))
|
||||||
{
|
{
|
||||||
@@ -361,6 +365,7 @@ namespace MareSynchronos.UI
|
|||||||
UiShared.ColorTextWrapped("The selected password is too short. It must be at least 10 characters.", new Vector4(1, 0, 0, 1));
|
UiShared.ColorTextWrapped("The selected password is too short. It must be at least 10 characters.", new Vector4(1, 0, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UiShared.SetScaledWindowSize(290);
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,9 +712,8 @@ namespace MareSynchronos.UI
|
|||||||
|
|
||||||
if (!_showModalBanUser) _banUserPopupOpen = false;
|
if (!_showModalBanUser) _banUserPopupOpen = false;
|
||||||
|
|
||||||
if (ImGui.BeginPopupModal("Ban User", ref _showModalBanUser))
|
if (ImGui.BeginPopupModal("Ban User", ref _showModalBanUser, UiShared.PopupWindowFlags))
|
||||||
{
|
{
|
||||||
ImGui.SetWindowSize(new Vector2(300, 200));
|
|
||||||
UiShared.TextWrapped("User " + (entry.UserAlias ?? entry.UserUID) + " will be banned and removed from this Syncshell.");
|
UiShared.TextWrapped("User " + (entry.UserAlias ?? entry.UserUID) + " will be banned and removed from this Syncshell.");
|
||||||
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
|
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
|
||||||
if (ImGui.Button("Ban User"))
|
if (ImGui.Button("Ban User"))
|
||||||
@@ -720,6 +724,7 @@ namespace MareSynchronos.UI
|
|||||||
_banReason = string.Empty;
|
_banReason = string.Empty;
|
||||||
}
|
}
|
||||||
UiShared.TextWrapped("The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason.");
|
UiShared.TextWrapped("The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason.");
|
||||||
|
UiShared.SetScaledWindowSize(300);
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -431,28 +431,31 @@ public class SettingsUi : Window, IDisposable
|
|||||||
|
|
||||||
UiShared.DrawHelpText("Completely deletes all your uploaded files on the service.");
|
UiShared.DrawHelpText("Completely deletes all your uploaded files on the service.");
|
||||||
|
|
||||||
if (ImGui.BeginPopupModal("Delete all your files?", ref _deleteFilesPopupModalShown,
|
if (ImGui.BeginPopupModal("Delete all your files?", ref _deleteFilesPopupModalShown, UiShared.PopupWindowFlags))
|
||||||
ImGuiWindowFlags.AlwaysAutoResize))
|
|
||||||
{
|
{
|
||||||
UiShared.TextWrapped(
|
UiShared.TextWrapped(
|
||||||
"All your own uploaded files on the service will be deleted.\nThis operation cannot be undone.");
|
"All your own uploaded files on the service will be deleted.\nThis operation cannot be undone.");
|
||||||
ImGui.Text("Are you sure you want to continue?");
|
ImGui.Text("Are you sure you want to continue?");
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
if (ImGui.Button("Delete everything", new Vector2(150, 0)))
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
var buttonSize = (ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X -
|
||||||
|
ImGui.GetStyle().ItemSpacing.X) / 2;
|
||||||
|
|
||||||
|
if (ImGui.Button("Delete everything", new Vector2(buttonSize, 0)))
|
||||||
{
|
{
|
||||||
Task.Run(() => _apiController.DeleteAllMyFiles());
|
Task.Run(() => _apiController.DeleteAllMyFiles());
|
||||||
ImGui.CloseCurrentPopup();
|
|
||||||
_deleteFilesPopupModalShown = false;
|
_deleteFilesPopupModalShown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
if (ImGui.Button("Cancel##cancelDelete", new Vector2(150, 0)))
|
if (ImGui.Button("Cancel##cancelDelete", new Vector2(buttonSize, 0)))
|
||||||
{
|
{
|
||||||
ImGui.CloseCurrentPopup();
|
|
||||||
_deleteFilesPopupModalShown = false;
|
_deleteFilesPopupModalShown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UiShared.SetScaledWindowSize(325);
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,30 +467,33 @@ public class SettingsUi : Window, IDisposable
|
|||||||
|
|
||||||
UiShared.DrawHelpText("Completely deletes your account and all uploaded files to the service.");
|
UiShared.DrawHelpText("Completely deletes your account and all uploaded files to the service.");
|
||||||
|
|
||||||
if (ImGui.BeginPopupModal("Delete your account?", ref _deleteAccountPopupModalShown,
|
if (ImGui.BeginPopupModal("Delete your account?", ref _deleteAccountPopupModalShown, UiShared.PopupWindowFlags))
|
||||||
ImGuiWindowFlags.AlwaysAutoResize))
|
|
||||||
{
|
{
|
||||||
UiShared.TextWrapped(
|
UiShared.TextWrapped(
|
||||||
"Your account and all associated files and data on the service will be deleted.");
|
"Your account and all associated files and data on the service will be deleted.");
|
||||||
UiShared.TextWrapped("Your UID will be removed from all pairing lists.");
|
UiShared.TextWrapped("Your UID will be removed from all pairing lists.");
|
||||||
ImGui.Text("Are you sure you want to continue?");
|
ImGui.Text("Are you sure you want to continue?");
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
if (ImGui.Button("Delete account", new Vector2(150, 0)))
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
var buttonSize = (ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X -
|
||||||
|
ImGui.GetStyle().ItemSpacing.X) / 2;
|
||||||
|
|
||||||
|
if (ImGui.Button("Delete account", new Vector2(buttonSize, 0)))
|
||||||
{
|
{
|
||||||
Task.Run(() => _apiController.DeleteAccount());
|
Task.Run(() => _apiController.DeleteAccount());
|
||||||
ImGui.CloseCurrentPopup();
|
|
||||||
_deleteAccountPopupModalShown = false;
|
_deleteAccountPopupModalShown = false;
|
||||||
SwitchToIntroUi?.Invoke();
|
SwitchToIntroUi?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
if (ImGui.Button("Cancel##cancelDelete", new Vector2(150, 0)))
|
if (ImGui.Button("Cancel##cancelDelete", new Vector2(buttonSize, 0)))
|
||||||
{
|
{
|
||||||
ImGui.CloseCurrentPopup();
|
|
||||||
_deleteAccountPopupModalShown = false;
|
_deleteAccountPopupModalShown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UiShared.SetScaledWindowSize(325);
|
||||||
ImGui.EndPopup();
|
ImGui.EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ public class UiShared : IDisposable
|
|||||||
public bool UidFontBuilt { get; private set; }
|
public bool UidFontBuilt { get; private set; }
|
||||||
public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0;
|
public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0;
|
||||||
public static bool ShiftPressed() => (GetKeyState(0xA1) & 0x8000) != 0 || (GetKeyState(0xA0) & 0x8000) != 0;
|
public static bool ShiftPressed() => (GetKeyState(0xA1) & 0x8000) != 0 || (GetKeyState(0xA0) & 0x8000) != 0;
|
||||||
|
|
||||||
|
public static ImGuiWindowFlags PopupWindowFlags = ImGuiWindowFlags.NoResize |
|
||||||
|
ImGuiWindowFlags.NoScrollbar |
|
||||||
|
ImGuiWindowFlags.NoScrollWithMouse;
|
||||||
|
|
||||||
public ApiController ApiController => _apiController;
|
public ApiController ApiController => _apiController;
|
||||||
|
|
||||||
@@ -98,6 +102,38 @@ public class UiShared : IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetScaledWindowSize(float width, bool centerWindow = true)
|
||||||
|
{
|
||||||
|
var newLineHeight = ImGui.GetCursorPosY();
|
||||||
|
ImGui.NewLine();
|
||||||
|
newLineHeight = ImGui.GetCursorPosY() - newLineHeight;
|
||||||
|
var x = width * ImGuiHelpers.GlobalScale;
|
||||||
|
var y = ImGui.GetCursorPos().Y + ImGui.GetWindowContentRegionMin().Y - newLineHeight * 2 - ImGui.GetStyle().ItemSpacing.Y;
|
||||||
|
|
||||||
|
if (centerWindow)
|
||||||
|
{
|
||||||
|
var center = ImGui.GetMainViewport().GetCenter();
|
||||||
|
ImGui.SetWindowPos(new Vector2(center.X - x / 2, center.Y - y / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.SetWindowSize(new Vector2(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetScaledWindowSize(float width, float height, bool centerWindow = true)
|
||||||
|
{
|
||||||
|
ImGui.SameLine();
|
||||||
|
var x = width * ImGuiHelpers.GlobalScale;
|
||||||
|
var y = height * ImGuiHelpers.GlobalScale;
|
||||||
|
|
||||||
|
if (centerWindow)
|
||||||
|
{
|
||||||
|
var center = ImGui.GetMainViewport().GetCenter();
|
||||||
|
ImGui.SetWindowPos(new Vector2(center.X - x / 2, center.Y - y / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.SetWindowSize(new Vector2(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
public static void DrawWithID(string id, Action drawSubSection)
|
public static void DrawWithID(string id, Action drawSubSection)
|
||||||
{
|
{
|
||||||
ImGui.PushID(id);
|
ImGui.PushID(id);
|
||||||
|
|||||||
Reference in New Issue
Block a user