Some checks failed
Tag and Release Lightless / tag-and-release (push) Failing after 32s
 Lightless 1.12.0 is HERE! In this major update, we are introducing something we've been working on and testing for the last couple of weeks. In this update we are introducing a new (**OPTIONAL**) feature called **LightFinder**! We took inspiration from FFXIV's very own Party Finder and decided to implement something that allows users to not only look for fellow Lightless users, but also put up their Syncshell for others looking to join a sync community! When you enable LightFinder, you will be visible to other LightFinder users for **3 hours** or when you want to disabled it. When the 3 hours are up, you can either leave it disabled or enable it again for another 3 hours. The tag shown above will show above your nameplate, and you will be able to receive pair requests in your UI from other users with LightFinder enabled without having to input their uid!  Are you at a Venue? In Limsa? Partying in the streets of Uldah? If you're looking for fellow Lightless users you can now enable LightFinder and you will be shown to others who also have LightFinder enabled! Looking for a Syncshell to join? Enable LightFinder to see what SyncShells are available to join! Want to advertise your Syncshell? Choose the syncshell you want to put up in LightFinder and enable LightFinder. **IMPORTANT: We want to stress the fact that, if you just want to sync with just your friends and no one else, this does not take that away. No one will know you use Lightless unless you choose to tell them, or use this **OPTIONAL** feature. Your privacy is still maintained if you don't want to use the feature.** # Major Changes ## LightFinder - **OPTIONAL FEATURE** - **DOES NOT AFFECT YOU IF YOU DON'T WANT TO USE IT**  * New **OPTIONAL** syncing feature where one can enable something like a Party Finder so that other Lightless users in the area can see you are looking for people to sync with. Enable it by clicking the compass button and then the `Enable LightFinder` button.  * [L] Send Pair Request has been added to player context menus. You should still be able to send a request without Lightfinder on BUT you will need to know the other player is using Lightless and have them send a pair request back.  * When in LightFinder mode, for X mins you will be visible to all Lightless Users WHO ALSO HAVE LIGHTFINDER ON and will receive notifications of people wanting to pair with you. If you are the person using LightFinder, you understand the risks of pairing with someone you don't know. If you are the person sending a request to someone with LightFinder on, you also understand the risks of pairing with someone you don't know. **AGAIN, THIS IS OPTIONAL.** * When in LightFinder mode, you can also put up a Syncshell you own on the Syncshell Finder so that others can easily find it and join. This has to be done prior to enabling LightFinder.  * Syncshell Finder allows you to join Syncshells that are indexed by LightFinder  # Minor Changes * Vanity addition to our supporters: On top of vanity ids you can find a fun addition under Your User Settings -> Edit Lightless Profile -> Vanity Settings to change the colour of your name in the lightless ui. This will be shown to all users.  * Pairing nameplate colour override can also now override FC tag (new option_ * Bunch of UI fixes, updates, and changes * kdb is now a whitelisted filetype that can upload Co-authored-by: CakeAndBanana <admin@cakeandbanana.nl> Co-authored-by: azyges <aaaaaa@aaa.aaa> Co-authored-by: choco <thijmenhogenkamp@gmail.com> Co-authored-by: choco <choco@noreply.git.lightless-sync.org> Co-authored-by: defnotken <itsdefnotken@gmail.com> Reviewed-on: #39
