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
240 lines
7.4 KiB
C#
240 lines
7.4 KiB
C#
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Game.Text.SeStringHandling;
|
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
|
using Dalamud.Interface;
|
|
using Dalamud.Interface.ImGuiSeStringRenderer;
|
|
using Dalamud.Interface.Utility;
|
|
using Lumina.Text;
|
|
using System;
|
|
using System.Numerics;
|
|
using DalamudSeString = Dalamud.Game.Text.SeStringHandling.SeString;
|
|
using DalamudSeStringBuilder = Dalamud.Game.Text.SeStringHandling.SeStringBuilder;
|
|
using LuminaSeStringBuilder = Lumina.Text.SeStringBuilder;
|
|
|
|
namespace LightlessSync.Utils;
|
|
|
|
public static class SeStringUtils
|
|
{
|
|
public static DalamudSeString BuildFormattedPlayerName(string text, Vector4? textColor, Vector4? glowColor)
|
|
{
|
|
var b = new DalamudSeStringBuilder();
|
|
|
|
if (glowColor is Vector4 glow)
|
|
b.Add(new GlowPayload(glow));
|
|
|
|
if (textColor is Vector4 color)
|
|
b.Add(new ColorPayload(color));
|
|
|
|
b.AddText(text ?? string.Empty);
|
|
|
|
if (textColor is not null)
|
|
b.Add(new ColorEndPayload());
|
|
|
|
if (glowColor is not null)
|
|
b.Add(new GlowEndPayload());
|
|
|
|
return b.Build();
|
|
}
|
|
|
|
public static DalamudSeString BuildPlain(string text)
|
|
{
|
|
var b = new DalamudSeStringBuilder();
|
|
b.AddText(text ?? string.Empty);
|
|
return b.Build();
|
|
}
|
|
|
|
public static DalamudSeString BuildRichText(ReadOnlySpan<RichTextEntry> fragments)
|
|
{
|
|
var builder = new LuminaSeStringBuilder();
|
|
|
|
foreach (var fragment in fragments)
|
|
{
|
|
if (string.IsNullOrEmpty(fragment.Text))
|
|
continue;
|
|
|
|
var hasColor = fragment.Color.HasValue;
|
|
Vector4 color = default;
|
|
if (hasColor)
|
|
{
|
|
color = fragment.Color!.Value;
|
|
builder.PushColorRgba(color);
|
|
}
|
|
|
|
if (fragment.Bold)
|
|
builder.AppendSetBold(true);
|
|
|
|
builder.Append(fragment.Text.AsSpan());
|
|
|
|
if (fragment.Bold)
|
|
builder.AppendSetBold(false);
|
|
|
|
if (hasColor)
|
|
builder.PopColor();
|
|
}
|
|
|
|
return DalamudSeString.Parse(builder.ToArray());
|
|
}
|
|
|
|
public static DalamudSeString BuildRichText(params RichTextEntry[] fragments) => BuildRichText(fragments.AsSpan());
|
|
public static void RenderSeString(DalamudSeString seString, Vector2 position, ImFontPtr? font = null, ImDrawListPtr? drawList = null)
|
|
{
|
|
drawList ??= ImGui.GetWindowDrawList();
|
|
|
|
var drawParams = new SeStringDrawParams
|
|
{
|
|
Font = font ?? UiBuilder.MonoFont,
|
|
Color = 0xFFFFFFFF,
|
|
WrapWidth = float.MaxValue,
|
|
TargetDrawList = drawList
|
|
};
|
|
|
|
ImGui.SetCursorScreenPos(position);
|
|
ImGuiHelpers.SeStringWrapped(seString.Encode(), drawParams);
|
|
|
|
var textSize = ImGui.CalcTextSize(seString.TextValue);
|
|
if (textSize.Y <= 0f)
|
|
textSize.Y = ImGui.GetTextLineHeight();
|
|
|
|
ImGui.Dummy(new Vector2(0f, textSize.Y));
|
|
}
|
|
|
|
public static void RenderSeStringWrapped(DalamudSeString seString, float wrapWidth, ImFontPtr? font = null, ImDrawListPtr? drawList = null)
|
|
{
|
|
drawList ??= ImGui.GetWindowDrawList();
|
|
|
|
var drawParams = new SeStringDrawParams
|
|
{
|
|
Font = font ?? ImGui.GetFont(),
|
|
Color = ImGui.GetColorU32(ImGuiCol.Text),
|
|
WrapWidth = wrapWidth,
|
|
TargetDrawList = drawList
|
|
};
|
|
|
|
ImGuiHelpers.SeStringWrapped(seString.Encode(), drawParams);
|
|
|
|
var calcWrapWidth = wrapWidth > 0f ? wrapWidth : -1f;
|
|
var textSize = ImGui.CalcTextSize(seString.TextValue, wrapWidth: calcWrapWidth);
|
|
if (textSize.Y <= 0f)
|
|
textSize.Y = ImGui.GetTextLineHeight();
|
|
|
|
ImGui.Dummy(new Vector2(0f, textSize.Y));
|
|
}
|
|
public static Vector2 RenderSeStringWithHitbox(DalamudSeString seString, Vector2 position, ImFontPtr? font = null)
|
|
{
|
|
var drawList = ImGui.GetWindowDrawList();
|
|
|
|
var drawParams = new SeStringDrawParams
|
|
{
|
|
Font = font ?? UiBuilder.MonoFont,
|
|
Color = 0xFFFFFFFF,
|
|
WrapWidth = float.MaxValue,
|
|
TargetDrawList = drawList
|
|
};
|
|
|
|
ImGui.SetCursorScreenPos(position);
|
|
ImGuiHelpers.SeStringWrapped(seString.Encode(), drawParams);
|
|
|
|
var textSize = ImGui.CalcTextSize(seString.TextValue);
|
|
|
|
ImGui.SetCursorScreenPos(position);
|
|
ImGui.InvisibleButton($"##hitbox_{Guid.NewGuid()}", textSize);
|
|
|
|
return textSize;
|
|
}
|
|
|
|
public static Vector2 RenderIconWithHitbox(int iconId, Vector2 position, ImFontPtr? font = null)
|
|
{
|
|
var drawList = ImGui.GetWindowDrawList();
|
|
|
|
var drawParams = new SeStringDrawParams
|
|
{
|
|
Font = font ?? UiBuilder.MonoFont,
|
|
Color = 0xFFFFFFFF,
|
|
WrapWidth = float.MaxValue,
|
|
TargetDrawList = drawList
|
|
};
|
|
|
|
var iconMacro = $"<icon({iconId})>";
|
|
var drawResult = ImGuiHelpers.CompileSeStringWrapped(iconMacro, drawParams);
|
|
|
|
ImGui.SetCursorScreenPos(position);
|
|
ImGui.InvisibleButton($"##iconHitbox_{Guid.NewGuid()}", drawResult.Size);
|
|
|
|
return drawResult.Size;
|
|
}
|
|
|
|
#region Internal Payloads
|
|
|
|
public readonly record struct RichTextEntry(string Text, Vector4? Color = null, bool Bold = false);
|
|
|
|
private abstract class AbstractColorPayload : Payload
|
|
{
|
|
protected byte Red { get; init; }
|
|
protected byte Green { get; init; }
|
|
protected byte Blue { get; init; }
|
|
|
|
protected override byte[] EncodeImpl()
|
|
{
|
|
return new byte[] { 0x02, ChunkType, 0x05, 0xF6, Red, Green, Blue, 0x03 };
|
|
}
|
|
|
|
protected override void DecodeImpl(BinaryReader reader, long endOfStream) { }
|
|
|
|
public override PayloadType Type => PayloadType.Unknown;
|
|
protected abstract byte ChunkType { get; }
|
|
}
|
|
|
|
private abstract class AbstractColorEndPayload : Payload
|
|
{
|
|
protected override byte[] EncodeImpl()
|
|
{
|
|
return new byte[] { 0x02, ChunkType, 0x02, 0xEC, 0x03 };
|
|
}
|
|
|
|
protected override void DecodeImpl(BinaryReader reader, long endOfStream) { }
|
|
|
|
public override PayloadType Type => PayloadType.Unknown;
|
|
protected abstract byte ChunkType { get; }
|
|
}
|
|
|
|
private class ColorPayload : AbstractColorPayload
|
|
{
|
|
protected override byte ChunkType => 0x13;
|
|
|
|
public ColorPayload(Vector3 color)
|
|
{
|
|
Red = Math.Max((byte)1, (byte)(color.X * 255f));
|
|
Green = Math.Max((byte)1, (byte)(color.Y * 255f));
|
|
Blue = Math.Max((byte)1, (byte)(color.Z * 255f));
|
|
}
|
|
|
|
public ColorPayload(Vector4 color) : this(new Vector3(color.X, color.Y, color.Z)) { }
|
|
}
|
|
|
|
private class ColorEndPayload : AbstractColorEndPayload
|
|
{
|
|
protected override byte ChunkType => 0x13;
|
|
}
|
|
|
|
private class GlowPayload : AbstractColorPayload
|
|
{
|
|
protected override byte ChunkType => 0x14;
|
|
|
|
public GlowPayload(Vector3 color)
|
|
{
|
|
Red = Math.Max((byte)1, (byte)(color.X * 255f));
|
|
Green = Math.Max((byte)1, (byte)(color.Y * 255f));
|
|
Blue = Math.Max((byte)1, (byte)(color.Z * 255f));
|
|
}
|
|
|
|
public GlowPayload(Vector4 color) : this(new Vector3(color.X, color.Y, color.Z)) { }
|
|
}
|
|
|
|
private class GlowEndPayload : AbstractColorEndPayload
|
|
{
|
|
protected override byte ChunkType => 0x14;
|
|
}
|
|
|
|
#endregion
|
|
}
|