Mare 0.9 (#65)
* add jwt expiry * start of 0.9 api impl * some stuff idk * some more impl * some cleanup * remove grouppair, add configuration, rework some pair drawing stuff * do some stuff * rework some ui * I don't even know anymore * add cancellationtoken * token bla * ui fixes etc * probably individual adding/removing now working fully as expected * add working report popup * I guess it's more syncshell shit or so * popup shit idk * work out most of the syncshell bullshit I guess * delete some old crap * are we actually getting closer to the end * update pair info stuff * more fixes/adjustments, idk * refactor some things * some rework * some more cleanup * cleanup * make menu buttons w i d e * better icon text buttons * add all syncshell folder and ordering fixes --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
@@ -1,41 +1,96 @@
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using ImGuiScene;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
|
||||
namespace MareSynchronos.UI.Handlers;
|
||||
|
||||
public class UidDisplayHandler
|
||||
public class IdDisplayHandler
|
||||
{
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
private readonly Dictionary<string, bool> _showUidForEntry = new(StringComparer.Ordinal);
|
||||
private string _editNickEntry = string.Empty;
|
||||
private string _editUserComment = string.Empty;
|
||||
private readonly Dictionary<string, bool> _showIdForEntry = new(StringComparer.Ordinal);
|
||||
private string _editComment = string.Empty;
|
||||
private string _editEntry = string.Empty;
|
||||
private bool _editIsUid = false;
|
||||
private string _lastMouseOverUid = string.Empty;
|
||||
private bool _popupShown = false;
|
||||
private DateTime? _popupTime;
|
||||
private TextureWrap? _textureWrap;
|
||||
|
||||
public UidDisplayHandler(MareMediator mediator, PairManager pairManager,
|
||||
ServerConfigurationManager serverManager, MareConfigService mareConfigService)
|
||||
public IdDisplayHandler(MareMediator mediator, ServerConfigurationManager serverManager, MareConfigService mareConfigService)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_pairManager = pairManager;
|
||||
_serverManager = serverManager;
|
||||
_mareConfigService = mareConfigService;
|
||||
}
|
||||
|
||||
public void DrawGroupText(string id, GroupFullInfoDto group, float textPosX, float originalY, Func<float> editBoxWidth)
|
||||
{
|
||||
ImGui.SameLine(textPosX);
|
||||
(bool textIsUid, string playerText) = GetGroupText(group);
|
||||
if (!string.Equals(_editEntry, group.GID, StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
using (ImRaii.PushFont(UiBuilder.MonoFont, textIsUid))
|
||||
ImGui.TextUnformatted(playerText);
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
{
|
||||
var prevState = textIsUid;
|
||||
if (_showIdForEntry.ContainsKey(group.GID))
|
||||
{
|
||||
prevState = _showIdForEntry[group.GID];
|
||||
}
|
||||
_showIdForEntry[group.GID] = !prevState;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
if (_editIsUid)
|
||||
{
|
||||
_serverManager.SetNoteForUid(_editEntry, _editComment, save: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverManager.SetNoteForGid(_editEntry, _editComment, save: true);
|
||||
}
|
||||
|
||||
_editComment = _serverManager.GetNoteForGid(group.GID) ?? string.Empty;
|
||||
_editEntry = group.GID;
|
||||
_editIsUid = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
|
||||
ImGui.SetNextItemWidth(editBoxWidth.Invoke());
|
||||
if (ImGui.InputTextWithHint("", "Name/Notes", ref _editComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_serverManager.SetNoteForGid(group.GID, _editComment, save: true);
|
||||
_editEntry = string.Empty;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
_editEntry = string.Empty;
|
||||
}
|
||||
UiSharedService.AttachToolTip("Hit ENTER to save\nRight click to cancel");
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawPairText(string id, Pair pair, float textPosX, float originalY, Func<float> editBoxWidth)
|
||||
{
|
||||
ImGui.SameLine(textPosX);
|
||||
(bool textIsUid, string playerText) = GetPlayerText(pair);
|
||||
if (!string.Equals(_editNickEntry, pair.UserData.UID, StringComparison.Ordinal))
|
||||
if (!string.Equals(_editEntry, pair.UserData.UID, StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
if (textIsUid) ImGui.PushFont(UiBuilder.MonoFont);
|
||||
@@ -66,7 +121,7 @@ public class UidDisplayHandler
|
||||
{
|
||||
if (string.Equals(_lastMouseOverUid, id))
|
||||
{
|
||||
_mediator.Publish(new ProfilePopoutToggle(null));
|
||||
_mediator.Publish(new ProfilePopoutToggle(Pair: null));
|
||||
_lastMouseOverUid = string.Empty;
|
||||
_popupShown = false;
|
||||
_textureWrap?.Dispose();
|
||||
@@ -77,19 +132,27 @@ public class UidDisplayHandler
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
{
|
||||
var prevState = textIsUid;
|
||||
if (_showUidForEntry.ContainsKey(pair.UserData.UID))
|
||||
if (_showIdForEntry.ContainsKey(pair.UserData.UID))
|
||||
{
|
||||
prevState = _showUidForEntry[pair.UserData.UID];
|
||||
prevState = _showIdForEntry[pair.UserData.UID];
|
||||
}
|
||||
_showUidForEntry[pair.UserData.UID] = !prevState;
|
||||
_showIdForEntry[pair.UserData.UID] = !prevState;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
var nickEntryPair = _pairManager.DirectPairs.Find(p => string.Equals(p.UserData.UID, _editNickEntry, StringComparison.Ordinal));
|
||||
nickEntryPair?.SetNote(_editUserComment);
|
||||
_editUserComment = pair.GetNote() ?? string.Empty;
|
||||
_editNickEntry = pair.UserData.UID;
|
||||
if (_editIsUid)
|
||||
{
|
||||
_serverManager.SetNoteForUid(_editEntry, _editComment, save: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverManager.SetNoteForGid(_editEntry, _editComment, save: true);
|
||||
}
|
||||
|
||||
_editComment = pair.GetNote() ?? string.Empty;
|
||||
_editEntry = pair.UserData.UID;
|
||||
_editIsUid = true;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Middle))
|
||||
@@ -102,21 +165,45 @@ public class UidDisplayHandler
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
|
||||
ImGui.SetNextItemWidth(editBoxWidth.Invoke());
|
||||
if (ImGui.InputTextWithHint("", "Nick/Notes", ref _editUserComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
if (ImGui.InputTextWithHint("", "Nick/Notes", ref _editComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_serverManager.SetNoteForUid(pair.UserData.UID, _editUserComment);
|
||||
_serverManager.SetNoteForUid(pair.UserData.UID, _editComment);
|
||||
_serverManager.SaveNotes();
|
||||
_editNickEntry = string.Empty;
|
||||
_editEntry = string.Empty;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
_editNickEntry = string.Empty;
|
||||
_editEntry = string.Empty;
|
||||
}
|
||||
UiSharedService.AttachToolTip("Hit ENTER to save\nRight click to cancel");
|
||||
}
|
||||
}
|
||||
|
||||
public (bool isGid, string text) GetGroupText(GroupFullInfoDto group)
|
||||
{
|
||||
var textIsGid = true;
|
||||
bool showUidInsteadOfName = ShowGidInsteadOfName(group);
|
||||
string? groupText = _serverManager.GetNoteForGid(group.GID);
|
||||
if (!showUidInsteadOfName && groupText != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(groupText))
|
||||
{
|
||||
groupText = group.GroupAliasOrGID;
|
||||
}
|
||||
else
|
||||
{
|
||||
textIsGid = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groupText = group.GroupAliasOrGID;
|
||||
}
|
||||
|
||||
return (textIsGid, groupText!);
|
||||
}
|
||||
|
||||
public (bool isUid, string text) GetPlayerText(Pair pair)
|
||||
{
|
||||
var textIsUid = true;
|
||||
@@ -157,8 +244,8 @@ public class UidDisplayHandler
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
_editNickEntry = string.Empty;
|
||||
_editUserComment = string.Empty;
|
||||
_editEntry = string.Empty;
|
||||
_editComment = string.Empty;
|
||||
}
|
||||
|
||||
internal void OpenProfile(Pair entry)
|
||||
@@ -166,10 +253,17 @@ public class UidDisplayHandler
|
||||
_mediator.Publish(new ProfileOpenStandaloneMessage(entry));
|
||||
}
|
||||
|
||||
private bool ShowGidInsteadOfName(GroupFullInfoDto group)
|
||||
{
|
||||
_showIdForEntry.TryGetValue(group.GID, out var showidInsteadOfName);
|
||||
|
||||
return showidInsteadOfName;
|
||||
}
|
||||
|
||||
private bool ShowUidInsteadOfName(Pair pair)
|
||||
{
|
||||
_showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName);
|
||||
_showIdForEntry.TryGetValue(pair.UserData.UID, out var showidInsteadOfName);
|
||||
|
||||
return showUidInsteadOfName;
|
||||
return showidInsteadOfName;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace MareSynchronos.UI.Handlers;
|
||||
|
||||
public class TagHandler
|
||||
{
|
||||
public const string CustomAllTag = "Mare_All";
|
||||
public const string CustomOfflineTag = "Mare_Offline";
|
||||
public const string CustomOnlineTag = "Mare_Online";
|
||||
public const string CustomUnpairedTag = "Mare_Unpaired";
|
||||
@@ -27,9 +28,12 @@ public class TagHandler
|
||||
|
||||
public List<string> GetAllTagsSorted()
|
||||
{
|
||||
return _serverConfigurationManager.GetServerAvailablePairTags()
|
||||
.OrderBy(s => s, StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
return
|
||||
[
|
||||
.. _serverConfigurationManager.GetServerAvailablePairTags()
|
||||
.OrderBy(s => s, StringComparer.OrdinalIgnoreCase)
|
||||
,
|
||||
];
|
||||
}
|
||||
|
||||
public HashSet<string> GetOtherUidsForTag(string tag)
|
||||
@@ -59,7 +63,6 @@ public class TagHandler
|
||||
|
||||
public void RemoveTag(string tag)
|
||||
{
|
||||
// First remove the tag from teh available pair tags
|
||||
_serverConfigurationManager.RemoveTag(tag);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user