373 lines
13 KiB
C#
373 lines
13 KiB
C#
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Interface;
|
|
using Dalamud.Interface.Utility;
|
|
using Dalamud.Interface.Utility.Raii;
|
|
using LightlessSync.API.Dto.Group;
|
|
using LightlessSync.LightlessConfiguration;
|
|
using LightlessSync.PlayerData.Pairs;
|
|
using LightlessSync.Services.Mediator;
|
|
using LightlessSync.Services.ServerConfiguration;
|
|
using LightlessSync.UI.Style;
|
|
using LightlessSync.Utils;
|
|
using System;
|
|
using System.Numerics;
|
|
|
|
namespace LightlessSync.UI.Handlers;
|
|
|
|
public class IdDisplayHandler
|
|
{
|
|
private readonly LightlessConfigService _lightlessConfigService;
|
|
private readonly LightlessMediator _mediator;
|
|
private readonly ServerConfigurationManager _serverManager;
|
|
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 Vector4 _currentBg = new(0.15f, 0.15f, 0.15f, 1f);
|
|
private float _highlightBoost;
|
|
|
|
public IdDisplayHandler(LightlessMediator mediator, ServerConfigurationManager serverManager, LightlessConfigService lightlessConfigService)
|
|
{
|
|
_mediator = mediator;
|
|
_serverManager = serverManager;
|
|
_lightlessConfigService = lightlessConfigService;
|
|
}
|
|
|
|
public void DrawGroupText(string id, GroupFullInfoDto group, float textPosX, Func<float> editBoxWidth)
|
|
{
|
|
ImGui.SameLine(textPosX);
|
|
(bool textIsUid, string playerText) = GetGroupText(group);
|
|
if (!string.Equals(_editEntry, group.GID, StringComparison.Ordinal))
|
|
{
|
|
ImGui.AlignTextToFramePadding();
|
|
|
|
using (ImRaii.PushFont(UiBuilder.MonoFont, textIsUid))
|
|
ImGui.TextUnformatted(playerText);
|
|
|
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
|
{
|
|
var prevState = textIsUid;
|
|
if (_showIdForEntry.TryGetValue(group.GID, out bool value))
|
|
{
|
|
prevState = value;
|
|
}
|
|
_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.AlignTextToFramePadding();
|
|
|
|
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, Func<float> editBoxWidth)
|
|
{
|
|
ImGui.SameLine(textPosX);
|
|
(bool textIsUid, string playerText) = GetPlayerText(pair);
|
|
|
|
if (!string.Equals(_editEntry, pair.UserData.UID, StringComparison.Ordinal))
|
|
{
|
|
ImGui.AlignTextToFramePadding();
|
|
|
|
var font = textIsUid ? UiBuilder.MonoFont : ImGui.GetFont();
|
|
|
|
Vector4? textColor = null;
|
|
Vector4? glowColor = null;
|
|
|
|
if (pair.UserData.HasVanity)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(pair.UserData.TextColorHex))
|
|
{
|
|
textColor = UIColors.HexToRgba(pair.UserData.TextColorHex);
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(pair.UserData.TextGlowColorHex))
|
|
{
|
|
glowColor = UIColors.HexToRgba(pair.UserData.TextGlowColorHex);
|
|
}
|
|
}
|
|
|
|
var useVanityColors = _lightlessConfigService.Current.useColoredUIDs && (textColor != null || glowColor != null);
|
|
var seString = useVanityColors
|
|
? SeStringUtils.BuildFormattedPlayerName(playerText, textColor, glowColor)
|
|
: SeStringUtils.BuildPlain(playerText);
|
|
|
|
var rowStart = ImGui.GetCursorScreenPos();
|
|
var drawList = ImGui.GetWindowDrawList();
|
|
bool useHighlight = false;
|
|
float highlightPadX = 0f;
|
|
float highlightPadY = 0f;
|
|
|
|
if (useVanityColors)
|
|
{
|
|
float boost = Luminance.ComputeHighlight(textColor, glowColor);
|
|
|
|
if (boost > 0f)
|
|
{
|
|
var style = ImGui.GetStyle();
|
|
useHighlight = true;
|
|
highlightPadX = MathF.Max(style.FramePadding.X * 0.6f, 2f * ImGuiHelpers.GlobalScale);
|
|
highlightPadY = MathF.Max(style.FramePadding.Y * 0.55f, 1.25f * ImGuiHelpers.GlobalScale);
|
|
drawList.ChannelsSplit(2);
|
|
drawList.ChannelsSetCurrent(1);
|
|
|
|
_highlightBoost = boost;
|
|
}
|
|
else
|
|
{
|
|
_highlightBoost = 0f;
|
|
}
|
|
}
|
|
|
|
Vector2 itemMin;
|
|
Vector2 itemMax;
|
|
Vector2 textSize;
|
|
using (ImRaii.PushFont(font, textIsUid))
|
|
{
|
|
SeStringUtils.RenderSeStringWithHitbox(seString, rowStart, font);
|
|
itemMin = ImGui.GetItemRectMin();
|
|
itemMax = ImGui.GetItemRectMax();
|
|
//textSize = itemMax - itemMin;
|
|
}
|
|
|
|
if (useHighlight)
|
|
{
|
|
var style = ImGui.GetStyle();
|
|
var frameHeight = ImGui.GetFrameHeight();
|
|
var rowTop = rowStart.Y - style.FramePadding.Y;
|
|
var rowBottom = rowTop + frameHeight;
|
|
|
|
var highlightMin = new Vector2(itemMin.X - highlightPadX, rowTop - highlightPadY);
|
|
var highlightMax = new Vector2(itemMax.X + highlightPadX, rowBottom + highlightPadY);
|
|
|
|
var windowPos = ImGui.GetWindowPos();
|
|
var contentMin = windowPos + ImGui.GetWindowContentRegionMin();
|
|
var contentMax = windowPos + ImGui.GetWindowContentRegionMax();
|
|
highlightMin.X = MathF.Max(highlightMin.X, contentMin.X);
|
|
highlightMax.X = MathF.Min(highlightMax.X, contentMax.X);
|
|
highlightMin.Y = MathF.Max(highlightMin.Y, contentMin.Y);
|
|
highlightMax.Y = MathF.Min(highlightMax.Y, contentMax.Y);
|
|
|
|
var highlightColor = new Vector4(
|
|
0.25f + _highlightBoost,
|
|
0.25f + _highlightBoost,
|
|
0.25f + _highlightBoost,
|
|
1f
|
|
);
|
|
|
|
highlightColor = Luminance.BackgroundContrast(textColor, glowColor, highlightColor, ref _currentBg);
|
|
|
|
float rounding = style.FrameRounding > 0f ? style.FrameRounding : 5f * ImGuiHelpers.GlobalScale;
|
|
drawList.ChannelsSetCurrent(0);
|
|
drawList.AddRectFilled(highlightMin, highlightMax, ImGui.GetColorU32(highlightColor), rounding);
|
|
|
|
var borderColor = style.Colors[(int)ImGuiCol.Border];
|
|
borderColor.W *= 0.25f;
|
|
drawList.AddRect(highlightMin, highlightMax, ImGui.GetColorU32(borderColor), rounding);
|
|
drawList.ChannelsMerge();
|
|
}
|
|
|
|
if (ImGui.IsItemHovered())
|
|
{
|
|
if (!string.Equals(_lastMouseOverUid, id))
|
|
{
|
|
_popupTime = DateTime.UtcNow.AddSeconds(_lightlessConfigService.Current.ProfileDelay);
|
|
}
|
|
|
|
_lastMouseOverUid = id;
|
|
|
|
if (_popupTime > DateTime.UtcNow || !_lightlessConfigService.Current.ProfilesShow)
|
|
{
|
|
ImGui.SetTooltip("Left click to switch between UID display and nick" + Environment.NewLine
|
|
+ "Right click to change nick for " + pair.UserData.AliasOrUID + Environment.NewLine
|
|
+ "Middle Mouse Button to open their profile in a separate window");
|
|
}
|
|
else if (_popupTime < DateTime.UtcNow && !_popupShown)
|
|
{
|
|
_popupShown = true;
|
|
_mediator.Publish(new ProfilePopoutToggle(pair));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (string.Equals(_lastMouseOverUid, id))
|
|
{
|
|
_mediator.Publish(new ProfilePopoutToggle(Pair: null));
|
|
_lastMouseOverUid = string.Empty;
|
|
_popupShown = false;
|
|
}
|
|
}
|
|
|
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
|
{
|
|
var prevState = textIsUid;
|
|
if (_showIdForEntry.ContainsKey(pair.UserData.UID))
|
|
{
|
|
prevState = _showIdForEntry[pair.UserData.UID];
|
|
}
|
|
_showIdForEntry[pair.UserData.UID] = !prevState;
|
|
}
|
|
|
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
|
{
|
|
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))
|
|
{
|
|
_mediator.Publish(new ProfileOpenStandaloneMessage(pair));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ImGui.AlignTextToFramePadding();
|
|
|
|
ImGui.SetNextItemWidth(editBoxWidth.Invoke());
|
|
if (ImGui.InputTextWithHint("##" + pair.UserData.UID, "Nick/Notes", ref _editComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
|
{
|
|
_serverManager.SetNoteForUid(pair.UserData.UID, _editComment);
|
|
_serverManager.SaveNotes();
|
|
_editEntry = string.Empty;
|
|
}
|
|
|
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
|
{
|
|
_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;
|
|
bool showUidInsteadOfName = ShowUidInsteadOfName(pair);
|
|
string? playerText = _serverManager.GetNoteForUid(pair.UserData.UID);
|
|
if (!showUidInsteadOfName && playerText != null)
|
|
{
|
|
if (string.IsNullOrEmpty(playerText))
|
|
{
|
|
playerText = pair.UserData.AliasOrUID;
|
|
}
|
|
else
|
|
{
|
|
textIsUid = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
playerText = pair.UserData.AliasOrUID;
|
|
}
|
|
|
|
if (_lightlessConfigService.Current.ShowCharacterNameInsteadOfNotesForVisible && pair.IsVisible && !showUidInsteadOfName)
|
|
{
|
|
playerText = pair.PlayerName;
|
|
textIsUid = false;
|
|
if (_lightlessConfigService.Current.PreferNotesOverNamesForVisible)
|
|
{
|
|
var note = pair.GetNote();
|
|
if (note != null)
|
|
{
|
|
playerText = note;
|
|
}
|
|
}
|
|
}
|
|
|
|
return (textIsUid, playerText!);
|
|
}
|
|
|
|
internal void Clear()
|
|
{
|
|
_editEntry = string.Empty;
|
|
_editComment = string.Empty;
|
|
}
|
|
|
|
internal void OpenProfile(Pair entry)
|
|
{
|
|
_mediator.Publish(new ProfileOpenStandaloneMessage(entry));
|
|
}
|
|
|
|
private bool ShowGidInsteadOfName(GroupFullInfoDto group)
|
|
{
|
|
_showIdForEntry.TryGetValue(group.GID, out var showidInsteadOfName);
|
|
|
|
return showidInsteadOfName;
|
|
}
|
|
|
|
private bool ShowUidInsteadOfName(Pair pair)
|
|
{
|
|
_showIdForEntry.TryGetValue(pair.UserData.UID, out var showidInsteadOfName);
|
|
|
|
return showidInsteadOfName;
|
|
}
|
|
} |