add note handling
This commit is contained in:
@@ -89,6 +89,7 @@ public class Configuration : IPluginConfiguration
|
||||
public int Version { get; set; } = 5;
|
||||
|
||||
public bool ShowTransferWindow { get; set; } = true;
|
||||
public bool OpenPopupOnAdd { get; set; } = false;
|
||||
|
||||
// the below exist just to make saving less cumbersome
|
||||
public void Initialize(DalamudPluginInterface pluginInterface)
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Components;
|
||||
@@ -36,10 +37,12 @@ public class CompactUi : Window, IDisposable
|
||||
|
||||
public float TransferPartHeight = 0;
|
||||
public float _windowContentWidth = 0;
|
||||
|
||||
private bool _showModalForUserAddition = false;
|
||||
|
||||
private bool showSyncShells = false;
|
||||
private GroupPanel groupPanel;
|
||||
private ClientPairDto? _lastAddedUser;
|
||||
private string _lastAddedUserComment = string.Empty;
|
||||
|
||||
public CompactUi(WindowSystem windowSystem,
|
||||
UiShared uiShared, Configuration configuration, ApiController apiController) : base("###MareSynchronosMainUI")
|
||||
@@ -89,6 +92,8 @@ public class CompactUi : Window, IDisposable
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
_showModalForUserAddition = _configuration.OpenPopupOnAdd;
|
||||
|
||||
_windowContentWidth = UiShared.GetWindowContentRegionWidth();
|
||||
UiShared.DrawWithID("header", DrawUIDHeader);
|
||||
ImGui.Separator();
|
||||
@@ -147,6 +152,38 @@ public class CompactUi : Window, IDisposable
|
||||
UiShared.DrawWithID("transfers", DrawTransfers);
|
||||
TransferPartHeight = ImGui.GetCursorPosY() - TransferPartHeight;
|
||||
}
|
||||
|
||||
if (_showModalForUserAddition && _apiController.LastAddedUser != null)
|
||||
{
|
||||
_lastAddedUser = _apiController.LastAddedUser;
|
||||
_apiController.LastAddedUser = null;
|
||||
ImGui.OpenPopup("Set Notes for New User");
|
||||
_showModalForUserAddition = true;
|
||||
_lastAddedUserComment = string.Empty;
|
||||
}
|
||||
|
||||
if (ImGui.BeginPopupModal("Set Notes for New User", ref _showModalForUserAddition, ImGuiWindowFlags.AlwaysAutoResize))
|
||||
{
|
||||
if (_lastAddedUser == null)
|
||||
{
|
||||
_showModalForUserAddition = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var uid = string.IsNullOrEmpty(_lastAddedUser!.VanityUID) ? _lastAddedUser.OtherUID : _lastAddedUser.VanityUID;
|
||||
UiShared.TextWrapped($"You have successfully added {uid}. Set a local note for the user in the field below:");
|
||||
ImGui.InputTextWithHint("##noteforuser", $"Note for {uid}", ref _lastAddedUserComment, 100);
|
||||
if (UiShared.IconTextButton(FontAwesomeIcon.Save, "Save Note"))
|
||||
{
|
||||
_configuration.SetCurrentServerUidComment(_lastAddedUser.OtherUID, _lastAddedUserComment);
|
||||
_lastAddedUser = null;
|
||||
_lastAddedUserComment = string.Empty;
|
||||
_configuration.Save();
|
||||
_showModalForUserAddition = false;
|
||||
}
|
||||
}
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
|
||||
@@ -11,7 +11,6 @@ using System.Threading.Tasks;
|
||||
using MareSynchronos.API;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI.Utils;
|
||||
using System.Diagnostics;
|
||||
using Dalamud.Utility;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
@@ -27,6 +26,7 @@ public class SettingsUi : Window, IDisposable
|
||||
private bool _overwriteExistingLabels = false;
|
||||
private bool? _notesSuccessfullyApplied = null;
|
||||
private string _lastTab = string.Empty;
|
||||
private bool _openPopupOnAddition;
|
||||
|
||||
public SettingsUi(WindowSystem windowSystem,
|
||||
UiShared uiShared, Configuration configuration, ApiController apiController) : base("Mare Synchronos Settings")
|
||||
@@ -43,6 +43,7 @@ public class SettingsUi : Window, IDisposable
|
||||
_windowSystem = windowSystem;
|
||||
_apiController = apiController;
|
||||
_uiShared = uiShared;
|
||||
_openPopupOnAddition = _configuration.OpenPopupOnAdd;
|
||||
windowSystem.AddWindow(this);
|
||||
}
|
||||
|
||||
@@ -73,6 +74,12 @@ public class SettingsUi : Window, IDisposable
|
||||
ImGui.Separator();
|
||||
if (ImGui.BeginTabBar("mainTabBar"))
|
||||
{
|
||||
if (ImGui.BeginTabItem("General"))
|
||||
{
|
||||
DrawGeneral();
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui.BeginTabItem("Cache Settings"))
|
||||
{
|
||||
DrawFileCacheSettings();
|
||||
@@ -100,12 +107,6 @@ public class SettingsUi : Window, IDisposable
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui.BeginTabItem("Privacy"))
|
||||
{
|
||||
DrawPrivacy();
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
if (_apiController.IsConnected && _apiController.IsModerator)
|
||||
{
|
||||
if (ImGui.BeginTabItem("Administration"))
|
||||
@@ -124,14 +125,14 @@ public class SettingsUi : Window, IDisposable
|
||||
private string _bannedUserHashEntry = string.Empty;
|
||||
private string _bannedUserReasonEntry = string.Empty;
|
||||
|
||||
private void DrawPrivacy()
|
||||
private void DrawGeneral()
|
||||
{
|
||||
if (!string.Equals(_lastTab, "Privacy", StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.Equals(_lastTab, "General", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_notesSuccessfullyApplied = null;
|
||||
}
|
||||
|
||||
_lastTab = "Privacy";
|
||||
_lastTab = "General";
|
||||
if (UiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Export all your user notes to clipboard"))
|
||||
{
|
||||
ImGui.SetClipboardText(_uiShared.GetNotes());
|
||||
@@ -154,10 +155,15 @@ public class SettingsUi : Window, IDisposable
|
||||
{
|
||||
UiShared.ColorTextWrapped("Attempt to import notes from clipboard failed. Check formatting and try again", ImGuiColors.DalamudRed);
|
||||
}
|
||||
ImGui.Separator();
|
||||
if (ImGui.Checkbox("Open Notes Popup on user addition", ref _openPopupOnAddition))
|
||||
{
|
||||
_configuration.OpenPopupOnAdd = _openPopupOnAddition;
|
||||
_configuration.Save();
|
||||
}
|
||||
UiShared.DrawHelpText("This will open a popup that allows you to set the notes for a user after successfully adding them to your individual pairs.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void DrawAdministration()
|
||||
{
|
||||
_lastTab = "Administration";
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace MareSynchronos.WebAPI;
|
||||
|
||||
public partial class ApiController
|
||||
{
|
||||
public ClientPairDto? LastAddedUser { get; set; }
|
||||
|
||||
private void UserForcedReconnectCallback()
|
||||
{
|
||||
_ = CreateConnections();
|
||||
@@ -25,6 +27,7 @@ public partial class ApiController
|
||||
}
|
||||
if (entry == null)
|
||||
{
|
||||
LastAddedUser = dto;
|
||||
PairedClients.Add(dto);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user