Client rework for API change and paradigm shift (#39)
* most of the groups refactoring on client * register OnMethods for group stuff * start implementing client (still pretty broken) * finish implementing new api first iteration * idk rework everything for pair shit (still WIP); goal is to remove PairedClients and GroupPairClients from ApiController * move everything to PairManager, remove dictionaries from APiController * remove admin stuff from client, cleanup * adjust reconnection handling, add new settings, todo still to remove access from old stuff that's marked obsolete from config * add back adding servers, fix intro ui * fix obsolete calls * adjust config namespace * add UI for setting animation/sound permissions to syncshells * add ConfigurationService to hot reload config on change from external * move transient data cache to configuration * add deleting service to ui * fix saving of transient resources * fix group pair user assignments * halt scanner when penumbra inactive, add visible/online/offline split to individual pairs and tags * add presence to syncshell ui * move fullpause from config to server config * fixes in code style * more codestyle * show info icon on player in shells, don't show icon when no changes from default state are made, add online notifs * fixes to intro UI --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Components;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.Models;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
using MareSynchronos.WebAPI;
|
||||
|
||||
@@ -12,12 +10,12 @@ namespace MareSynchronos.UI.Components
|
||||
{
|
||||
public class PairGroupsUi
|
||||
{
|
||||
private readonly Action<ClientPairDto> _clientRenderFn;
|
||||
private readonly Action<Pair> _clientRenderFn;
|
||||
private readonly TagHandler _tagHandler;
|
||||
private readonly ApiController _apiController;
|
||||
private readonly SelectPairForGroupUi _selectGroupForPairUi;
|
||||
|
||||
public PairGroupsUi(TagHandler tagHandler, Action<ClientPairDto> clientRenderFn, ApiController apiController, SelectPairForGroupUi selectGroupForPairUi)
|
||||
public PairGroupsUi(TagHandler tagHandler, Action<Pair> clientRenderFn, ApiController apiController, SelectPairForGroupUi selectGroupForPairUi)
|
||||
{
|
||||
_clientRenderFn = clientRenderFn;
|
||||
_tagHandler = tagHandler;
|
||||
@@ -25,30 +23,57 @@ namespace MareSynchronos.UI.Components
|
||||
_selectGroupForPairUi = selectGroupForPairUi;
|
||||
}
|
||||
|
||||
public void Draw(List<ClientPairDto> availablePairs)
|
||||
public void Draw(List<Pair> visibleUsers, List<Pair> onlineUsers, List<Pair> offlineUsers)
|
||||
{
|
||||
// Only render those tags that actually have pairs in them, otherwise
|
||||
// we can end up with a bunch of useless pair groups
|
||||
var tagsWithPairsInThem = _tagHandler.GetAllTagsSorted();
|
||||
foreach (var tag in tagsWithPairsInThem)
|
||||
{
|
||||
UiShared.DrawWithID($"group-{tag}", () => DrawCategory(tag, availablePairs));
|
||||
UiShared.DrawWithID($"group-{tag}", () => DrawCategory(tag, visibleUsers, onlineUsers, offlineUsers));
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawCategory(string tag, List<ClientPairDto> availablePairs)
|
||||
public void DrawCategory(string tag, List<Pair> visibleUsers, List<Pair> onlineUsers, List<Pair> offlineUsers)
|
||||
{
|
||||
var otherUidsTaggedWithTag = _tagHandler.GetOtherUidsForTag(tag);
|
||||
var availablePairsInThisTag = availablePairs
|
||||
.Where(pair => otherUidsTaggedWithTag.Contains(pair.OtherUID))
|
||||
var visiblePairsInThisTag = visibleUsers
|
||||
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
|
||||
.ToList();
|
||||
if (availablePairsInThisTag.Any())
|
||||
var onlinePairsInThisTag = onlineUsers
|
||||
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
|
||||
.ToList();
|
||||
var offlinePairsInThisTag = offlineUsers
|
||||
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
|
||||
.ToList();
|
||||
if (visiblePairsInThisTag.Any() || onlinePairsInThisTag.Any() || offlinePairsInThisTag.Any())
|
||||
{
|
||||
DrawName(tag);
|
||||
UiShared.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, availablePairsInThisTag));
|
||||
UiShared.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, visiblePairsInThisTag));
|
||||
if (_tagHandler.IsTagOpen(tag))
|
||||
{
|
||||
DrawPairs(tag, availablePairsInThisTag);
|
||||
ImGui.Indent(20);
|
||||
if (visiblePairsInThisTag.Any())
|
||||
{
|
||||
ImGui.Text("Visible");
|
||||
ImGui.Separator();
|
||||
DrawPairs(tag, visiblePairsInThisTag);
|
||||
}
|
||||
|
||||
if (onlinePairsInThisTag.Any())
|
||||
{
|
||||
ImGui.Text("Online");
|
||||
ImGui.Separator();
|
||||
DrawPairs(tag, onlinePairsInThisTag);
|
||||
}
|
||||
|
||||
if (offlinePairsInThisTag.Any())
|
||||
{
|
||||
ImGui.Text("Offline/Unknown");
|
||||
ImGui.Separator();
|
||||
DrawPairs(tag, offlinePairsInThisTag);
|
||||
}
|
||||
ImGui.Unindent(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,9 +97,9 @@ namespace MareSynchronos.UI.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawButtons(string tag, List<ClientPairDto> availablePairsInThisTag)
|
||||
private void DrawButtons(string tag, List<Pair> availablePairsInThisTag)
|
||||
{
|
||||
var allArePaused = availablePairsInThisTag.All(pair => pair.IsPaused);
|
||||
var allArePaused = availablePairsInThisTag.All(pair => pair.UserPair!.OwnPermissions.IsPaused());
|
||||
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||
var flyoutMenuX = UiShared.GetIconButtonSize(FontAwesomeIcon.Bars).X;
|
||||
var pauseButtonX = UiShared.GetIconButtonSize(pauseButton).X;
|
||||
@@ -142,43 +167,37 @@ namespace MareSynchronos.UI.Components
|
||||
UiShared.AttachToolTip($"Delete Group {tag} (Will not delete the pairs)" + Environment.NewLine + "Hold CTRL to delete");
|
||||
}
|
||||
|
||||
private void DrawPairs(string tag, List<ClientPairDto> availablePairsInThisCategory)
|
||||
private void DrawPairs(string tag, List<Pair> availablePairsInThisCategory)
|
||||
{
|
||||
ImGui.Separator();
|
||||
// These are all the OtherUIDs that are tagged with this tag
|
||||
availablePairsInThisCategory
|
||||
.ForEach(pair => UiShared.DrawWithID($"tag-{tag}-pair-${pair.OtherUID}", () => DrawPair(pair)));
|
||||
.ForEach(pair => UiShared.DrawWithID($"tag-{tag}-pair-${pair.UserData.UID}", () => _clientRenderFn(pair)));
|
||||
ImGui.Separator();
|
||||
}
|
||||
|
||||
private void DrawPair(ClientPairDto pair)
|
||||
{
|
||||
// This is probably just dumb. Somehow, just setting the cursor position to the icon lenght
|
||||
// does not really push the child rendering further. So we'll just add two whitespaces and call it a day?
|
||||
UiShared.FontText(" ", UiBuilder.DefaultFont);
|
||||
ImGui.SameLine();
|
||||
_clientRenderFn(pair);
|
||||
}
|
||||
|
||||
private void ToggleTagOpen(string tag)
|
||||
{
|
||||
bool open = !_tagHandler.IsTagOpen(tag);
|
||||
_tagHandler.SetTagOpen(tag, open);
|
||||
}
|
||||
|
||||
private void PauseRemainingPairs(List<ClientPairDto> availablePairs)
|
||||
private void PauseRemainingPairs(List<Pair> availablePairs)
|
||||
{
|
||||
foreach (var pairToPause in availablePairs.Where(pair => !pair.IsPaused))
|
||||
foreach (var pairToPause in availablePairs.Where(pair => !pair.UserPair!.OwnPermissions.IsPaused()))
|
||||
{
|
||||
_ = _apiController.UserChangePairPauseStatus(pairToPause.OtherUID, paused: true);
|
||||
var perm = pairToPause.UserPair!.OwnPermissions;
|
||||
perm.SetPaused(paused: true);
|
||||
_ = _apiController.UserSetPairPermissions(new(pairToPause.UserData, perm));
|
||||
}
|
||||
}
|
||||
|
||||
private void ResumeAllPairs(List<ClientPairDto> availablePairs)
|
||||
private void ResumeAllPairs(List<Pair> availablePairs)
|
||||
{
|
||||
foreach (var pairToPause in availablePairs)
|
||||
{
|
||||
_ = _apiController.UserChangePairPauseStatus(pairToPause.OtherUID, paused: false);
|
||||
var perm = pairToPause.UserPair!.OwnPermissions;
|
||||
perm.SetPaused(paused: false);
|
||||
_ = _apiController.UserSetPairPermissions(new(pairToPause.UserData, perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API;
|
||||
using MareSynchronos.Models;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
|
||||
namespace MareSynchronos.UI.Components;
|
||||
@@ -20,7 +19,7 @@ public class SelectGroupForPairUi
|
||||
/// The group UI is always open for a specific pair. This defines which pair the UI is open for.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private ClientPairDto? _pair;
|
||||
private Pair? _pair;
|
||||
|
||||
/// <summary>
|
||||
/// For the add category option, this stores the currently typed in tag name
|
||||
@@ -28,17 +27,15 @@ public class SelectGroupForPairUi
|
||||
private string _tagNameToAdd = "";
|
||||
|
||||
private readonly TagHandler _tagHandler;
|
||||
private readonly Configuration _configuration;
|
||||
|
||||
public SelectGroupForPairUi(TagHandler tagHandler, Configuration configuration)
|
||||
public SelectGroupForPairUi(TagHandler tagHandler)
|
||||
{
|
||||
_show = false;
|
||||
_pair = null;
|
||||
_tagHandler = tagHandler;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public void Open(ClientPairDto pair)
|
||||
public void Open(Pair pair)
|
||||
{
|
||||
_pair = pair;
|
||||
// Using "_show" here to de-couple the opening of the popup
|
||||
@@ -56,7 +53,7 @@ public class SelectGroupForPairUi
|
||||
return;
|
||||
}
|
||||
|
||||
var name = PairName(showUidForEntry, _pair.OtherUID, _pair.VanityUID);
|
||||
var name = PairName(showUidForEntry, _pair);
|
||||
var popupName = $"Choose Groups for {name}";
|
||||
// Is the popup supposed to show but did not open yet? Open it
|
||||
if (_show)
|
||||
@@ -76,7 +73,7 @@ public class SelectGroupForPairUi
|
||||
{
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
UiShared.DrawWithID($"groups-pair-{_pair.OtherUID}-{tag}", () => DrawGroupName(_pair, tag));
|
||||
UiShared.DrawWithID($"groups-pair-{_pair.UserData.UID}-{tag}", () => DrawGroupName(_pair, tag));
|
||||
}
|
||||
ImGui.EndChild();
|
||||
}
|
||||
@@ -99,19 +96,19 @@ public class SelectGroupForPairUi
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGroupName(ClientPairDto pair, string name)
|
||||
private void DrawGroupName(Pair pair, string name)
|
||||
{
|
||||
var hasTagBefore = _tagHandler.HasTag(pair, name);
|
||||
var hasTagBefore = _tagHandler.HasTag(pair.UserPair!, name);
|
||||
var hasTag = hasTagBefore;
|
||||
if (ImGui.Checkbox(name, ref hasTag))
|
||||
{
|
||||
if (hasTag)
|
||||
{
|
||||
_tagHandler.AddTagToPairedUid(pair, name);
|
||||
_tagHandler.AddTagToPairedUid(pair.UserPair!, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tagHandler.RemoveTagFromPairedUid(pair, name);
|
||||
_tagHandler.RemoveTagFromPairedUid(pair.UserPair!, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,19 +120,19 @@ public class SelectGroupForPairUi
|
||||
_tagHandler.AddTag(_tagNameToAdd);
|
||||
if (_pair != null)
|
||||
{
|
||||
_tagHandler.AddTagToPairedUid(_pair, _tagNameToAdd);
|
||||
_tagHandler.AddTagToPairedUid(_pair.UserPair!, _tagNameToAdd);
|
||||
}
|
||||
_tagNameToAdd = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private string PairName(Dictionary<string, bool> showUidForEntry, string otherUid, string vanityUid)
|
||||
private string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
|
||||
{
|
||||
showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName);
|
||||
_configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText);
|
||||
showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName);
|
||||
var playerText = pair.GetNote();
|
||||
if (showUidInsteadOfName || string.IsNullOrEmpty(playerText))
|
||||
{
|
||||
playerText = string.IsNullOrEmpty(vanityUid) ? otherUid : vanityUid;
|
||||
playerText = pair.UserData.AliasOrUID;
|
||||
}
|
||||
return playerText;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using FFXIVClientStructs.FFXIV.Common.Math;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API;
|
||||
using MareSynchronos.Models;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
|
||||
namespace MareSynchronos.UI.Components;
|
||||
@@ -12,16 +10,14 @@ public class SelectPairForGroupUi
|
||||
{
|
||||
private bool _show = false;
|
||||
private bool _opened = false;
|
||||
private HashSet<string> _peopleInGroup = new(System.StringComparer.Ordinal);
|
||||
private HashSet<string> _peopleInGroup = new(StringComparer.Ordinal);
|
||||
private string _tag = string.Empty;
|
||||
private readonly TagHandler _tagHandler;
|
||||
private readonly Configuration _configuration;
|
||||
private string _filter = string.Empty;
|
||||
|
||||
public SelectPairForGroupUi(TagHandler tagHandler, Configuration configuration)
|
||||
public SelectPairForGroupUi(TagHandler tagHandler)
|
||||
{
|
||||
_tagHandler = tagHandler;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public void Open(string tag)
|
||||
@@ -31,7 +27,7 @@ public class SelectPairForGroupUi
|
||||
_show = true;
|
||||
}
|
||||
|
||||
public void Draw(List<ClientPairDto> pairs, Dictionary<string, bool> showUidForEntry)
|
||||
public void Draw(List<Pair> pairs, Dictionary<string, bool> showUidForEntry)
|
||||
{
|
||||
var workHeight = ImGui.GetMainViewport().WorkSize.Y / ImGuiHelpers.GlobalScale;
|
||||
var minSize = new Vector2(300, workHeight < 400 ? workHeight : 400) * ImGuiHelpers.GlobalScale;
|
||||
@@ -57,21 +53,21 @@ public class SelectPairForGroupUi
|
||||
{
|
||||
UiShared.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont);
|
||||
ImGui.InputTextWithHint("##filter", "Filter", ref _filter, 255, ImGuiInputTextFlags.None);
|
||||
foreach (var item in pairs.OrderBy(p => PairName(showUidForEntry, p.OtherUID, p.VanityUID), System.StringComparer.OrdinalIgnoreCase)
|
||||
.Where(p => string.IsNullOrEmpty(_filter) || PairName(showUidForEntry, p.OtherUID, p.VanityUID).Contains(_filter, System.StringComparison.OrdinalIgnoreCase)).ToList())
|
||||
foreach (var item in pairs.OrderBy(p => PairName(showUidForEntry, p), StringComparer.OrdinalIgnoreCase)
|
||||
.Where(p => string.IsNullOrEmpty(_filter) || PairName(showUidForEntry, p).Contains(_filter, StringComparison.OrdinalIgnoreCase)).ToList())
|
||||
{
|
||||
var isInGroup = _peopleInGroup.Contains(item.OtherUID);
|
||||
if (ImGui.Checkbox(PairName(showUidForEntry, item.OtherUID, item.VanityUID), ref isInGroup))
|
||||
var isInGroup = _peopleInGroup.Contains(item.UserData.UID);
|
||||
if (ImGui.Checkbox(PairName(showUidForEntry, item), ref isInGroup))
|
||||
{
|
||||
if (isInGroup)
|
||||
{
|
||||
_tagHandler.AddTagToPairedUid(item, _tag);
|
||||
_peopleInGroup.Add(item.OtherUID);
|
||||
_tagHandler.AddTagToPairedUid(item.UserPair!, _tag);
|
||||
_peopleInGroup.Add(item.UserData.UID);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tagHandler.RemoveTagFromPairedUid(item, _tag);
|
||||
_peopleInGroup.Remove(item.OtherUID);
|
||||
_tagHandler.RemoveTagFromPairedUid(item.UserPair!, _tag);
|
||||
_peopleInGroup.Remove(item.UserData.UID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,13 +80,13 @@ public class SelectPairForGroupUi
|
||||
}
|
||||
}
|
||||
|
||||
private string PairName(Dictionary<string, bool> showUidForEntry, string otherUid, string vanityUid)
|
||||
private string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
|
||||
{
|
||||
showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName);
|
||||
_configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText);
|
||||
showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName);
|
||||
var playerText = pair.GetNote();
|
||||
if (showUidInsteadOfName || string.IsNullOrEmpty(playerText))
|
||||
{
|
||||
playerText = string.IsNullOrEmpty(vanityUid) ? otherUid : vanityUid;
|
||||
playerText = pair.UserData.AliasOrUID;
|
||||
}
|
||||
return playerText;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user