Merge branch 'refs/heads/2.0.0' into notif-style-rework
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Brio.API;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using LightlessSync.API.Dto.CharaData;
|
||||
using LightlessSync.Interop.Ipc.Framework;
|
||||
using LightlessSync.Services;
|
||||
@@ -13,21 +13,23 @@ namespace LightlessSync.Interop.Ipc;
|
||||
|
||||
public sealed class IpcCallerBrio : IpcServiceBase
|
||||
{
|
||||
private static readonly IpcServiceDescriptor BrioDescriptor = new("Brio", "Brio", new Version(0, 0, 0, 0));
|
||||
private static readonly IpcServiceDescriptor BrioDescriptor = new("Brio", "Brio", new Version(3, 0, 0, 0));
|
||||
|
||||
private readonly ILogger<IpcCallerBrio> _logger;
|
||||
private readonly DalamudUtilService _dalamudUtilService;
|
||||
private readonly ICallGateSubscriber<(int, int)> _brioApiVersion;
|
||||
|
||||
private readonly ICallGateSubscriber<bool, bool, bool, Task<IGameObject>> _brioSpawnActorAsync;
|
||||
private readonly ICallGateSubscriber<IGameObject, bool> _brioDespawnActor;
|
||||
private readonly ICallGateSubscriber<IGameObject, Vector3?, Quaternion?, Vector3?, bool, bool> _brioSetModelTransform;
|
||||
private readonly ICallGateSubscriber<IGameObject, (Vector3?, Quaternion?, Vector3?)> _brioGetModelTransform;
|
||||
private readonly ICallGateSubscriber<IGameObject, string> _brioGetPoseAsJson;
|
||||
private readonly ICallGateSubscriber<IGameObject, string, bool, bool> _brioSetPoseFromJson;
|
||||
private readonly ICallGateSubscriber<IGameObject, bool> _brioFreezeActor;
|
||||
private readonly ICallGateSubscriber<bool> _brioFreezePhysics;
|
||||
private readonly ApiVersion _apiVersion;
|
||||
|
||||
private readonly SpawnActor _spawnActor;
|
||||
private readonly DespawnActor _despawnActor;
|
||||
private readonly SetModelTransform _setModelTransform;
|
||||
private readonly GetModelTransform _getModelTransform;
|
||||
|
||||
private readonly GetPoseAsJson _getPoseAsJson;
|
||||
private readonly LoadPoseFromJson _setPoseFromJson;
|
||||
|
||||
private readonly FreezeActor _freezeActor;
|
||||
private readonly FreezePhysics _freezePhysics;
|
||||
|
||||
public IpcCallerBrio(ILogger<IpcCallerBrio> logger, IDalamudPluginInterface dalamudPluginInterface,
|
||||
DalamudUtilService dalamudUtilService, LightlessMediator mediator) : base(logger, mediator, dalamudPluginInterface, BrioDescriptor)
|
||||
@@ -35,15 +37,18 @@ public sealed class IpcCallerBrio : IpcServiceBase
|
||||
_logger = logger;
|
||||
_dalamudUtilService = dalamudUtilService;
|
||||
|
||||
_brioApiVersion = dalamudPluginInterface.GetIpcSubscriber<(int, int)>("Brio.ApiVersion");
|
||||
_brioSpawnActorAsync = dalamudPluginInterface.GetIpcSubscriber<bool, bool, bool, Task<IGameObject>>("Brio.Actor.SpawnExAsync");
|
||||
_brioDespawnActor = dalamudPluginInterface.GetIpcSubscriber<IGameObject, bool>("Brio.Actor.Despawn");
|
||||
_brioSetModelTransform = dalamudPluginInterface.GetIpcSubscriber<IGameObject, Vector3?, Quaternion?, Vector3?, bool, bool>("Brio.Actor.SetModelTransform");
|
||||
_brioGetModelTransform = dalamudPluginInterface.GetIpcSubscriber<IGameObject, (Vector3?, Quaternion?, Vector3?)>("Brio.Actor.GetModelTransform");
|
||||
_brioGetPoseAsJson = dalamudPluginInterface.GetIpcSubscriber<IGameObject, string>("Brio.Actor.Pose.GetPoseAsJson");
|
||||
_brioSetPoseFromJson = dalamudPluginInterface.GetIpcSubscriber<IGameObject, string, bool, bool>("Brio.Actor.Pose.LoadFromJson");
|
||||
_brioFreezeActor = dalamudPluginInterface.GetIpcSubscriber<IGameObject, bool>("Brio.Actor.Freeze");
|
||||
_brioFreezePhysics = dalamudPluginInterface.GetIpcSubscriber<bool>("Brio.FreezePhysics");
|
||||
_apiVersion = new ApiVersion(dalamudPluginInterface);
|
||||
_spawnActor = new SpawnActor(dalamudPluginInterface);
|
||||
_despawnActor = new DespawnActor(dalamudPluginInterface);
|
||||
|
||||
_setModelTransform = new SetModelTransform(dalamudPluginInterface);
|
||||
_getModelTransform = new GetModelTransform(dalamudPluginInterface);
|
||||
|
||||
_getPoseAsJson = new GetPoseAsJson(dalamudPluginInterface);
|
||||
_setPoseFromJson = new LoadPoseFromJson(dalamudPluginInterface);
|
||||
|
||||
_freezeActor = new FreezeActor(dalamudPluginInterface);
|
||||
_freezePhysics = new FreezePhysics(dalamudPluginInterface);
|
||||
|
||||
CheckAPI();
|
||||
}
|
||||
@@ -52,7 +57,7 @@ public sealed class IpcCallerBrio : IpcServiceBase
|
||||
{
|
||||
if (!APIAvailable) return null;
|
||||
_logger.LogDebug("Spawning Brio Actor");
|
||||
return await _brioSpawnActorAsync.InvokeFunc(false, false, true).ConfigureAwait(false);
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _spawnActor.Invoke(Brio.API.Enums.SpawnFlags.Default, true)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> DespawnActorAsync(nint address)
|
||||
@@ -61,7 +66,7 @@ public sealed class IpcCallerBrio : IpcServiceBase
|
||||
var gameObject = await _dalamudUtilService.CreateGameObjectAsync(address).ConfigureAwait(false);
|
||||
if (gameObject == null) return false;
|
||||
_logger.LogDebug("Despawning Brio Actor {actor}", gameObject.Name.TextValue);
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _brioDespawnActor.InvokeFunc(gameObject)).ConfigureAwait(false);
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _despawnActor.Invoke(gameObject)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> ApplyTransformAsync(nint address, WorldData data)
|
||||
@@ -71,7 +76,7 @@ public sealed class IpcCallerBrio : IpcServiceBase
|
||||
if (gameObject == null) return false;
|
||||
_logger.LogDebug("Applying Transform to Actor {actor}", gameObject.Name.TextValue);
|
||||
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _brioSetModelTransform.InvokeFunc(gameObject,
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _setModelTransform.Invoke(gameObject,
|
||||
new Vector3(data.PositionX, data.PositionY, data.PositionZ),
|
||||
new Quaternion(data.RotationX, data.RotationY, data.RotationZ, data.RotationW),
|
||||
new Vector3(data.ScaleX, data.ScaleY, data.ScaleZ), false)).ConfigureAwait(false);
|
||||
@@ -82,8 +87,7 @@ public sealed class IpcCallerBrio : IpcServiceBase
|
||||
if (!APIAvailable) return default;
|
||||
var gameObject = await _dalamudUtilService.CreateGameObjectAsync(address).ConfigureAwait(false);
|
||||
if (gameObject == null) return default;
|
||||
var data = await _dalamudUtilService.RunOnFrameworkThread(() => _brioGetModelTransform.InvokeFunc(gameObject)).ConfigureAwait(false);
|
||||
//_logger.LogDebug("Getting Transform from Actor {actor}", gameObject.Name.TextValue);
|
||||
var data = await _dalamudUtilService.RunOnFrameworkThread(() => _getModelTransform.Invoke(gameObject)).ConfigureAwait(false);
|
||||
|
||||
return new WorldData()
|
||||
{
|
||||
@@ -107,7 +111,7 @@ public sealed class IpcCallerBrio : IpcServiceBase
|
||||
if (gameObject == null) return null;
|
||||
_logger.LogDebug("Getting Pose from Actor {actor}", gameObject.Name.TextValue);
|
||||
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _brioGetPoseAsJson.InvokeFunc(gameObject)).ConfigureAwait(false);
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _getPoseAsJson.Invoke(gameObject)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> SetPoseAsync(nint address, string pose)
|
||||
@@ -118,15 +122,15 @@ public sealed class IpcCallerBrio : IpcServiceBase
|
||||
_logger.LogDebug("Setting Pose to Actor {actor}", gameObject.Name.TextValue);
|
||||
|
||||
var applicablePose = JsonNode.Parse(pose)!;
|
||||
var currentPose = await _dalamudUtilService.RunOnFrameworkThread(() => _brioGetPoseAsJson.InvokeFunc(gameObject)).ConfigureAwait(false);
|
||||
var currentPose = await _dalamudUtilService.RunOnFrameworkThread(() => _getPoseAsJson.Invoke(gameObject)).ConfigureAwait(false);
|
||||
applicablePose["ModelDifference"] = JsonNode.Parse(JsonNode.Parse(currentPose)!["ModelDifference"]!.ToJsonString());
|
||||
|
||||
await _dalamudUtilService.RunOnFrameworkThread(() =>
|
||||
{
|
||||
_brioFreezeActor.InvokeFunc(gameObject);
|
||||
_brioFreezePhysics.InvokeFunc();
|
||||
_freezeActor.Invoke(gameObject);
|
||||
_freezePhysics.Invoke();
|
||||
}).ConfigureAwait(false);
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _brioSetPoseFromJson.InvokeFunc(gameObject, applicablePose.ToJsonString(), false)).ConfigureAwait(false);
|
||||
return await _dalamudUtilService.RunOnFrameworkThread(() => _setPoseFromJson.Invoke(gameObject, applicablePose.ToJsonString(), false)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected override IpcConnectionState EvaluateState()
|
||||
@@ -139,8 +143,8 @@ public sealed class IpcCallerBrio : IpcServiceBase
|
||||
|
||||
try
|
||||
{
|
||||
var version = _brioApiVersion.InvokeFunc();
|
||||
return version.Item1 == 2 && version.Item2 >= 0
|
||||
var version = _apiVersion.Invoke();
|
||||
return version.Item1 == 3 && version.Item2 >= 0
|
||||
? IpcConnectionState.Available
|
||||
: IpcConnectionState.VersionMismatch;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Dalamud.NET.Sdk/13.1.0">
|
||||
<Project Sdk="Dalamud.NET.Sdk/14.0.0">
|
||||
<PropertyGroup>
|
||||
<Authors></Authors>
|
||||
<Company></Company>
|
||||
@@ -10,7 +10,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0-windows7.0</TargetFramework>
|
||||
<TargetFramework>net10.0-windows7.0</TargetFramework>
|
||||
<Platforms>x64</Platforms>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
@@ -28,16 +28,17 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blake3" Version="2.0.0" />
|
||||
<PackageReference Include="Brio.API" Version="3.0.0" />
|
||||
<PackageReference Include="Downloader" Version="4.0.3" />
|
||||
<PackageReference Include="K4os.Compression.LZ4.Legacy" Version="1.3.8" />
|
||||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.212">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
|
||||
<PackageReference Include="Glamourer.Api" Version="2.6.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
|
||||
<PackageReference Include="Glamourer.Api" Version="2.8.0" />
|
||||
<PackageReference Include="NReco.Logging.File" Version="1.2.2" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.11" />
|
||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.7.0.110445">
|
||||
@@ -95,5 +96,9 @@
|
||||
<TargetPath>DirectXTexC.dll</TargetPath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="DalamudPackager" Version="14.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -5,6 +5,7 @@ using LightlessSync.Services.Mediator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Runtime.CompilerServices;
|
||||
using static FFXIVClientStructs.FFXIV.Client.Game.Character.DrawDataContainer;
|
||||
using VisibilityFlags = FFXIVClientStructs.FFXIV.Client.Game.Object.VisibilityFlags;
|
||||
using ObjectKind = LightlessSync.API.Data.Enum.ObjectKind;
|
||||
|
||||
namespace LightlessSync.PlayerData.Handlers;
|
||||
@@ -376,8 +377,8 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
{
|
||||
if (Address == IntPtr.Zero) return DrawCondition.ObjectZero;
|
||||
if (DrawObjectAddress == IntPtr.Zero) return DrawCondition.DrawObjectZero;
|
||||
var renderFlags = (((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)Address)->RenderFlags) != 0x0;
|
||||
if (renderFlags) return DrawCondition.RenderFlags;
|
||||
var visibilityFlags = ((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)Address)->RenderFlags;
|
||||
if (visibilityFlags != VisibilityFlags.None) return DrawCondition.RenderFlags;
|
||||
|
||||
if (ObjectKind == ObjectKind.Player)
|
||||
{
|
||||
|
||||
@@ -783,7 +783,7 @@ public sealed class ActorObjectService : IHostedService, IDisposable
|
||||
if (drawObject == null)
|
||||
return false;
|
||||
|
||||
if (gameObject->RenderFlags == 2048)
|
||||
if ((gameObject->RenderFlags & VisibilityFlags.Nameplate) != VisibilityFlags.None)
|
||||
return false;
|
||||
|
||||
var characterBase = (CharacterBase*)drawObject;
|
||||
|
||||
@@ -3,10 +3,21 @@ using LightlessSync.API.Dto.Chat;
|
||||
namespace LightlessSync.Services.Chat;
|
||||
|
||||
public sealed record ChatMessageEntry(
|
||||
ChatMessageDto Payload,
|
||||
ChatMessageDto? Payload,
|
||||
string DisplayName,
|
||||
bool FromSelf,
|
||||
DateTime ReceivedAtUtc);
|
||||
DateTime ReceivedAtUtc,
|
||||
ChatSystemEntry? SystemMessage = null)
|
||||
{
|
||||
public bool IsSystem => SystemMessage is not null;
|
||||
}
|
||||
|
||||
public enum ChatSystemEntryType
|
||||
{
|
||||
ZoneSeparator
|
||||
}
|
||||
|
||||
public sealed record ChatSystemEntry(ChatSystemEntryType Type, string? ZoneName);
|
||||
|
||||
public readonly record struct ChatChannelSnapshot(
|
||||
string Key,
|
||||
|
||||
@@ -240,8 +240,22 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
||||
}
|
||||
}
|
||||
|
||||
public Task<ChatParticipantResolveResultDto?> ResolveParticipantAsync(ChatChannelDescriptor descriptor, string token)
|
||||
=> _apiController.ResolveChatParticipant(new ChatParticipantResolveRequestDto(descriptor, token));
|
||||
public async Task<bool> SetParticipantMuteAsync(ChatChannelDescriptor descriptor, string token, bool mute)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(token))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
await _apiController.SetChatParticipantMute(new ChatParticipantMuteRequestDto(descriptor, token, mute)).ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Failed to update chat participant mute state");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<ChatReportResult> ReportMessageAsync(ChatChannelDescriptor descriptor, string messageId, string reason, string? additionalContext)
|
||||
{
|
||||
@@ -534,6 +548,7 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
||||
}
|
||||
|
||||
bool shouldForceSend;
|
||||
ChatMessageEntry? zoneSeparatorEntry = null;
|
||||
|
||||
using (_sync.EnterScope())
|
||||
{
|
||||
@@ -544,11 +559,24 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
||||
state.IsAvailable = _chatEnabled;
|
||||
state.StatusText = _chatEnabled ? null : "Chat services disabled";
|
||||
|
||||
var previousDescriptor = _lastZoneDescriptor;
|
||||
var zoneChanged = previousDescriptor.HasValue && !ChannelDescriptorsMatch(previousDescriptor.Value, descriptor.Value);
|
||||
|
||||
_activeChannelKey = ZoneChannelKey;
|
||||
shouldForceSend = force || !_lastZoneDescriptor.HasValue || !ChannelDescriptorsMatch(_lastZoneDescriptor.Value, descriptor.Value);
|
||||
shouldForceSend = force || !previousDescriptor.HasValue || zoneChanged;
|
||||
if (zoneChanged && state.Messages.Any(m => !m.IsSystem))
|
||||
{
|
||||
zoneSeparatorEntry = AddZoneSeparatorLocked(state, definition.Value.DisplayName);
|
||||
}
|
||||
|
||||
_lastZoneDescriptor = descriptor;
|
||||
}
|
||||
|
||||
if (zoneSeparatorEntry is not null)
|
||||
{
|
||||
Mediator.Publish(new ChatChannelMessageAdded(ZoneChannelKey, zoneSeparatorEntry));
|
||||
}
|
||||
|
||||
PublishChannelListChanged();
|
||||
await SendPresenceAsync(descriptor.Value, territoryId, isActive: true, force: shouldForceSend).ConfigureAwait(false);
|
||||
}
|
||||
@@ -561,7 +589,6 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
||||
private async Task LeaveCurrentZoneAsync(bool force, ushort territoryId)
|
||||
{
|
||||
ChatChannelDescriptor? descriptor = null;
|
||||
bool clearedHistory = false;
|
||||
|
||||
using (_sync.EnterScope())
|
||||
{
|
||||
@@ -570,15 +597,6 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
||||
|
||||
if (_channels.TryGetValue(ZoneChannelKey, out var state))
|
||||
{
|
||||
if (state.Messages.Count > 0)
|
||||
{
|
||||
state.Messages.Clear();
|
||||
state.HasUnread = false;
|
||||
state.UnreadCount = 0;
|
||||
_lastReadCounts[ZoneChannelKey] = 0;
|
||||
clearedHistory = true;
|
||||
}
|
||||
|
||||
state.IsConnected = _isConnected;
|
||||
state.IsAvailable = false;
|
||||
state.StatusText = !_chatEnabled
|
||||
@@ -593,11 +611,6 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
||||
}
|
||||
}
|
||||
|
||||
if (clearedHistory)
|
||||
{
|
||||
PublishHistoryCleared(ZoneChannelKey);
|
||||
}
|
||||
|
||||
PublishChannelListChanged();
|
||||
|
||||
if (descriptor.HasValue)
|
||||
@@ -1007,6 +1020,39 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
||||
return new ChatMessageEntry(dto, displayName, fromSelf, DateTime.UtcNow);
|
||||
}
|
||||
|
||||
private ChatMessageEntry AddZoneSeparatorLocked(ChatChannelState state, string zoneDisplayName)
|
||||
{
|
||||
var separator = new ChatMessageEntry(
|
||||
null,
|
||||
string.Empty,
|
||||
false,
|
||||
DateTime.UtcNow,
|
||||
new ChatSystemEntry(ChatSystemEntryType.ZoneSeparator, zoneDisplayName));
|
||||
|
||||
state.Messages.Add(separator);
|
||||
if (state.Messages.Count > MaxMessageHistory)
|
||||
{
|
||||
state.Messages.RemoveAt(0);
|
||||
}
|
||||
|
||||
if (string.Equals(_activeChannelKey, ZoneChannelKey, StringComparison.Ordinal))
|
||||
{
|
||||
state.HasUnread = false;
|
||||
state.UnreadCount = 0;
|
||||
_lastReadCounts[ZoneChannelKey] = state.Messages.Count;
|
||||
}
|
||||
else if (_lastReadCounts.TryGetValue(ZoneChannelKey, out var readCount))
|
||||
{
|
||||
_lastReadCounts[ZoneChannelKey] = readCount + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastReadCounts[ZoneChannelKey] = state.Messages.Count;
|
||||
}
|
||||
|
||||
return separator;
|
||||
}
|
||||
|
||||
private string ResolveDisplayName(ChatMessageDto dto, bool fromSelf)
|
||||
{
|
||||
var isZone = dto.Channel.Type == ChatChannelType.Zone;
|
||||
@@ -1070,8 +1116,6 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
||||
|
||||
private void PublishChannelListChanged() => Mediator.Publish(new ChatChannelsUpdated());
|
||||
|
||||
private void PublishHistoryCleared(string channelKey) => Mediator.Publish(new ChatChannelHistoryCleared(channelKey));
|
||||
|
||||
private static IEnumerable<string> EnumerateTerritoryKeys(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
|
||||
@@ -26,6 +26,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using DalamudObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
|
||||
using GameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject;
|
||||
using VisibilityFlags = FFXIVClientStructs.FFXIV.Client.Game.Object.VisibilityFlags;
|
||||
|
||||
namespace LightlessSync.Services;
|
||||
|
||||
@@ -707,7 +708,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
const int tick = 250;
|
||||
int curWaitTime = 0;
|
||||
_logger.LogTrace("RenderFlags: {flags}", obj->RenderFlags.ToString("X"));
|
||||
while (obj->RenderFlags != 0x00 && curWaitTime < timeOut)
|
||||
while (obj->RenderFlags != VisibilityFlags.None && curWaitTime < timeOut)
|
||||
{
|
||||
_logger.LogTrace($"Waiting for gpose actor to finish drawing");
|
||||
curWaitTime += tick;
|
||||
@@ -752,7 +753,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
bool isDrawingChanged = false;
|
||||
if ((nint)drawObj != IntPtr.Zero)
|
||||
{
|
||||
isDrawing = gameObj->RenderFlags == 0b100000000000;
|
||||
isDrawing = (gameObj->RenderFlags & VisibilityFlags.Nameplate) != VisibilityFlags.None;
|
||||
if (!isDrawing)
|
||||
{
|
||||
isDrawing = ((CharacterBase*)drawObj)->HasModelInSlotLoaded != 0;
|
||||
@@ -1047,4 +1048,4 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
onExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ public record PairDownloadStatusMessage(List<(string PlayerName, float Progress,
|
||||
public record VisibilityChange : MessageBase;
|
||||
public record ChatChannelsUpdated : MessageBase;
|
||||
public record ChatChannelMessageAdded(string ChannelKey, ChatMessageEntry Message) : MessageBase;
|
||||
public record ChatChannelHistoryCleared(string ChannelKey) : MessageBase;
|
||||
public record GroupCollectionChangedMessage : MessageBase;
|
||||
public record OpenUserProfileMessage(UserData User) : MessageBase;
|
||||
#pragma warning restore S2094
|
||||
|
||||
@@ -327,7 +327,12 @@ public class LightlessProfileManager : MediatorSubscriberBase
|
||||
if (profile == null)
|
||||
return null;
|
||||
|
||||
var userData = profile.User;
|
||||
if (profile.User is null)
|
||||
{
|
||||
Logger.LogWarning("Lightfinder profile response missing user info for CID {HashedCid}", hashedCid);
|
||||
}
|
||||
|
||||
var userData = profile.User ?? new UserData(hashedCid, Alias: "Lightfinder User");
|
||||
var profileTags = profile.Tags ?? _emptyTagSet;
|
||||
var profileData = BuildProfileData(userData, profile, profileTags);
|
||||
_lightlessProfiles[userData] = profileData;
|
||||
|
||||
@@ -146,12 +146,19 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
|
||||
if (string.IsNullOrEmpty(hashedCid))
|
||||
return LightfinderDisplayName;
|
||||
|
||||
var (name, address) = dalamudUtilService.FindPlayerByNameHash(hashedCid);
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return LightfinderDisplayName;
|
||||
try
|
||||
{
|
||||
var (name, address) = dalamudUtilService.FindPlayerByNameHash(hashedCid);
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return LightfinderDisplayName;
|
||||
|
||||
var world = dalamudUtilService.GetWorldNameFromPlayerAddress(address);
|
||||
return string.IsNullOrEmpty(world) ? name : $"{name} ({world})";
|
||||
var world = dalamudUtilService.GetWorldNameFromPlayerAddress(address);
|
||||
return string.IsNullOrEmpty(world) ? name : $"{name} ({world})";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return LightfinderDisplayName;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DrawInternal()
|
||||
|
||||
@@ -95,13 +95,6 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
.Apply();
|
||||
|
||||
Mediator.Subscribe<ChatChannelMessageAdded>(this, OnChatChannelMessageAdded);
|
||||
Mediator.Subscribe<ChatChannelHistoryCleared>(this, msg =>
|
||||
{
|
||||
if (_selectedChannelKey is not null && string.Equals(_selectedChannelKey, msg.ChannelKey, StringComparison.Ordinal))
|
||||
{
|
||||
_scrollToBottom = true;
|
||||
}
|
||||
});
|
||||
Mediator.Subscribe<ChatChannelsUpdated>(this, _ => _scrollToBottom = true);
|
||||
}
|
||||
|
||||
@@ -250,6 +243,21 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
for (var i = 0; i < channel.Messages.Count; i++)
|
||||
{
|
||||
var message = channel.Messages[i];
|
||||
ImGui.PushID(i);
|
||||
|
||||
if (message.IsSystem)
|
||||
{
|
||||
DrawSystemEntry(message);
|
||||
ImGui.PopID();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (message.Payload is not { } payload)
|
||||
{
|
||||
ImGui.PopID();
|
||||
continue;
|
||||
}
|
||||
|
||||
var timestampText = string.Empty;
|
||||
if (showTimestamps)
|
||||
{
|
||||
@@ -257,24 +265,21 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
var color = message.FromSelf ? UIColors.Get("LightlessBlue") : ImGuiColors.DalamudWhite;
|
||||
|
||||
ImGui.PushID(i);
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, color);
|
||||
ImGui.TextWrapped($"{timestampText}{message.DisplayName}: {message.Payload.Message}");
|
||||
ImGui.TextWrapped($"{timestampText}{message.DisplayName}: {payload.Message}");
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
if (ImGui.BeginPopupContextItem($"chat_msg_ctx##{channel.Key}_{i}"))
|
||||
{
|
||||
var contextLocalTimestamp = message.Payload.SentAtUtc.ToLocalTime();
|
||||
var contextLocalTimestamp = payload.SentAtUtc.ToLocalTime();
|
||||
var contextTimestampText = contextLocalTimestamp.ToString("yyyy-MM-dd HH:mm:ss 'UTC'z", CultureInfo.InvariantCulture);
|
||||
ImGui.TextDisabled(contextTimestampText);
|
||||
ImGui.Separator();
|
||||
|
||||
var actionIndex = 0;
|
||||
foreach (var action in GetContextMenuActions(channel, message))
|
||||
{
|
||||
if (ImGui.MenuItem(action.Label, string.Empty, false, action.IsEnabled))
|
||||
{
|
||||
action.Execute();
|
||||
}
|
||||
DrawContextMenuAction(action, actionIndex++);
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
@@ -538,6 +543,13 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.Payload is not { } payload)
|
||||
{
|
||||
CloseReportPopup();
|
||||
ImGui.EndPopup();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_reportSubmissionResult is { } pendingResult)
|
||||
{
|
||||
_reportSubmissionResult = null;
|
||||
@@ -563,11 +575,11 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
|
||||
ImGui.TextUnformatted(channelLabel);
|
||||
ImGui.TextUnformatted($"Sender: {message.DisplayName}");
|
||||
ImGui.TextUnformatted($"Sent: {message.Payload.SentAtUtc.ToLocalTime().ToString("g", CultureInfo.CurrentCulture)}");
|
||||
ImGui.TextUnformatted($"Sent: {payload.SentAtUtc.ToLocalTime().ToString("g", CultureInfo.CurrentCulture)}");
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.PushTextWrapPos(ImGui.GetWindowContentRegionMax().X);
|
||||
ImGui.TextWrapped(message.Payload.Message);
|
||||
ImGui.TextWrapped(payload.Message);
|
||||
ImGui.PopTextWrapPos();
|
||||
ImGui.Separator();
|
||||
|
||||
@@ -633,9 +645,15 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
|
||||
private void OpenReportPopup(ChatChannelSnapshot channel, ChatMessageEntry message)
|
||||
{
|
||||
if (message.Payload is not { } payload)
|
||||
{
|
||||
_logger.LogDebug("Ignoring report popup request for non-message entry in {ChannelKey}", channel.Key);
|
||||
return;
|
||||
}
|
||||
|
||||
_reportTargetChannel = channel;
|
||||
_reportTargetMessage = message;
|
||||
_logger.LogDebug("Opening report popup for channel {ChannelKey}, message {MessageId}", channel.Key, message.Payload.MessageId);
|
||||
_logger.LogDebug("Opening report popup for channel {ChannelKey}, message {MessageId}", channel.Key, payload.MessageId);
|
||||
_reportReason = string.Empty;
|
||||
_reportAdditionalContext = string.Empty;
|
||||
_reportError = null;
|
||||
@@ -650,6 +668,12 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
if (_reportSubmitting)
|
||||
return;
|
||||
|
||||
if (message.Payload is not { } payload)
|
||||
{
|
||||
_reportError = "Unable to report this message.";
|
||||
return;
|
||||
}
|
||||
|
||||
var trimmedReason = _reportReason.Trim();
|
||||
if (trimmedReason.Length == 0)
|
||||
{
|
||||
@@ -666,7 +690,7 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
_reportSubmissionResult = null;
|
||||
|
||||
var descriptor = channel.Descriptor;
|
||||
var messageId = message.Payload.MessageId;
|
||||
var messageId = payload.MessageId;
|
||||
if (string.IsNullOrWhiteSpace(messageId))
|
||||
{
|
||||
_reportSubmitting = false;
|
||||
@@ -743,25 +767,33 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
|
||||
private IEnumerable<ChatMessageContextAction> GetContextMenuActions(ChatChannelSnapshot channel, ChatMessageEntry message)
|
||||
{
|
||||
if (TryCreateCopyMessageAction(message, out var copyAction))
|
||||
if (message.IsSystem || message.Payload is not { } payload)
|
||||
yield break;
|
||||
|
||||
if (TryCreateCopyMessageAction(message, payload, out var copyAction))
|
||||
{
|
||||
yield return copyAction;
|
||||
}
|
||||
|
||||
if (TryCreateViewProfileAction(channel, message, out var viewProfile))
|
||||
if (TryCreateViewProfileAction(channel, message, payload, out var viewProfile))
|
||||
{
|
||||
yield return viewProfile;
|
||||
}
|
||||
|
||||
if (TryCreateReportMessageAction(channel, message, out var reportAction))
|
||||
if (TryCreateMuteParticipantAction(channel, message, payload, out var muteAction))
|
||||
{
|
||||
yield return muteAction;
|
||||
}
|
||||
|
||||
if (TryCreateReportMessageAction(channel, message, payload, out var reportAction))
|
||||
{
|
||||
yield return reportAction;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryCreateCopyMessageAction(ChatMessageEntry message, out ChatMessageContextAction action)
|
||||
private static bool TryCreateCopyMessageAction(ChatMessageEntry message, ChatMessageDto payload, out ChatMessageContextAction action)
|
||||
{
|
||||
var text = message.Payload.Message;
|
||||
var text = payload.Message;
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
action = default;
|
||||
@@ -769,20 +801,21 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
|
||||
action = new ChatMessageContextAction(
|
||||
FontAwesomeIcon.Clipboard,
|
||||
"Copy Message",
|
||||
true,
|
||||
() => ImGui.SetClipboardText(text));
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryCreateViewProfileAction(ChatChannelSnapshot channel, ChatMessageEntry message, out ChatMessageContextAction action)
|
||||
private bool TryCreateViewProfileAction(ChatChannelSnapshot channel, ChatMessageEntry message, ChatMessageDto payload, out ChatMessageContextAction action)
|
||||
{
|
||||
action = default;
|
||||
switch (channel.Type)
|
||||
{
|
||||
case ChatChannelType.Group:
|
||||
{
|
||||
var user = message.Payload.Sender.User;
|
||||
var user = payload.Sender.User;
|
||||
if (user?.UID is not { Length: > 0 })
|
||||
return false;
|
||||
|
||||
@@ -790,6 +823,7 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
if (snapshot.PairsByUid.TryGetValue(user.UID, out var pair) && pair is not null)
|
||||
{
|
||||
action = new ChatMessageContextAction(
|
||||
FontAwesomeIcon.User,
|
||||
"View Profile",
|
||||
true,
|
||||
() => Mediator.Publish(new ProfileOpenStandaloneMessage(pair)));
|
||||
@@ -797,41 +831,64 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
|
||||
action = new ChatMessageContextAction(
|
||||
FontAwesomeIcon.User,
|
||||
"View Profile",
|
||||
true,
|
||||
() => RunContextAction(() => OpenStandardProfileAsync(user)));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
case ChatChannelType.Zone:
|
||||
if (!message.Payload.Sender.CanResolveProfile)
|
||||
if (!payload.Sender.CanResolveProfile)
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrEmpty(message.Payload.Sender.Token))
|
||||
var hashedCid = payload.Sender.HashedCid;
|
||||
if (string.IsNullOrEmpty(hashedCid))
|
||||
return false;
|
||||
|
||||
action = new ChatMessageContextAction(
|
||||
FontAwesomeIcon.User,
|
||||
"View Profile",
|
||||
true,
|
||||
() => RunContextAction(() => OpenZoneParticipantProfileAsync(channel.Descriptor, message.Payload.Sender.Token)));
|
||||
() => RunContextAction(() => OpenLightfinderProfileInternalAsync(hashedCid)));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryCreateReportMessageAction(ChatChannelSnapshot channel, ChatMessageEntry message, out ChatMessageContextAction action)
|
||||
private bool TryCreateMuteParticipantAction(ChatChannelSnapshot channel, ChatMessageEntry message, ChatMessageDto payload, out ChatMessageContextAction action)
|
||||
{
|
||||
action = default;
|
||||
if (message.FromSelf)
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(message.Payload.MessageId))
|
||||
if (string.IsNullOrEmpty(payload.Sender.Token))
|
||||
return false;
|
||||
|
||||
var safeName = string.IsNullOrWhiteSpace(message.DisplayName)
|
||||
? "Participant"
|
||||
: message.DisplayName;
|
||||
|
||||
action = new ChatMessageContextAction(
|
||||
FontAwesomeIcon.VolumeMute,
|
||||
$"Mute '{safeName}'",
|
||||
true,
|
||||
() => RunContextAction(() => _zoneChatService.SetParticipantMuteAsync(channel.Descriptor, payload.Sender.Token!, true)));
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryCreateReportMessageAction(ChatChannelSnapshot channel, ChatMessageEntry message, ChatMessageDto payload, out ChatMessageContextAction action)
|
||||
{
|
||||
action = default;
|
||||
if (message.FromSelf)
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(payload.MessageId))
|
||||
return false;
|
||||
|
||||
action = new ChatMessageContextAction(
|
||||
FontAwesomeIcon.ExclamationTriangle,
|
||||
"Report Message",
|
||||
true,
|
||||
() => OpenReportPopup(channel, message));
|
||||
@@ -863,24 +920,12 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
});
|
||||
}
|
||||
|
||||
private async Task OpenZoneParticipantProfileAsync(ChatChannelDescriptor descriptor, string token)
|
||||
private void OnChatChannelMessageAdded(ChatChannelMessageAdded message)
|
||||
{
|
||||
var result = await _zoneChatService.ResolveParticipantAsync(descriptor, token).ConfigureAwait(false);
|
||||
if (result is null)
|
||||
if (_selectedChannelKey is not null && string.Equals(_selectedChannelKey, message.ChannelKey, StringComparison.Ordinal))
|
||||
{
|
||||
Mediator.Publish(new NotificationMessage("Zone Chat", "Participant is no longer available.", NotificationType.Warning, TimeSpan.FromSeconds(3)));
|
||||
return;
|
||||
_scrollToBottom = true;
|
||||
}
|
||||
|
||||
var resolved = result.Value;
|
||||
var hashedCid = resolved.Sender.HashedCid;
|
||||
if (string.IsNullOrEmpty(hashedCid))
|
||||
{
|
||||
Mediator.Publish(new NotificationMessage("Zone Chat", "This participant remains anonymous.", NotificationType.Warning, TimeSpan.FromSeconds(3)));
|
||||
return;
|
||||
}
|
||||
|
||||
await OpenLightfinderProfileInternalAsync(hashedCid).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task OpenLightfinderProfileInternalAsync(string hashedCid)
|
||||
@@ -901,14 +946,6 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
Mediator.Publish(new OpenLightfinderProfileMessage(sanitizedUser, profile.Value.ProfileData, hashedCid));
|
||||
}
|
||||
|
||||
private void OnChatChannelMessageAdded(ChatChannelMessageAdded message)
|
||||
{
|
||||
if (_selectedChannelKey is not null && string.Equals(_selectedChannelKey, message.ChannelKey, StringComparison.Ordinal))
|
||||
{
|
||||
_scrollToBottom = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureSelectedChannel(IReadOnlyList<ChatChannelSnapshot> channels)
|
||||
{
|
||||
if (_selectedChannelKey is not null && channels.Any(channel => string.Equals(channel.Key, _selectedChannelKey, StringComparison.Ordinal)))
|
||||
@@ -1374,5 +1411,86 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - style.ItemSpacing.Y * 0.3f);
|
||||
}
|
||||
|
||||
private readonly record struct ChatMessageContextAction(string Label, bool IsEnabled, Action Execute);
|
||||
private void DrawSystemEntry(ChatMessageEntry entry)
|
||||
{
|
||||
var system = entry.SystemMessage;
|
||||
if (system is null)
|
||||
return;
|
||||
|
||||
switch (system.Type)
|
||||
{
|
||||
case ChatSystemEntryType.ZoneSeparator:
|
||||
DrawZoneSeparatorEntry(system, entry.ReceivedAtUtc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawZoneSeparatorEntry(ChatSystemEntry systemEntry, DateTime timestampUtc)
|
||||
{
|
||||
ImGui.Spacing();
|
||||
|
||||
var zoneName = string.IsNullOrWhiteSpace(systemEntry.ZoneName) ? "Zone" : systemEntry.ZoneName;
|
||||
var localTime = timestampUtc.ToLocalTime();
|
||||
var label = $"{localTime.ToString("HH:mm", CultureInfo.CurrentCulture)} - {zoneName}";
|
||||
var availableWidth = ImGui.GetContentRegionAvail().X;
|
||||
var textSize = ImGui.CalcTextSize(label);
|
||||
var cursor = ImGui.GetCursorPos();
|
||||
var textPosX = cursor.X + MathF.Max(0f, (availableWidth - textSize.X) * 0.5f);
|
||||
|
||||
ImGui.SetCursorPos(new Vector2(textPosX, cursor.Y));
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey2);
|
||||
ImGui.TextUnformatted(label);
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
var nextY = ImGui.GetCursorPosY() + ImGui.GetStyle().ItemSpacing.Y * 0.35f;
|
||||
ImGui.SetCursorPos(new Vector2(cursor.X, nextY));
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
}
|
||||
|
||||
private void DrawContextMenuAction(ChatMessageContextAction action, int index)
|
||||
{
|
||||
ImGui.PushID(index);
|
||||
using var disabled = ImRaii.Disabled(!action.IsEnabled);
|
||||
|
||||
var availableWidth = Math.Max(1f, ImGui.GetContentRegionAvail().X);
|
||||
var clicked = ImGui.Selectable("##chat_ctx_action", false, ImGuiSelectableFlags.None, new Vector2(availableWidth, 0f));
|
||||
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
var itemMin = ImGui.GetItemRectMin();
|
||||
var itemMax = ImGui.GetItemRectMax();
|
||||
var itemHeight = itemMax.Y - itemMin.Y;
|
||||
var style = ImGui.GetStyle();
|
||||
var textColor = ImGui.GetColorU32(action.IsEnabled ? ImGuiCol.Text : ImGuiCol.TextDisabled);
|
||||
|
||||
var textSize = ImGui.CalcTextSize(action.Label);
|
||||
var textPos = new Vector2(itemMin.X + style.FramePadding.X, itemMin.Y + (itemHeight - textSize.Y) * 0.5f);
|
||||
|
||||
if (action.Icon.HasValue)
|
||||
{
|
||||
var iconSize = _uiSharedService.GetIconSize(action.Icon.Value);
|
||||
var iconPos = new Vector2(
|
||||
itemMin.X + style.FramePadding.X,
|
||||
itemMin.Y + (itemHeight - iconSize.Y) * 0.5f);
|
||||
|
||||
using (_uiSharedService.IconFont.Push())
|
||||
{
|
||||
drawList.AddText(iconPos, textColor, action.Icon.Value.ToIconString());
|
||||
}
|
||||
|
||||
textPos.X = iconPos.X + iconSize.X + style.ItemSpacing.X;
|
||||
}
|
||||
|
||||
drawList.AddText(textPos, textColor, action.Label);
|
||||
|
||||
if (clicked && action.IsEnabled)
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
action.Execute();
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
private readonly record struct ChatMessageContextAction(FontAwesomeIcon? Icon, string Label, bool IsEnabled, Action Execute);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
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 Dalamud.Interface.Textures.TextureWraps;
|
||||
using Lumina.Text;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Lumina.Text.Parse;
|
||||
using Lumina.Text.ReadOnly;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using DalamudSeString = Dalamud.Game.Text.SeStringHandling.SeString;
|
||||
using DalamudSeStringBuilder = Dalamud.Game.Text.SeStringHandling.SeStringBuilder;
|
||||
using LuminaSeStringBuilder = Lumina.Text.SeStringBuilder;
|
||||
@@ -58,7 +52,7 @@ public static class SeStringUtils
|
||||
Color = ImGui.GetColorU32(ImGuiCol.Text),
|
||||
};
|
||||
|
||||
var renderId = ImGui.GetID($"SeStringMarkup##{normalizedPayload.GetHashCode()}");
|
||||
var renderId = ImGui.GetID($"SeStringMarkup##{normalizedPayload.GetHashCode(StringComparison.Ordinal)}");
|
||||
var drawResult = ImGuiHelpers.CompileSeStringWrapped(normalizedPayload, drawParams, renderId);
|
||||
var height = drawResult.Size.Y;
|
||||
if (height <= 0f)
|
||||
@@ -382,7 +376,7 @@ public static class SeStringUtils
|
||||
return false;
|
||||
|
||||
return Uri.TryCreate(value, UriKind.Absolute, out var uri)
|
||||
&& (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps);
|
||||
&& (string.Equals(uri.Scheme, Uri.UriSchemeHttp, StringComparison.Ordinal) || string.Equals(uri.Scheme, Uri.UriSchemeHttps, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
public static string StripMarkup(string value)
|
||||
@@ -545,12 +539,15 @@ public static class SeStringUtils
|
||||
{
|
||||
drawList ??= ImGui.GetWindowDrawList();
|
||||
|
||||
var usedFont = font ?? ImGui.GetFont();
|
||||
var drawParams = new SeStringDrawParams
|
||||
{
|
||||
Font = font ?? ImGui.GetFont(),
|
||||
Font = usedFont,
|
||||
FontSize = usedFont.FontSize,
|
||||
Color = ImGui.GetColorU32(ImGuiCol.Text),
|
||||
WrapWidth = wrapWidth,
|
||||
TargetDrawList = drawList
|
||||
TargetDrawList = drawList,
|
||||
ScreenOffset = ImGui.GetCursorScreenPos()
|
||||
};
|
||||
|
||||
ImGuiHelpers.SeStringWrapped(seString.Encode(), drawParams);
|
||||
@@ -588,6 +585,11 @@ public static class SeStringUtils
|
||||
|
||||
var drawPos = new Vector2(position.X, position.Y + verticalOffset);
|
||||
ImGui.SetCursorScreenPos(drawPos);
|
||||
|
||||
drawParams.ScreenOffset = drawPos;
|
||||
drawParams.Font = usedFont;
|
||||
drawParams.FontSize = usedFont.FontSize;
|
||||
|
||||
ImGuiHelpers.SeStringWrapped(seString.Encode(), drawParams);
|
||||
|
||||
ImGui.SetCursorScreenPos(position);
|
||||
@@ -621,6 +623,7 @@ public static class SeStringUtils
|
||||
var measureParams = new SeStringDrawParams
|
||||
{
|
||||
Font = usedFont,
|
||||
FontSize = usedFont.FontSize,
|
||||
Color = 0xFFFFFFFF,
|
||||
WrapWidth = float.MaxValue
|
||||
};
|
||||
@@ -642,6 +645,7 @@ public static class SeStringUtils
|
||||
var drawParams = new SeStringDrawParams
|
||||
{
|
||||
Font = usedFont,
|
||||
FontSize = usedFont.FontSize,
|
||||
Color = 0xFFFFFFFF,
|
||||
WrapWidth = float.MaxValue,
|
||||
TargetDrawList = drawList,
|
||||
|
||||
@@ -60,12 +60,11 @@ public partial class ApiController
|
||||
await _lightlessHub.InvokeAsync(nameof(ReportChatMessage), request).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ChatParticipantResolveResultDto?> ResolveChatParticipant(ChatParticipantResolveRequestDto request)
|
||||
public async Task SetChatParticipantMute(ChatParticipantMuteRequestDto request)
|
||||
{
|
||||
if (!IsConnected || _lightlessHub is null) return null;
|
||||
return await _lightlessHub.InvokeAsync<ChatParticipantResolveResultDto?>(nameof(ResolveChatParticipant), request).ConfigureAwait(false);
|
||||
if (!IsConnected || _lightlessHub is null) return;
|
||||
await _lightlessHub.InvokeAsync(nameof(SetChatParticipantMute), request).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task SetBroadcastStatus(bool enabled, GroupBroadcastRequestDto? groupDto = null)
|
||||
{
|
||||
CheckConnection();
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Utility;
|
||||
using LightlessSync.API.Data;
|
||||
using LightlessSync.API.Data.Extensions;
|
||||
using LightlessSync.API.Dto;
|
||||
using LightlessSync.API.Dto.Chat;
|
||||
using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.API.Dto.Chat;
|
||||
using LightlessSync.API.Dto.User;
|
||||
using LightlessSync.API.SignalR;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user