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:
rootdarkarchon
2023-10-17 21:36:44 +02:00
committed by GitHub
parent f15b8f6bbd
commit 14575a4a6b
111 changed files with 3456 additions and 3174 deletions

View File

@@ -1,47 +1,49 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using ImGuiNET;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.MareConfiguration;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.Services;
using MareSynchronos.Services.Mediator;
using MareSynchronos.Services.ServerConfiguration;
using Microsoft.Extensions.Logging;
using System.Numerics;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.MareConfiguration;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Internal;
namespace MareSynchronos.UI;
public class PopoutProfileUi : WindowMediatorSubscriberBase
{
private readonly MareProfileManager _mareProfileManager;
private readonly PairManager _pairManager;
private readonly ServerConfigurationManager _serverManager;
private readonly UiSharedService _uiSharedService;
private Vector2 _lastMainPos = Vector2.Zero;
private Vector2 _lastMainSize = Vector2.Zero;
private byte[] _lastProfilePicture = Array.Empty<byte>();
private byte[] _lastSupporterPicture = Array.Empty<byte>();
private byte[] _lastProfilePicture = [];
private byte[] _lastSupporterPicture = [];
private Pair? _pair;
private IDalamudTextureWrap? _supporterTextureWrap;
private IDalamudTextureWrap? _textureWrap;
public PopoutProfileUi(ILogger<PopoutProfileUi> logger, MareMediator mediator, UiSharedService uiBuilder,
ServerConfigurationManager serverManager, MareConfigService mareConfigService,
MareProfileManager mareProfileManager) : base(logger, mediator, "###MareSynchronosPopoutProfileUI")
MareProfileManager mareProfileManager, PairManager pairManager) : base(logger, mediator, "###MareSynchronosPopoutProfileUI")
{
_uiSharedService = uiBuilder;
_serverManager = serverManager;
_mareProfileManager = mareProfileManager;
_pairManager = pairManager;
Flags = ImGuiWindowFlags.NoDecoration;
Mediator.Subscribe<ProfilePopoutToggle>(this, (msg) =>
{
IsOpen = msg.Pair != null;
_pair = msg.Pair;
_lastProfilePicture = Array.Empty<byte>();
_lastSupporterPicture = Array.Empty<byte>();
_lastProfilePicture = [];
_lastSupporterPicture = [];
_textureWrap?.Dispose();
_textureWrap = null;
_supporterTextureWrap?.Dispose();
@@ -54,7 +56,6 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
{
var border = ImGui.GetStyle().WindowBorderSize;
var padding = ImGui.GetStyle().WindowPadding;
var spacing = ImGui.GetStyle().ItemSpacing;
Size = new(256 + (padding.X * 2) + border, msg.Size.Y / ImGuiHelpers.GlobalScale);
_lastMainSize = msg.Size;
}
@@ -65,7 +66,7 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
}
else
{
Position = new(mainPos.X - Size.Value.X * ImGuiHelpers.GlobalScale, mainPos.Y);
Position = new(mainPos.X - Size!.Value.X * ImGuiHelpers.GlobalScale, mainPos.Y);
}
if (msg.Position != Vector2.Zero)
@@ -129,7 +130,7 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
ImGui.SameLine();
ImGui.TextUnformatted($"({_pair.PlayerName})");
}
if (_pair.UserPair != null)
if (_pair.UserPair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional)
{
ImGui.TextUnformatted("Directly paired");
if (_pair.UserPair.OwnPermissions.IsPaused())
@@ -143,13 +144,14 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
UiSharedService.ColorText("They: paused", ImGuiColors.DalamudYellow);
}
}
if (_pair.GroupPair.Any())
if (_pair.UserPair.Groups.Any())
{
ImGui.TextUnformatted("Paired through Syncshells:");
foreach (var groupPair in _pair.GroupPair.Select(k => k.Key))
foreach (var group in _pair.UserPair.Groups)
{
var groupNote = _serverManager.GetNoteForGid(groupPair.GID);
var groupString = string.IsNullOrEmpty(groupNote) ? groupPair.GroupAliasOrGID : $"{groupNote} ({groupPair.GroupAliasOrGID})";
var groupNote = _serverManager.GetNoteForGid(group);
var groupName = _pairManager.GroupPairs.First(f => string.Equals(f.Key.GID, group, StringComparison.Ordinal)).Key.GroupAliasOrGID;
var groupString = string.IsNullOrEmpty(groupNote) ? groupName : $"{groupNote} ({groupName})";
ImGui.TextUnformatted("- " + groupString);
}
}
@@ -162,7 +164,7 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
bool trimmed = textSize.Y > remaining;
while (textSize.Y > remaining && descText.Contains(' '))
{
descText = descText.Substring(0, descText.LastIndexOf(' ')).TrimEnd();
descText = descText[..descText.LastIndexOf(' ')].TrimEnd();
textSize = ImGui.CalcTextSize(descText + $"...{Environment.NewLine}[Open Full Profile for complete description]", 256f * ImGuiHelpers.GlobalScale);
}
UiSharedService.TextWrapped(trimmed ? descText + $"...{Environment.NewLine}[Open Full Profile for complete description]" : mareProfile.Description);