Compare commits
14 Commits
merge-abel
...
i18n
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1fafd459b | ||
|
|
a88677ff66 | ||
|
|
9b9010ab8e | ||
|
|
032201ed9e | ||
|
|
775b128cf3 | ||
|
|
4bb8db8c03 | ||
|
|
f307c65c66 | ||
|
|
4eec363cd2 | ||
|
|
d00df84ed6 | ||
|
|
9048b3bd87 | ||
|
|
a2ed9f8d2b | ||
| 8e08da7471 | |||
|
|
b87837dadc | ||
|
|
f89ea9d879 |
Submodule LightlessAPI updated: 4ecd5375e6...c3caa7e25c
@@ -11,6 +11,7 @@ public sealed class ChatConfig : ILightlessConfiguration
|
||||
public bool ShowRulesOverlayOnOpen { get; set; } = true;
|
||||
public bool ShowMessageTimestamps { get; set; } = true;
|
||||
public bool ShowNotesInSyncshellChat { get; set; } = true;
|
||||
public bool EnableAnimatedEmotes { get; set; } = true;
|
||||
public float ChatWindowOpacity { get; set; } = .97f;
|
||||
public bool FadeWhenUnfocused { get; set; } = false;
|
||||
public float UnfocusedWindowOpacity { get; set; } = 0.6f;
|
||||
|
||||
@@ -24,6 +24,15 @@
|
||||
<Compile Remove="PlayerData\Export\**" />
|
||||
<EmbeddedResource Remove="PlayerData\Export\**" />
|
||||
<None Remove="PlayerData\Export\**" />
|
||||
<EmbeddedResource Update="Resources\Resources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<Compile Update="Resources\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -68,8 +77,6 @@
|
||||
</None>
|
||||
<EmbeddedResource Include="Changelog\changelog.yaml" />
|
||||
<EmbeddedResource Include="Changelog\credits.yaml" />
|
||||
<EmbeddedResource Include="Localization\de.json" />
|
||||
<EmbeddedResource Include="Localization\fr.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
3
LightlessSync/LightlessSync.csproj.DotSettings
Normal file
3
LightlessSync/LightlessSync.csproj.DotSettings
Normal file
@@ -0,0 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeEditing/Localization/Localizable/@EntryValue">Yes</s:String>
|
||||
<s:String x:Key="/Default/CodeEditing/Localization/LocalizableInspector/@EntryValue">Pessimistic</s:String></wpf:ResourceDictionary>
|
||||
@@ -1,44 +0,0 @@
|
||||
using CheapLoc;
|
||||
|
||||
namespace LightlessSync.Localization;
|
||||
|
||||
public static class Strings
|
||||
{
|
||||
public static ToSStrings ToS { get; set; } = new();
|
||||
|
||||
public class ToSStrings
|
||||
{
|
||||
public readonly string AgreeLabel = Loc.Localize("AgreeLabel", "I agree");
|
||||
public readonly string AgreementLabel = Loc.Localize("AgreementLabel", "Agreement of Usage of Service");
|
||||
public readonly string ButtonWillBeAvailableIn = Loc.Localize("ButtonWillBeAvailableIn", "'I agree' button will be available in");
|
||||
public readonly string LanguageLabel = Loc.Localize("LanguageLabel", "Language");
|
||||
|
||||
public readonly string Paragraph1 = Loc.Localize("Paragraph1",
|
||||
"All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. " +
|
||||
"The plugin will exclusively upload the necessary mod files and not the whole mod.");
|
||||
|
||||
public readonly string Paragraph2 = Loc.Localize("Paragraph2",
|
||||
"If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. " +
|
||||
"Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. " +
|
||||
"Files present on the service that already represent your active mod files will not be uploaded again.");
|
||||
|
||||
public readonly string Paragraph3 = Loc.Localize("Paragraph3",
|
||||
"The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. " +
|
||||
"Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. " +
|
||||
"Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.");
|
||||
|
||||
public readonly string Paragraph4 = Loc.Localize("Paragraph4",
|
||||
"The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.");
|
||||
|
||||
public readonly string Paragraph5 = Loc.Localize("Paragraph5",
|
||||
"Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. " +
|
||||
"After a period of not being used, the mod files will be automatically deleted. " +
|
||||
"You will also be able to wipe all the files you have personally uploaded on request. " +
|
||||
"The service holds no information about which mod files belong to which mod.");
|
||||
|
||||
public readonly string Paragraph6 = Loc.Localize("Paragraph6",
|
||||
"This service is provided as-is. In case of abuse join the Lightless Sync Discord.");
|
||||
|
||||
public readonly string ReadLabel = Loc.Localize("ReadLabel", "READ THIS CAREFULLY");
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"LanguageLabel": {
|
||||
"message": "Language",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"AgreementLabel": {
|
||||
"message": "Nutzungsbedingungen",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"ReadLabel": {
|
||||
"message": "BITTE LIES DIES SORGFÄLTIG",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph1": {
|
||||
"message": "Alle Moddateien, die aktuell auf deinem Charakter aktiv sind und dein Charakterzustand werden automatisch zu dem Service, an dem du dich registriert hast, hochgeladen. Das Plugin wird ausschließlich die nötigen Moddateien hochladen und nicht die gesamte Modifikation.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph2": {
|
||||
"message": "Falls du mit einer getakteten Internetverbindung verbunden bist, können durch den Datentransfer von Hoch- und Runtergeladenen Moddateien höhere Kosten entstehen. Moddateien werden beim Hoch- und Runterladen komprimiert um Bandbreite zu sparen. Durch unterschiedliche Hoch- und Runterladgeschwindigkeiten ist es möglich, dass Änderungen an Charakteren nicht sofort sichtbar sind. Dateien die bereits auf dem Service existieren, werden nicht nochmals hochgeladen.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph3": {
|
||||
"message": "Die Moddateien die du hochlädst sind vertraulich und werden nicht mit anderen Nutzern geteilt, die nicht die exakt selben Dateien anfordern. Bitte überlege dir sorgfältig mit wem du deinen Identifikationscode teilst, da es unvermeidlich ist, dass die andere Person deine Moddateien erhält und lokal zwischenspeichert. Lokal zwischengespeicherte Dateien haben willkürrliche Namen um vor Versuchen abzuschrecken die originalen Moddateien aus diesen wiederherzustellen.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph4": {
|
||||
"message": "Der Ersteller des Plugins hat sein Bestes getan, um deine Sicherheit zu gewährleisten. Es gibt jedoch keine Garantie für 100%ige Sicherheit. Teile deinen Identifikationscode nicht blind mit jedem.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph5": {
|
||||
"message": "Moddateien, die auf dem Service gespeichert sind, verbleiben auf dem Service, solange es Anforderungen für diese Dateien gibt. Nach einer Zeitspanne in der die Dateien nicht verwendet wurden, werden diese automatisch gelöscht. Du hast auch die Möglichkeit manuell alle Dateien auf dem Service zu löschen. Der Service hat keine Informationen welche Moddateien zu welcher Modifikation gehören.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph6": {
|
||||
"message": "Dieser Dienst wird ohne Gewähr angeboten. Im Falle eines Missbrauchs tretet dem Lightless Sync Discord bei.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"AgreeLabel": {
|
||||
"message": "Ich Stimme zu",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"ButtonWillBeAvailableIn": {
|
||||
"message": "\"Ich stimme zu\" Knopf verfügbar in",
|
||||
"description": "ToSStrings..ctor"
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"LanguageLabel": {
|
||||
"message": "Language",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"AgreementLabel": {
|
||||
"message": "Conditions d'Utilisation",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"ReadLabel": {
|
||||
"message": "LISEZ CES INFORMATIONS ATTENTIVEMENT",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph1": {
|
||||
"message": "Tous les fichiers moddés actuellement en cours d'utilisation ainsi que le statut actuel de votre personnage vont être mix en ligne via le service sur lequel vous vous êtes automatiquement enregistré. Seuls les fichiers nécessaires seront téléversés par le plugin et non pas le mod en entier.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph2": {
|
||||
"message": "Si le débit de votre connexion internet est limité, le téléchargement et téléversement d'un grand nombre de fichiers peut entraîner des coûts supplémentaires. Les fichiers seront compressés au chargement et versement pour réduire l'impact sur votre bande passants. Selon la rapidité de vos téléchargements et téléversements, les changements ne seront peut-être pas visibles instantanément sur les personnages. Les fichiers déja présents sur le service qui correspondent à ceux de vos mods en cours d'utilisation ne seront pas remis en ligne.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph3": {
|
||||
"message": "Les fichiers que vous allez partager sont confidentiels et ne seront envoyés qu'aux utilisateurs qui feront une requête exacte de ceux-çi. Nous vous demandons de (re)considérer qui sera synchronisé avec vous, puisqu'ils recevront et stockeront inévitablement en local les fichiers nécéssaires utilisés à cet instant. Les noms des fichiers stockés localement sont changés de manière arbitraire afin de décourager toute tentative de réplication des originaux.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph4": {
|
||||
"message": "Le créateur de ce plugin a tenté de sécuriser l'application du mieux possible. Cependant, il ne peut pas garantir une protection 100% infaillible. Pour votre sécurité, ne vous synchronisez pas aveuglément et avec n'importe qui.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph5": {
|
||||
"message": "Les fichiers sauvegardés sur le service resteront en ligne tant que des utilisateurs en feront usage. Ils seront effacés automatiquement après une certaine période d'inactivité. Vous pouvez également demander l'effacement de tous les fichiers que vous avez mis en ligne vous-même. Le service en soi ne contient aucune information pouvant identifier quel fichier appartient à quel mod.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"Paragraph6": {
|
||||
"message": "Ce service et ses composants vous sont fournis en l'état. En cas d'abus rejoindre le serveur Discord Lightless Sync.",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"AgreeLabel": {
|
||||
"message": "J'accept",
|
||||
"description": "ToSStrings..ctor"
|
||||
},
|
||||
"ButtonWillBeAvailableIn": {
|
||||
"message": "Bouton \"J'accept\" disposible dans",
|
||||
"description": "ToSStrings..ctor"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||
using Dalamud.Utility;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||
using LightlessSync.API.Data.Enum;
|
||||
using LightlessSync.FileCache;
|
||||
using LightlessSync.Interop.Ipc;
|
||||
@@ -11,6 +12,8 @@ using LightlessSync.Services.Mediator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LightlessSync.PlayerData.Factories;
|
||||
|
||||
@@ -123,22 +126,38 @@ public class PlayerDataFactory
|
||||
{
|
||||
if (playerPointer == IntPtr.Zero)
|
||||
return true;
|
||||
|
||||
if (!IsPointerValid(playerPointer))
|
||||
return true;
|
||||
|
||||
var character = (Character*)playerPointer;
|
||||
if (character == null)
|
||||
return true;
|
||||
|
||||
var gameObject = &character->GameObject;
|
||||
if (gameObject == null)
|
||||
return true;
|
||||
|
||||
if (!IsPointerValid((IntPtr)gameObject))
|
||||
return true;
|
||||
|
||||
return gameObject->DrawObject == null;
|
||||
}
|
||||
|
||||
private static bool IsPointerValid(IntPtr ptr)
|
||||
{
|
||||
if (ptr == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var character = (Character*)playerPointer;
|
||||
if (character == null)
|
||||
return true;
|
||||
|
||||
var gameObject = &character->GameObject;
|
||||
if (gameObject == null)
|
||||
return true;
|
||||
|
||||
return gameObject->DrawObject == null;
|
||||
}
|
||||
catch (AccessViolationException)
|
||||
{
|
||||
_ = Marshal.ReadByte(ptr);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsCacheFresh(CacheEntry entry)
|
||||
@@ -537,13 +556,31 @@ public class PlayerDataFactory
|
||||
|
||||
var hash = g.Key;
|
||||
|
||||
var resolvedPath = g.Select(f => f.ResolvedPath).Distinct(StringComparer.OrdinalIgnoreCase);
|
||||
var papPathSummary = string.Join(", ", resolvedPath);
|
||||
if (papPathSummary.IsNullOrEmpty())
|
||||
papPathSummary = "<unknown pap path>";
|
||||
|
||||
Dictionary<string, List<ushort>>? papIndices = null;
|
||||
|
||||
await _papParseLimiter.WaitAsync(ct).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
papIndices = await Task.Run(() => _modelAnalyzer.GetBoneIndicesFromPap(hash), ct)
|
||||
.ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
papIndices = await Task.Run(() => _modelAnalyzer.GetBoneIndicesFromPap(hash, persistToConfig: false), ct)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (SEHException ex)
|
||||
{
|
||||
_logger.LogError(ex, "SEH exception while parsing PAP file (hash={hash}, path={path}). Error code: 0x{code:X}. Skipping this animation.", hash, papPathSummary, ex.ErrorCode);
|
||||
continue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Unexpected error parsing PAP file (hash={hash}, path={path}). Skipping this animation.", hash, papPathSummary);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -553,43 +590,75 @@ public class PlayerDataFactory
|
||||
if (papIndices == null || papIndices.Count == 0)
|
||||
continue;
|
||||
|
||||
if (papIndices.All(k => k.Value.DefaultIfEmpty().Max() <= 105))
|
||||
bool hasValidIndices = false;
|
||||
try
|
||||
{
|
||||
hasValidIndices = papIndices.All(k => k.Value != null && k.Value.DefaultIfEmpty().Max() <= 105);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error validating bone indices for PAP (hash={hash}, path={path}). Skipping.", hash, papPathSummary);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasValidIndices)
|
||||
continue;
|
||||
|
||||
if (_logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
var papBuckets = papIndices
|
||||
.Select(kvp => new
|
||||
{
|
||||
Raw = kvp.Key,
|
||||
Key = XivDataAnalyzer.CanonicalizeSkeletonKey(kvp.Key),
|
||||
Indices = kvp.Value
|
||||
})
|
||||
.Where(x => x.Indices is { Count: > 0 })
|
||||
.GroupBy(x => string.IsNullOrEmpty(x.Key) ? x.Raw : x.Key!, StringComparer.OrdinalIgnoreCase)
|
||||
.Select(grp =>
|
||||
{
|
||||
var all = grp.SelectMany(v => v.Indices).ToList();
|
||||
var min = all.Count > 0 ? all.Min() : 0;
|
||||
var max = all.Count > 0 ? all.Max() : 0;
|
||||
var raws = string.Join(',', grp.Select(v => v.Raw).Distinct(StringComparer.OrdinalIgnoreCase));
|
||||
return $"{grp.Key}(min={min},max={max},raw=[{raws}])";
|
||||
})
|
||||
.ToList();
|
||||
try
|
||||
{
|
||||
var papBuckets = papIndices
|
||||
.Where(kvp => kvp.Value is { Count: > 0 })
|
||||
.Select(kvp => new
|
||||
{
|
||||
Raw = kvp.Key,
|
||||
Key = XivDataAnalyzer.CanonicalizeSkeletonKey(kvp.Key),
|
||||
Indices = kvp.Value
|
||||
})
|
||||
.Where(x => x.Indices is { Count: > 0 })
|
||||
.GroupBy(x => string.IsNullOrEmpty(x.Key) ? x.Raw : x.Key!, StringComparer.OrdinalIgnoreCase)
|
||||
.Select(grp =>
|
||||
{
|
||||
var all = grp.SelectMany(v => v.Indices).ToList();
|
||||
var min = all.Count > 0 ? all.Min() : 0;
|
||||
var max = all.Count > 0 ? all.Max() : 0;
|
||||
var raws = string.Join(',', grp.Select(v => v.Raw).Distinct(StringComparer.OrdinalIgnoreCase));
|
||||
return $"{grp.Key}(min={min},max={max},raw=[{raws}])";
|
||||
})
|
||||
.ToList();
|
||||
|
||||
_logger.LogDebug("SEND pap buckets for hash={hash}: {b}",
|
||||
hash,
|
||||
string.Join(" | ", papBuckets));
|
||||
_logger.LogDebug("SEND pap buckets for hash={hash}: {b}",
|
||||
hash,
|
||||
string.Join(" | ", papBuckets));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "Error logging PAP bucket details for hash={hash}", hash);
|
||||
}
|
||||
}
|
||||
|
||||
if (XivDataAnalyzer.IsPapCompatible(localBoneSets, papIndices, mode, allowBasedShift, allownNightIndex, out var reason))
|
||||
bool isCompatible = false;
|
||||
string reason = string.Empty;
|
||||
try
|
||||
{
|
||||
isCompatible = XivDataAnalyzer.IsPapCompatible(localBoneSets, papIndices, mode, allowBasedShift, allownNightIndex, out reason);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error checking PAP compatibility for hash={hash}, path={path}. Treating as incompatible.", hash, papPathSummary);
|
||||
reason = $"Exception during compatibility check: {ex.Message}";
|
||||
isCompatible = false;
|
||||
}
|
||||
|
||||
if (isCompatible)
|
||||
continue;
|
||||
|
||||
noValidationFailed++;
|
||||
|
||||
_logger.LogWarning(
|
||||
"Animation PAP hash {hash} is not compatible with local skeletons; dropping all mappings for this hash. Reason: {reason}",
|
||||
hash,
|
||||
"Animation PAP is not compatible with local skeletons; dropping mappings for {papPath}. Reason: {reason}",
|
||||
papPathSummary,
|
||||
reason);
|
||||
|
||||
var removedGamePaths = fragment.FileReplacements
|
||||
@@ -669,7 +738,7 @@ public class PlayerDataFactory
|
||||
list.Add(forwardPaths[i].ToLowerInvariant());
|
||||
else
|
||||
{
|
||||
resolvedPaths[filePath] = [forwardPaths[i].ToLowerInvariant()];
|
||||
resolvedPaths[filePath] = [forwardPathsLower[i]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
if (msg.Address == Address)
|
||||
{
|
||||
_haltProcessing = false;
|
||||
Refresh();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -114,16 +113,16 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
public async Task ActOnFrameworkAfterEnsureNoDrawAsync(Action<Dalamud.Game.ClientState.Objects.Types.ICharacter> act, CancellationToken token)
|
||||
{
|
||||
while (await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||
{
|
||||
EnsureLatestObjectState();
|
||||
if (CurrentDrawCondition != DrawCondition.None) return true;
|
||||
var gameObj = _dalamudUtil.CreateGameObject(Address);
|
||||
if (gameObj is Dalamud.Game.ClientState.Objects.Types.ICharacter chara)
|
||||
{
|
||||
act.Invoke(chara);
|
||||
}
|
||||
return false;
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
EnsureLatestObjectState();
|
||||
if (CurrentDrawCondition != DrawCondition.None) return true;
|
||||
var gameObj = _dalamudUtil.CreateGameObject(Address);
|
||||
if (gameObj is Dalamud.Game.ClientState.Objects.Types.ICharacter chara)
|
||||
{
|
||||
act.Invoke(chara);
|
||||
}
|
||||
return false;
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
await Task.Delay(250, token).ConfigureAwait(false);
|
||||
}
|
||||
@@ -170,19 +169,13 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
return $"{owned}/{ObjectKind}:{Name} ({Address:X},{DrawObjectAddress:X})";
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
Mediator.Publish(new GameObjectHandlerDestroyedMessage(this, _isOwnedObject));
|
||||
}
|
||||
|
||||
private void CheckAndUpdateObject() => CheckAndUpdateObject(allowPublish: true);
|
||||
|
||||
private unsafe void CheckAndUpdateObject(bool allowPublish = true)
|
||||
private unsafe void CheckAndUpdateObject(bool allowPublish)
|
||||
{
|
||||
var prevAddr = Address;
|
||||
var prevDrawObj = DrawObjectAddress;
|
||||
string? nameString = null;
|
||||
|
||||
Address = _getAddress();
|
||||
|
||||
@@ -193,10 +186,9 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
EntityId = gameObject->EntityId;
|
||||
|
||||
var chara = (Character*)Address;
|
||||
var newName = chara->GameObject.NameString;
|
||||
|
||||
if (!string.IsNullOrEmpty(newName) && !string.Equals(newName, Name, StringComparison.Ordinal))
|
||||
Name = newName;
|
||||
nameString = chara->GameObject.NameString;
|
||||
if (!string.IsNullOrEmpty(nameString) && !string.Equals(nameString, Name, StringComparison.Ordinal))
|
||||
Name = nameString;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -214,16 +206,18 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
if (Address != IntPtr.Zero && DrawObjectAddress != IntPtr.Zero)
|
||||
{
|
||||
var chara = (Character*)Address;
|
||||
var name = chara->GameObject.NameString;
|
||||
bool nameChange = !string.Equals(name, Name, StringComparison.Ordinal);
|
||||
if (nameChange)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
var drawObj = (DrawObject*)DrawObjectAddress;
|
||||
var objType = drawObj->Object.GetObjectType();
|
||||
var isHuman = objType == ObjectType.CharacterBase
|
||||
&& ((CharacterBase*)drawObj)->GetModelType() == CharacterBase.ModelType.Human;
|
||||
|
||||
nameString ??= ((Character*)Address)->GameObject.NameString;
|
||||
var nameChange = !string.Equals(nameString, Name, StringComparison.Ordinal);
|
||||
if (nameChange) Name = nameString;
|
||||
|
||||
bool equipDiff = false;
|
||||
|
||||
if (((DrawObject*)DrawObjectAddress)->Object.GetObjectType() == ObjectType.CharacterBase
|
||||
&& ((CharacterBase*)DrawObjectAddress)->GetModelType() == CharacterBase.ModelType.Human)
|
||||
if (isHuman)
|
||||
{
|
||||
var classJob = chara->CharacterData.ClassJob;
|
||||
if (classJob != _classJob)
|
||||
@@ -233,7 +227,7 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
Mediator.Publish(new ClassJobChangedMessage(this));
|
||||
}
|
||||
|
||||
equipDiff = CompareAndUpdateEquipByteData((byte*)&((Human*)DrawObjectAddress)->Head);
|
||||
equipDiff = CompareAndUpdateEquipByteData((byte*)&((Human*)drawObj)->Head);
|
||||
|
||||
ref var mh = ref chara->DrawData.Weapon(WeaponSlot.MainHand);
|
||||
ref var oh = ref chara->DrawData.Weapon(WeaponSlot.OffHand);
|
||||
@@ -258,12 +252,11 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
|
||||
bool customizeDiff = false;
|
||||
|
||||
if (((DrawObject*)DrawObjectAddress)->Object.GetObjectType() == ObjectType.CharacterBase
|
||||
&& ((CharacterBase*)DrawObjectAddress)->GetModelType() == CharacterBase.ModelType.Human)
|
||||
if (isHuman)
|
||||
{
|
||||
var gender = ((Human*)DrawObjectAddress)->Customize.Sex;
|
||||
var raceId = ((Human*)DrawObjectAddress)->Customize.Race;
|
||||
var tribeId = ((Human*)DrawObjectAddress)->Customize.Tribe;
|
||||
var gender = ((Human*)drawObj)->Customize.Sex;
|
||||
var raceId = ((Human*)drawObj)->Customize.Race;
|
||||
var tribeId = ((Human*)drawObj)->Customize.Tribe;
|
||||
|
||||
if (_isOwnedObject && ObjectKind == ObjectKind.Player
|
||||
&& (gender != Gender || raceId != RaceId || tribeId != TribeId))
|
||||
@@ -274,7 +267,7 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP
|
||||
TribeId = tribeId;
|
||||
}
|
||||
|
||||
customizeDiff = CompareAndUpdateCustomizeData(((Human*)DrawObjectAddress)->Customize.Data);
|
||||
customizeDiff = CompareAndUpdateCustomizeData(((Human*)drawObj)->Customize.Data);
|
||||
if (customizeDiff)
|
||||
Logger.LogTrace("Checking [{this}] customize data as human from draw obj, result: {diff}", this, customizeDiff);
|
||||
}
|
||||
|
||||
9
LightlessSync/Resources/LocalizationExtention.cs
Normal file
9
LightlessSync/Resources/LocalizationExtention.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace LightlessSync.Resources;
|
||||
|
||||
public static class LocalizationExtensions
|
||||
{
|
||||
public static string F(this string mask, params object[] args)
|
||||
{
|
||||
return string.Format(mask, args);
|
||||
}
|
||||
}
|
||||
170
LightlessSync/Resources/Resources.Designer.cs
generated
Normal file
170
LightlessSync/Resources/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,170 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace LightlessSync.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LightlessSync.Resources.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to I agree.
|
||||
/// </summary>
|
||||
public static string ToSStrings_AgreeLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_AgreeLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Agreement of Usage of Service.
|
||||
/// </summary>
|
||||
public static string ToSStrings_AgreementLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_AgreementLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 'I agree' button will be available in.
|
||||
/// </summary>
|
||||
public static string ToSStrings_ButtonWillBeAvailableIn {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_ButtonWillBeAvailableIn", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Language.
|
||||
/// </summary>
|
||||
public static string ToSStrings_LanguageLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_LanguageLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. The plugin will exclusively upload the necessary mod files and not the whole mod..
|
||||
/// </summary>
|
||||
public static string ToSStrings_Paragraph1 {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_Paragraph1", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. Files present on the service that already represent your active mod files will not be uploaded again..
|
||||
/// </summary>
|
||||
public static string ToSStrings_Paragraph2 {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_Paragraph2", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod..
|
||||
/// </summary>
|
||||
public static string ToSStrings_Paragraph3 {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_Paragraph3", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone..
|
||||
/// </summary>
|
||||
public static string ToSStrings_Paragraph4 {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_Paragraph4", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. After a period of not being used, the mod files will be automatically deleted. You will also be able to wipe all the files you have personally uploaded on request. The service holds no information about which mod files belong to which mod..
|
||||
/// </summary>
|
||||
public static string ToSStrings_Paragraph5 {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_Paragraph5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This service is provided as-is. In case of abuse join the Lightless Sync Discord..
|
||||
/// </summary>
|
||||
public static string ToSStrings_Paragraph6 {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_Paragraph6", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to READ THIS CAREFULLY.
|
||||
/// </summary>
|
||||
public static string ToSStrings_ReadLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("ToSStrings_ReadLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Users Online.
|
||||
/// </summary>
|
||||
public static string Users_Online {
|
||||
get {
|
||||
return ResourceManager.GetString("Users_Online", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
LightlessSync/Resources/Resources.de.resx
Normal file
47
LightlessSync/Resources/Resources.de.resx
Normal file
@@ -0,0 +1,47 @@
|
||||
<root>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ToSStrings_LanguageLabel" xml:space="preserve">
|
||||
<value>Language</value>
|
||||
</data>
|
||||
<data name="ToSStrings_AgreementLabel" xml:space="preserve">
|
||||
<value>Nutzungsbedingungen</value>
|
||||
</data>
|
||||
<data name="ToSStrings_ReadLabel" xml:space="preserve">
|
||||
<value>BITTE LIES DIES SORGFÄLTIG</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph1" xml:space="preserve">
|
||||
<value>Alle Moddateien, die aktuell auf deinem Charakter aktiv sind und dein Charakterzustand werden automatisch zu dem Service, an dem du dich registriert hast, hochgeladen. Das Plugin wird ausschließlich die nötigen Moddateien hochladen und nicht die gesamte Modifikation.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph2" xml:space="preserve">
|
||||
<value>Falls du mit einer getakteten Internetverbindung verbunden bist, können durch den Datentransfer von Hoch- und Runtergeladenen Moddateien höhere Kosten entstehen. Moddateien werden beim Hoch- und Runterladen komprimiert um Bandbreite zu sparen. Durch unterschiedliche Hoch- und Runterladgeschwindigkeiten ist es möglich, dass Änderungen an Charakteren nicht sofort sichtbar sind. Dateien die bereits auf dem Service existieren, werden nicht nochmals hochgeladen.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph3" xml:space="preserve">
|
||||
<value>Die Moddateien die du hochlädst sind vertraulich und werden nicht mit anderen Nutzern geteilt, die nicht die exakt selben Dateien anfordern. Bitte überlege dir sorgfältig mit wem du deinen Identifikationscode teilst, da es unvermeidlich ist, dass die andere Person deine Moddateien erhält und lokal zwischenspeichert. Lokal zwischengespeicherte Dateien haben willkürrliche Namen um vor Versuchen abzuschrecken die originalen Moddateien aus diesen wiederherzustellen.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph4" xml:space="preserve">
|
||||
<value>Der Ersteller des Plugins hat sein Bestes getan, um deine Sicherheit zu gewährleisten. Es gibt jedoch keine Garantie für 100%ige Sicherheit. Teile deinen Identifikationscode nicht blind mit jedem.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph5" xml:space="preserve">
|
||||
<value>Moddateien, die auf dem Service gespeichert sind, verbleiben auf dem Service, solange es Anforderungen für diese Dateien gibt. Nach einer Zeitspanne in der die Dateien nicht verwendet wurden, werden diese automatisch gelöscht. Du hast auch die Möglichkeit manuell alle Dateien auf dem Service zu löschen. Der Service hat keine Informationen welche Moddateien zu welcher Modifikation gehören.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph6" xml:space="preserve">
|
||||
<value>Dieser Dienst wird ohne Gewähr angeboten. Im Falle eines Missbrauchs tretet dem Lightless Sync Discord bei.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_AgreeLabel" xml:space="preserve">
|
||||
<value>Ich Stimme zu</value>
|
||||
</data>
|
||||
<data name="ToSStrings_ButtonWillBeAvailableIn" xml:space="preserve">
|
||||
<value>"Ich stimme zu" Knopf verfügbar in</value>
|
||||
</data>
|
||||
</root>
|
||||
47
LightlessSync/Resources/Resources.fr.resx
Normal file
47
LightlessSync/Resources/Resources.fr.resx
Normal file
@@ -0,0 +1,47 @@
|
||||
<root>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ToSStrings_LanguageLabel" xml:space="preserve">
|
||||
<value>Language</value>
|
||||
</data>
|
||||
<data name="ToSStrings_AgreementLabel" xml:space="preserve">
|
||||
<value>Conditions d'Utilisation</value>
|
||||
</data>
|
||||
<data name="ToSStrings_ReadLabel" xml:space="preserve">
|
||||
<value>LISEZ CES INFORMATIONS ATTENTIVEMENT</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph1" xml:space="preserve">
|
||||
<value>Tous les fichiers moddés actuellement en cours d'utilisation ainsi que le statut actuel de votre personnage vont être mix en ligne via le service sur lequel vous vous êtes automatiquement enregistré. Seuls les fichiers nécessaires seront téléversés par le plugin et non pas le mod en entier.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph2" xml:space="preserve">
|
||||
<value>Si le débit de votre connexion internet est limité, le téléchargement et téléversement d'un grand nombre de fichiers peut entraîner des coûts supplémentaires. Les fichiers seront compressés au chargement et versement pour réduire l'impact sur votre bande passants. Selon la rapidité de vos téléchargements et téléversements, les changements ne seront peut-être pas visibles instantanément sur les personnages. Les fichiers déja présents sur le service qui correspondent à ceux de vos mods en cours d'utilisation ne seront pas remis en ligne.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph3" xml:space="preserve">
|
||||
<value>Les fichiers que vous allez partager sont confidentiels et ne seront envoyés qu'aux utilisateurs qui feront une requête exacte de ceux-çi. Nous vous demandons de (re)considérer qui sera synchronisé avec vous, puisqu'ils recevront et stockeront inévitablement en local les fichiers nécéssaires utilisés à cet instant. Les noms des fichiers stockés localement sont changés de manière arbitraire afin de décourager toute tentative de réplication des originaux.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph4" xml:space="preserve">
|
||||
<value>Le créateur de ce plugin a tenté de sécuriser l'application du mieux possible. Cependant, il ne peut pas garantir une protection 100% infaillible. Pour votre sécurité, ne vous synchronisez pas aveuglément et avec n'importe qui.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph5" xml:space="preserve">
|
||||
<value>Les fichiers sauvegardés sur le service resteront en ligne tant que des utilisateurs en feront usage. Ils seront effacés automatiquement après une certaine période d'inactivité. Vous pouvez également demander l'effacement de tous les fichiers que vous avez mis en ligne vous-même. Le service en soi ne contient aucune information pouvant identifier quel fichier appartient à quel mod.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph6" xml:space="preserve">
|
||||
<value>Ce service et ses composants vous sont fournis en l'état. En cas d'abus rejoindre le serveur Discord Lightless Sync.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_AgreeLabel" xml:space="preserve">
|
||||
<value>J'accept</value>
|
||||
</data>
|
||||
<data name="ToSStrings_ButtonWillBeAvailableIn" xml:space="preserve">
|
||||
<value>Bouton "J'accept" disposible dans</value>
|
||||
</data>
|
||||
</root>
|
||||
57
LightlessSync/Resources/Resources.resx
Normal file
57
LightlessSync/Resources/Resources.resx
Normal file
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ToSStrings_AgreeLabel" xml:space="preserve">
|
||||
<value>I agree</value>
|
||||
</data>
|
||||
<data name="ToSStrings_AgreementLabel" xml:space="preserve">
|
||||
<value>Agreement of Usage of Service</value>
|
||||
</data>
|
||||
<data name="ToSStrings_ButtonWillBeAvailableIn" xml:space="preserve">
|
||||
<value>'I agree' button will be available in</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph1" xml:space="preserve">
|
||||
<value>All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. The plugin will exclusively upload the necessary mod files and not the whole mod.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph2" xml:space="preserve">
|
||||
<value>If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. Files present on the service that already represent your active mod files will not be uploaded again.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph3" xml:space="preserve">
|
||||
<value>The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph4" xml:space="preserve">
|
||||
<value>The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph5" xml:space="preserve">
|
||||
<value>Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. After a period of not being used, the mod files will be automatically deleted. You will also be able to wipe all the files you have personally uploaded on request. The service holds no information about which mod files belong to which mod.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_Paragraph6" xml:space="preserve">
|
||||
<value>This service is provided as-is. In case of abuse join the Lightless Sync Discord.</value>
|
||||
</data>
|
||||
<data name="ToSStrings_ReadLabel" xml:space="preserve">
|
||||
<value>READ THIS CAREFULLY</value>
|
||||
</data>
|
||||
<data name="ToSStrings_LanguageLabel" xml:space="preserve">
|
||||
<value>Language</value>
|
||||
</data>
|
||||
<data name="Users_Online" xml:space="preserve">
|
||||
<value>Users Online</value>
|
||||
</data>
|
||||
</root>
|
||||
20
LightlessSync/Resources/Resources.zh.resx
Normal file
20
LightlessSync/Resources/Resources.zh.resx
Normal file
@@ -0,0 +1,20 @@
|
||||
<root>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ToSStrings_LanguageLabel" xml:space="preserve">
|
||||
<value>语言</value>
|
||||
</data>
|
||||
<data name="Users_Online" xml:space="preserve">
|
||||
<value>用户在线</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,29 +1,41 @@
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.UI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats.Gif;
|
||||
using SixLabors.ImageSharp.Formats.Webp;
|
||||
using SixLabors.ImageSharp.Metadata;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
|
||||
namespace LightlessSync.Services.Chat;
|
||||
|
||||
public sealed class ChatEmoteService : IDisposable
|
||||
{
|
||||
private const string GlobalEmoteSetUrl = "https://7tv.io/v3/emote-sets/global";
|
||||
private const int DefaultFrameDelayMs = 100;
|
||||
private const int MinFrameDelayMs = 20;
|
||||
|
||||
private readonly ILogger<ChatEmoteService> _logger;
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private readonly ChatConfigService _chatConfigService;
|
||||
private readonly ConcurrentDictionary<string, EmoteEntry> _emotes = new(StringComparer.Ordinal);
|
||||
private readonly SemaphoreSlim _downloadGate = new(3, 3);
|
||||
|
||||
private readonly object _loadLock = new();
|
||||
private Task? _loadTask;
|
||||
|
||||
public ChatEmoteService(ILogger<ChatEmoteService> logger, HttpClient httpClient, UiSharedService uiSharedService)
|
||||
public ChatEmoteService(ILogger<ChatEmoteService> logger, HttpClient httpClient, UiSharedService uiSharedService, ChatConfigService chatConfigService)
|
||||
{
|
||||
_logger = logger;
|
||||
_httpClient = httpClient;
|
||||
_uiSharedService = uiSharedService;
|
||||
_chatConfigService = chatConfigService;
|
||||
}
|
||||
|
||||
public void EnsureGlobalEmotesLoaded()
|
||||
@@ -62,13 +74,17 @@ public sealed class ChatEmoteService : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entry.Texture is not null)
|
||||
var allowAnimation = _chatConfigService.Current.EnableAnimatedEmotes;
|
||||
if (entry.TryGetTexture(allowAnimation, out texture))
|
||||
{
|
||||
texture = entry.Texture;
|
||||
if (allowAnimation && entry.NeedsAnimationLoad && !entry.HasAttemptedAnimation)
|
||||
{
|
||||
entry.EnsureLoading(allowAnimation, QueueEmoteDownload, allowWhenStaticLoaded: true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
entry.EnsureLoading(QueueEmoteDownload);
|
||||
entry.EnsureLoading(allowAnimation, QueueEmoteDownload);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -76,7 +92,7 @@ public sealed class ChatEmoteService : IDisposable
|
||||
{
|
||||
foreach (var entry in _emotes.Values)
|
||||
{
|
||||
entry.Texture?.Dispose();
|
||||
entry.Dispose();
|
||||
}
|
||||
|
||||
_downloadGate.Dispose();
|
||||
@@ -108,13 +124,13 @@ public sealed class ChatEmoteService : IDisposable
|
||||
continue;
|
||||
}
|
||||
|
||||
var url = TryBuildEmoteUrl(emoteElement);
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
var source = TryBuildEmoteSource(emoteElement);
|
||||
if (source is null || (!source.Value.HasStatic && !source.Value.HasAnimation))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_emotes.TryAdd(name, new EmoteEntry(url));
|
||||
_emotes.TryAdd(name, new EmoteEntry(name, source.Value));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -123,7 +139,7 @@ public sealed class ChatEmoteService : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private static string? TryBuildEmoteUrl(JsonElement emoteElement)
|
||||
private static EmoteSource? TryBuildEmoteSource(JsonElement emoteElement)
|
||||
{
|
||||
if (!emoteElement.TryGetProperty("data", out var dataElement))
|
||||
{
|
||||
@@ -156,29 +172,38 @@ public sealed class ChatEmoteService : IDisposable
|
||||
return null;
|
||||
}
|
||||
|
||||
var fileName = PickBestStaticFile(filesElement);
|
||||
if (string.IsNullOrWhiteSpace(fileName))
|
||||
var files = ReadEmoteFiles(filesElement);
|
||||
if (files.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return baseUrl.TrimEnd('/') + "/" + fileName;
|
||||
var animatedFile = PickBestAnimatedFile(files);
|
||||
var animatedUrl = animatedFile is null ? null : BuildEmoteUrl(baseUrl, animatedFile.Value.Name);
|
||||
|
||||
var staticName = animatedFile?.StaticName;
|
||||
if (string.IsNullOrWhiteSpace(staticName))
|
||||
{
|
||||
staticName = PickBestStaticFileName(files);
|
||||
}
|
||||
|
||||
var staticUrl = string.IsNullOrWhiteSpace(staticName) ? null : BuildEmoteUrl(baseUrl, staticName);
|
||||
if (string.IsNullOrWhiteSpace(animatedUrl) && string.IsNullOrWhiteSpace(staticUrl))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new EmoteSource(staticUrl, animatedUrl);
|
||||
}
|
||||
|
||||
private static string? PickBestStaticFile(JsonElement filesElement)
|
||||
{
|
||||
string? png1x = null;
|
||||
string? webp1x = null;
|
||||
string? pngFallback = null;
|
||||
string? webpFallback = null;
|
||||
private static string BuildEmoteUrl(string baseUrl, string fileName)
|
||||
=> baseUrl.TrimEnd('/') + "/" + fileName;
|
||||
|
||||
private static List<EmoteFile> ReadEmoteFiles(JsonElement filesElement)
|
||||
{
|
||||
var files = new List<EmoteFile>();
|
||||
foreach (var file in filesElement.EnumerateArray())
|
||||
{
|
||||
if (file.TryGetProperty("static", out var staticElement) && staticElement.ValueKind == JsonValueKind.False)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!file.TryGetProperty("name", out var nameElement))
|
||||
{
|
||||
continue;
|
||||
@@ -190,6 +215,88 @@ public sealed class ChatEmoteService : IDisposable
|
||||
continue;
|
||||
}
|
||||
|
||||
string? staticName = null;
|
||||
if (file.TryGetProperty("static_name", out var staticNameElement) && staticNameElement.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
staticName = staticNameElement.GetString();
|
||||
}
|
||||
|
||||
var frameCount = 1;
|
||||
if (file.TryGetProperty("frame_count", out var frameCountElement) && frameCountElement.ValueKind == JsonValueKind.Number)
|
||||
{
|
||||
frameCountElement.TryGetInt32(out frameCount);
|
||||
frameCount = Math.Max(frameCount, 1);
|
||||
}
|
||||
|
||||
string? format = null;
|
||||
if (file.TryGetProperty("format", out var formatElement) && formatElement.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
format = formatElement.GetString();
|
||||
}
|
||||
|
||||
files.Add(new EmoteFile(name, staticName, frameCount, format));
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
private static EmoteFile? PickBestAnimatedFile(IReadOnlyList<EmoteFile> files)
|
||||
{
|
||||
EmoteFile? webp1x = null;
|
||||
EmoteFile? gif1x = null;
|
||||
EmoteFile? webpFallback = null;
|
||||
EmoteFile? gifFallback = null;
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (file.FrameCount <= 1 || !IsAnimatedFormatSupported(file))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.Name.Equals("1x.webp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
webp1x = file;
|
||||
}
|
||||
else if (file.Name.Equals("1x.gif", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
gif1x = file;
|
||||
}
|
||||
else if (file.Name.EndsWith(".webp", StringComparison.OrdinalIgnoreCase) && webpFallback is null)
|
||||
{
|
||||
webpFallback = file;
|
||||
}
|
||||
else if (file.Name.EndsWith(".gif", StringComparison.OrdinalIgnoreCase) && gifFallback is null)
|
||||
{
|
||||
gifFallback = file;
|
||||
}
|
||||
}
|
||||
|
||||
return webp1x ?? gif1x ?? webpFallback ?? gifFallback;
|
||||
}
|
||||
|
||||
private static string? PickBestStaticFileName(IReadOnlyList<EmoteFile> files)
|
||||
{
|
||||
string? png1x = null;
|
||||
string? webp1x = null;
|
||||
string? gif1x = null;
|
||||
string? pngFallback = null;
|
||||
string? webpFallback = null;
|
||||
string? gifFallback = null;
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (file.FrameCount > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = file.StaticName ?? file.Name;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name.Equals("1x.png", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
png1x = name;
|
||||
@@ -198,6 +305,10 @@ public sealed class ChatEmoteService : IDisposable
|
||||
{
|
||||
webp1x = name;
|
||||
}
|
||||
else if (name.Equals("1x.gif", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
gif1x = name;
|
||||
}
|
||||
else if (name.EndsWith(".png", StringComparison.OrdinalIgnoreCase) && pngFallback is null)
|
||||
{
|
||||
pngFallback = name;
|
||||
@@ -206,25 +317,80 @@ public sealed class ChatEmoteService : IDisposable
|
||||
{
|
||||
webpFallback = name;
|
||||
}
|
||||
else if (name.EndsWith(".gif", StringComparison.OrdinalIgnoreCase) && gifFallback is null)
|
||||
{
|
||||
gifFallback = name;
|
||||
}
|
||||
}
|
||||
|
||||
return png1x ?? webp1x ?? pngFallback ?? webpFallback;
|
||||
return png1x ?? webp1x ?? gif1x ?? pngFallback ?? webpFallback ?? gifFallback;
|
||||
}
|
||||
|
||||
private void QueueEmoteDownload(EmoteEntry entry)
|
||||
private static bool IsAnimatedFormatSupported(EmoteFile file)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(file.Format))
|
||||
{
|
||||
return file.Format.Equals("WEBP", StringComparison.OrdinalIgnoreCase)
|
||||
|| file.Format.Equals("GIF", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
return file.Name.EndsWith(".webp", StringComparison.OrdinalIgnoreCase)
|
||||
|| file.Name.EndsWith(".gif", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private readonly record struct EmoteSource(string? StaticUrl, string? AnimatedUrl)
|
||||
{
|
||||
public bool HasStatic => !string.IsNullOrWhiteSpace(StaticUrl);
|
||||
public bool HasAnimation => !string.IsNullOrWhiteSpace(AnimatedUrl);
|
||||
}
|
||||
|
||||
private readonly record struct EmoteFile(string Name, string? StaticName, int FrameCount, string? Format);
|
||||
|
||||
private void QueueEmoteDownload(EmoteEntry entry, bool allowAnimation)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await _downloadGate.WaitAsync().ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
var data = await _httpClient.GetByteArrayAsync(entry.Url).ConfigureAwait(false);
|
||||
var texture = _uiSharedService.LoadImage(data);
|
||||
entry.SetTexture(texture);
|
||||
if (allowAnimation)
|
||||
{
|
||||
if (entry.HasAnimatedSource)
|
||||
{
|
||||
entry.MarkAnimationAttempted();
|
||||
if (await TryLoadAnimatedEmoteAsync(entry).ConfigureAwait(false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.HasStaticSource && !entry.HasStaticTexture && await TryLoadStaticEmoteAsync(entry).ConfigureAwait(false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry.HasStaticSource && await TryLoadStaticEmoteAsync(entry).ConfigureAwait(false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.HasAnimatedSource)
|
||||
{
|
||||
entry.MarkAnimationAttempted();
|
||||
if (await TryLoadAnimatedEmoteAsync(entry).ConfigureAwait(false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entry.MarkFailed();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed to load 7TV emote {Url}", entry.Url);
|
||||
_logger.LogDebug(ex, "Failed to load 7TV emote {Emote}", entry.Code);
|
||||
entry.MarkFailed();
|
||||
}
|
||||
finally
|
||||
@@ -234,21 +400,334 @@ public sealed class ChatEmoteService : IDisposable
|
||||
});
|
||||
}
|
||||
|
||||
private sealed class EmoteEntry
|
||||
private async Task<bool> TryLoadAnimatedEmoteAsync(EmoteEntry entry)
|
||||
{
|
||||
private int _loadingState;
|
||||
|
||||
public EmoteEntry(string url)
|
||||
if (string.IsNullOrWhiteSpace(entry.AnimatedUrl))
|
||||
{
|
||||
Url = url;
|
||||
return false;
|
||||
}
|
||||
|
||||
public string Url { get; }
|
||||
public IDalamudTextureWrap? Texture { get; private set; }
|
||||
|
||||
public void EnsureLoading(Action<EmoteEntry> queueDownload)
|
||||
try
|
||||
{
|
||||
if (Texture is not null)
|
||||
var data = await _httpClient.GetByteArrayAsync(entry.AnimatedUrl).ConfigureAwait(false);
|
||||
var isWebp = entry.AnimatedUrl.EndsWith(".webp", StringComparison.OrdinalIgnoreCase);
|
||||
if (!TryDecodeAnimation(data, isWebp, out var animation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.SetAnimation(animation);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed to decode animated 7TV emote {Emote}", entry.Code);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> TryLoadStaticEmoteAsync(EmoteEntry entry)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.StaticUrl))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var data = await _httpClient.GetByteArrayAsync(entry.StaticUrl).ConfigureAwait(false);
|
||||
var texture = _uiSharedService.LoadImage(data);
|
||||
entry.SetStaticTexture(texture);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed to decode static 7TV emote {Emote}", entry.Code);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryDecodeAnimation(byte[] data, bool isWebp, out EmoteAnimation? animation)
|
||||
{
|
||||
animation = null;
|
||||
List<EmoteFrame>? frames = null;
|
||||
|
||||
try
|
||||
{
|
||||
Image<Rgba32> image;
|
||||
if (isWebp)
|
||||
{
|
||||
using var stream = new MemoryStream(data);
|
||||
image = WebpDecoder.Instance.Decode<Rgba32>(
|
||||
new WebpDecoderOptions { BackgroundColorHandling = BackgroundColorHandling.Ignore },
|
||||
stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
image = Image.Load<Rgba32>(data);
|
||||
}
|
||||
|
||||
using (image)
|
||||
{
|
||||
if (image.Frames.Count <= 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using var composite = new Image<Rgba32>(image.Width, image.Height, Color.Transparent);
|
||||
Image<Rgba32>? restoreCanvas = null;
|
||||
GifDisposalMethod? pendingGifDisposal = null;
|
||||
WebpDisposalMethod? pendingWebpDisposal = null;
|
||||
|
||||
frames = new List<EmoteFrame>(image.Frames.Count);
|
||||
for (var i = 0; i < image.Frames.Count; i++)
|
||||
{
|
||||
var frameMetadata = image.Frames[i].Metadata;
|
||||
var delayMs = GetFrameDelayMs(frameMetadata);
|
||||
|
||||
ApplyDisposal(composite, ref restoreCanvas, pendingGifDisposal, pendingWebpDisposal);
|
||||
|
||||
GifDisposalMethod? currentGifDisposal = null;
|
||||
WebpDisposalMethod? currentWebpDisposal = null;
|
||||
var blendMethod = WebpBlendMethod.Over;
|
||||
|
||||
if (isWebp)
|
||||
{
|
||||
if (frameMetadata.TryGetWebpFrameMetadata(out var webpMetadata))
|
||||
{
|
||||
currentWebpDisposal = webpMetadata.DisposalMethod;
|
||||
blendMethod = webpMetadata.BlendMethod;
|
||||
}
|
||||
}
|
||||
else if (frameMetadata.TryGetGifMetadata(out var gifMetadata))
|
||||
{
|
||||
currentGifDisposal = gifMetadata.DisposalMethod;
|
||||
}
|
||||
|
||||
if (currentGifDisposal == GifDisposalMethod.RestoreToPrevious)
|
||||
{
|
||||
restoreCanvas?.Dispose();
|
||||
restoreCanvas = composite.Clone();
|
||||
}
|
||||
|
||||
using var frameImage = image.Frames.CloneFrame(i);
|
||||
var alphaMode = blendMethod == WebpBlendMethod.Source
|
||||
? PixelAlphaCompositionMode.Src
|
||||
: PixelAlphaCompositionMode.SrcOver;
|
||||
composite.Mutate(ctx => ctx.DrawImage(frameImage, PixelColorBlendingMode.Normal, alphaMode, 1f));
|
||||
|
||||
using var renderedFrame = composite.Clone();
|
||||
using var ms = new MemoryStream();
|
||||
renderedFrame.SaveAsPng(ms);
|
||||
|
||||
var texture = _uiSharedService.LoadImage(ms.ToArray());
|
||||
frames.Add(new EmoteFrame(texture, delayMs));
|
||||
|
||||
pendingGifDisposal = currentGifDisposal;
|
||||
pendingWebpDisposal = currentWebpDisposal;
|
||||
}
|
||||
|
||||
restoreCanvas?.Dispose();
|
||||
|
||||
animation = new EmoteAnimation(frames);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (frames is not null)
|
||||
{
|
||||
foreach (var frame in frames)
|
||||
{
|
||||
frame.Texture.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetFrameDelayMs(ImageFrameMetadata metadata)
|
||||
{
|
||||
if (metadata.TryGetGifMetadata(out var gifMetadata))
|
||||
{
|
||||
var delayMs = (long)gifMetadata.FrameDelay * 10L;
|
||||
return NormalizeFrameDelayMs(delayMs);
|
||||
}
|
||||
|
||||
if (metadata.TryGetWebpFrameMetadata(out var webpMetadata))
|
||||
{
|
||||
return NormalizeFrameDelayMs(webpMetadata.FrameDelay);
|
||||
}
|
||||
|
||||
return DefaultFrameDelayMs;
|
||||
}
|
||||
|
||||
private static int NormalizeFrameDelayMs(long delayMs)
|
||||
{
|
||||
if (delayMs <= 0)
|
||||
{
|
||||
return DefaultFrameDelayMs;
|
||||
}
|
||||
|
||||
var clamped = delayMs > int.MaxValue ? int.MaxValue : (int)delayMs;
|
||||
return Math.Max(clamped, MinFrameDelayMs);
|
||||
}
|
||||
|
||||
private static void ApplyDisposal(
|
||||
Image<Rgba32> composite,
|
||||
ref Image<Rgba32>? restoreCanvas,
|
||||
GifDisposalMethod? gifDisposal,
|
||||
WebpDisposalMethod? webpDisposal)
|
||||
{
|
||||
if (gifDisposal is not null)
|
||||
{
|
||||
switch (gifDisposal)
|
||||
{
|
||||
case GifDisposalMethod.RestoreToBackground:
|
||||
composite.Mutate(ctx => ctx.BackgroundColor(Color.Transparent));
|
||||
break;
|
||||
case GifDisposalMethod.RestoreToPrevious:
|
||||
if (restoreCanvas is not null)
|
||||
{
|
||||
composite.Mutate(ctx => ctx.BackgroundColor(Color.Transparent));
|
||||
var restoreSnapshot = restoreCanvas;
|
||||
composite.Mutate(ctx => ctx.DrawImage(restoreSnapshot, PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.Src, 1f));
|
||||
restoreCanvas.Dispose();
|
||||
restoreCanvas = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (webpDisposal == WebpDisposalMethod.RestoreToBackground)
|
||||
{
|
||||
composite.Mutate(ctx => ctx.BackgroundColor(Color.Transparent));
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class EmoteAnimation : IDisposable
|
||||
{
|
||||
private readonly EmoteFrame[] _frames;
|
||||
private readonly int _durationMs;
|
||||
private readonly long _startTimestamp;
|
||||
|
||||
public EmoteAnimation(IReadOnlyList<EmoteFrame> frames)
|
||||
{
|
||||
_frames = frames.ToArray();
|
||||
_durationMs = Math.Max(1, frames.Sum(frame => frame.DurationMs));
|
||||
_startTimestamp = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
public IDalamudTextureWrap? GetCurrentFrame()
|
||||
{
|
||||
if (_frames.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_frames.Length == 1)
|
||||
{
|
||||
return _frames[0].Texture;
|
||||
}
|
||||
|
||||
var elapsedTicks = Stopwatch.GetTimestamp() - _startTimestamp;
|
||||
var elapsedMs = (elapsedTicks * 1000L) / Stopwatch.Frequency;
|
||||
var targetMs = (int)(elapsedMs % _durationMs);
|
||||
var accumulated = 0;
|
||||
|
||||
foreach (var frame in _frames)
|
||||
{
|
||||
accumulated += frame.DurationMs;
|
||||
if (targetMs < accumulated)
|
||||
{
|
||||
return frame.Texture;
|
||||
}
|
||||
}
|
||||
|
||||
return _frames[^1].Texture;
|
||||
}
|
||||
|
||||
public IDalamudTextureWrap? GetStaticFrame()
|
||||
{
|
||||
if (_frames.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _frames[0].Texture;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var frame in _frames)
|
||||
{
|
||||
frame.Texture.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly record struct EmoteFrame(IDalamudTextureWrap Texture, int DurationMs);
|
||||
|
||||
private sealed class EmoteEntry : IDisposable
|
||||
{
|
||||
private int _loadingState;
|
||||
private int _animationAttempted;
|
||||
private IDalamudTextureWrap? _staticTexture;
|
||||
private EmoteAnimation? _animation;
|
||||
|
||||
public EmoteEntry(string code, EmoteSource source)
|
||||
{
|
||||
Code = code;
|
||||
StaticUrl = source.StaticUrl;
|
||||
AnimatedUrl = source.AnimatedUrl;
|
||||
}
|
||||
|
||||
public string Code { get; }
|
||||
public string? StaticUrl { get; }
|
||||
public string? AnimatedUrl { get; }
|
||||
public bool HasStaticSource => !string.IsNullOrWhiteSpace(StaticUrl);
|
||||
public bool HasAnimatedSource => !string.IsNullOrWhiteSpace(AnimatedUrl);
|
||||
public bool HasStaticTexture => _staticTexture is not null;
|
||||
public bool HasAttemptedAnimation => Interlocked.CompareExchange(ref _animationAttempted, 0, 0) != 0;
|
||||
public bool NeedsAnimationLoad => _animation is null && HasAnimatedSource;
|
||||
|
||||
public void MarkAnimationAttempted()
|
||||
{
|
||||
Interlocked.Exchange(ref _animationAttempted, 1);
|
||||
}
|
||||
|
||||
public bool TryGetTexture(bool allowAnimation, out IDalamudTextureWrap? texture)
|
||||
{
|
||||
if (allowAnimation && _animation is not null)
|
||||
{
|
||||
texture = _animation.GetCurrentFrame();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_staticTexture is not null)
|
||||
{
|
||||
texture = _staticTexture;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!allowAnimation && _animation is not null)
|
||||
{
|
||||
texture = _animation.GetStaticFrame();
|
||||
return true;
|
||||
}
|
||||
|
||||
texture = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void EnsureLoading(bool allowAnimation, Action<EmoteEntry, bool> queueDownload, bool allowWhenStaticLoaded = false)
|
||||
{
|
||||
if (_animation is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowWhenStaticLoaded && _staticTexture is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -258,12 +737,22 @@ public sealed class ChatEmoteService : IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
queueDownload(this);
|
||||
queueDownload(this, allowAnimation);
|
||||
}
|
||||
|
||||
public void SetTexture(IDalamudTextureWrap texture)
|
||||
public void SetAnimation(EmoteAnimation animation)
|
||||
{
|
||||
Texture = texture;
|
||||
_staticTexture?.Dispose();
|
||||
_staticTexture = null;
|
||||
_animation?.Dispose();
|
||||
_animation = animation;
|
||||
Interlocked.Exchange(ref _loadingState, 0);
|
||||
}
|
||||
|
||||
public void SetStaticTexture(IDalamudTextureWrap texture)
|
||||
{
|
||||
_staticTexture?.Dispose();
|
||||
_staticTexture = texture;
|
||||
Interlocked.Exchange(ref _loadingState, 0);
|
||||
}
|
||||
|
||||
@@ -271,5 +760,11 @@ public sealed class ChatEmoteService : IDisposable
|
||||
{
|
||||
Interlocked.Exchange(ref _loadingState, 0);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_animation?.Dispose();
|
||||
_staticTexture?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
{
|
||||
return gameData.GetExcelSheet<Lumina.Excel.Sheets.World>(clientLanguage)!
|
||||
.Where(w => !w.Name.IsEmpty && w.DataCenter.RowId != 0 && (w.IsPublic || char.IsUpper(w.Name.ToString()[0])
|
||||
|| w is { RowId: > 1000, Region: 101 or 201 }))
|
||||
|| w is { RowId: > 1000, UserType: 101 or 201 }))
|
||||
.ToDictionary(w => (ushort)w.RowId, w => w.Name.ToString());
|
||||
});
|
||||
JobData = new(() =>
|
||||
@@ -666,7 +666,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
|
||||
var location = new LocationInfo();
|
||||
location.ServerId = _playerState.CurrentWorld.RowId;
|
||||
location.InstanceId = UIState.Instance()->PublicInstance.InstanceId;
|
||||
location.InstanceId = UIState.Instance()->PublicInstance.InstanceId;
|
||||
location.TerritoryId = _clientState.TerritoryType;
|
||||
location.MapId = _clientState.MapId;
|
||||
if (houseMan != null)
|
||||
@@ -699,13 +699,13 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
|
||||
public string LocationToString(LocationInfo location)
|
||||
{
|
||||
if (location.ServerId is 0 || location.TerritoryId is 0) return String.Empty;
|
||||
var str = WorldData.Value[(ushort)location.ServerId];
|
||||
|
||||
if (ContentFinderData.Value.TryGetValue(location.TerritoryId , out var dutyName))
|
||||
if (ContentFinderData.Value.TryGetValue(location.TerritoryId, out var dutyName))
|
||||
{
|
||||
str += $" - [In Duty]{dutyName}";
|
||||
}
|
||||
@@ -856,7 +856,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
|
||||
var token = ct ?? CancellationToken.None;
|
||||
|
||||
const int tick = 250;
|
||||
const int tick = 250;
|
||||
const int initialSettle = 50;
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
@@ -881,7 +881,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
catch (AccessViolationException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Error accessing {handler}, object does not exist anymore?", handler);
|
||||
}
|
||||
@@ -922,11 +922,11 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
public string? GetWorldNameFromPlayerAddress(nint address)
|
||||
{
|
||||
if (address == nint.Zero) return null;
|
||||
|
||||
|
||||
EnsureIsOnFramework();
|
||||
var playerCharacter = _objectTable.OfType<IPlayerCharacter>().FirstOrDefault(p => p.Address == address);
|
||||
if (playerCharacter == null) return null;
|
||||
|
||||
|
||||
var worldId = (ushort)playerCharacter.HomeWorld.RowId;
|
||||
return WorldData.Value.TryGetValue(worldId, out var worldName) ? worldName : null;
|
||||
}
|
||||
@@ -953,37 +953,87 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
});
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool IsBadReadPtr(IntPtr ptr, UIntPtr size);
|
||||
|
||||
private static bool IsValidPointer(nint ptr, int size = 8)
|
||||
{
|
||||
if (ptr == nint.Zero)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
if (!Util.IsWine())
|
||||
{
|
||||
return !IsBadReadPtr(ptr, (UIntPtr)size);
|
||||
}
|
||||
return ptr != nint.Zero && (ptr % IntPtr.Size) == 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void CheckCharacterForDrawing(nint address, string characterName)
|
||||
{
|
||||
if (address == nint.Zero)
|
||||
return;
|
||||
|
||||
if (!IsValidPointer(address))
|
||||
{
|
||||
_logger.LogDebug("Invalid pointer for character {name} at {addr}", characterName, address.ToString("X"));
|
||||
return;
|
||||
}
|
||||
|
||||
var gameObj = (GameObject*)address;
|
||||
|
||||
if (gameObj == null)
|
||||
return;
|
||||
|
||||
if (!_objectTable.Any(o => o?.Address == address))
|
||||
{
|
||||
_logger.LogDebug("Character {name} at {addr} no longer in object table", characterName, address.ToString("X"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameObj->ObjectKind == 0)
|
||||
return;
|
||||
|
||||
var drawObj = gameObj->DrawObject;
|
||||
bool isDrawing = false;
|
||||
bool isDrawingChanged = false;
|
||||
if ((nint)drawObj != IntPtr.Zero)
|
||||
|
||||
if ((nint)drawObj != IntPtr.Zero && IsValidPointer((nint)drawObj))
|
||||
{
|
||||
isDrawing = gameObj->RenderFlags == (VisibilityFlags)0b100000000000;
|
||||
|
||||
if (!isDrawing)
|
||||
{
|
||||
isDrawing = ((CharacterBase*)drawObj)->HasModelInSlotLoaded != 0;
|
||||
if (!isDrawing)
|
||||
var charBase = (CharacterBase*)drawObj;
|
||||
if (charBase != null && IsValidPointer((nint)charBase))
|
||||
{
|
||||
isDrawing = ((CharacterBase*)drawObj)->HasModelFilesInSlotLoaded != 0;
|
||||
if (isDrawing && !string.Equals(_lastGlobalBlockPlayer, characterName, StringComparison.Ordinal)
|
||||
&& !string.Equals(_lastGlobalBlockReason, "HasModelFilesInSlotLoaded", StringComparison.Ordinal))
|
||||
isDrawing = charBase->HasModelInSlotLoaded != 0;
|
||||
if (!isDrawing)
|
||||
{
|
||||
_lastGlobalBlockPlayer = characterName;
|
||||
_lastGlobalBlockReason = "HasModelFilesInSlotLoaded";
|
||||
isDrawingChanged = true;
|
||||
isDrawing = charBase->HasModelFilesInSlotLoaded != 0;
|
||||
if (isDrawing && !string.Equals(_lastGlobalBlockPlayer, characterName, StringComparison.Ordinal)
|
||||
&& !string.Equals(_lastGlobalBlockReason, "HasModelFilesInSlotLoaded", StringComparison.Ordinal))
|
||||
{
|
||||
_lastGlobalBlockPlayer = characterName;
|
||||
_lastGlobalBlockReason = "HasModelFilesInSlotLoaded";
|
||||
isDrawingChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.Equals(_lastGlobalBlockPlayer, characterName, StringComparison.Ordinal)
|
||||
&& !string.Equals(_lastGlobalBlockReason, "HasModelInSlotLoaded", StringComparison.Ordinal))
|
||||
else
|
||||
{
|
||||
_lastGlobalBlockPlayer = characterName;
|
||||
_lastGlobalBlockReason = "HasModelInSlotLoaded";
|
||||
isDrawingChanged = true;
|
||||
if (!string.Equals(_lastGlobalBlockPlayer, characterName, StringComparison.Ordinal)
|
||||
&& !string.Equals(_lastGlobalBlockReason, "HasModelInSlotLoaded", StringComparison.Ordinal))
|
||||
{
|
||||
_lastGlobalBlockPlayer = characterName;
|
||||
_lastGlobalBlockReason = "HasModelInSlotLoaded";
|
||||
isDrawingChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1014,6 +1064,11 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
|
||||
private unsafe void FrameworkOnUpdateInternal()
|
||||
{
|
||||
if (!_clientState.IsLoggedIn || _objectTable.LocalPlayer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_objectTable.LocalPlayer?.IsDead ?? false) && _condition[ConditionFlag.BoundByDuty])
|
||||
{
|
||||
return;
|
||||
@@ -1033,12 +1088,17 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
}
|
||||
|
||||
var playerDescriptors = _actorObjectService.PlayerDescriptors;
|
||||
for (var i = 0; i < playerDescriptors.Count; i++)
|
||||
var descriptorCount = playerDescriptors.Count;
|
||||
|
||||
for (var i = 0; i < descriptorCount; i++)
|
||||
{
|
||||
if (i >= playerDescriptors.Count)
|
||||
break;
|
||||
|
||||
var actor = playerDescriptors[i];
|
||||
|
||||
var playerAddress = actor.Address;
|
||||
if (playerAddress == nint.Zero)
|
||||
if (playerAddress == nint.Zero || !IsValidPointer(playerAddress))
|
||||
continue;
|
||||
|
||||
if (actor.ObjectIndex >= 200)
|
||||
@@ -1052,17 +1112,16 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
|
||||
if (!IsAnythingDrawing)
|
||||
{
|
||||
var gameObj = (GameObject*)playerAddress;
|
||||
var currentName = gameObj != null ? gameObj->NameString ?? string.Empty : string.Empty;
|
||||
var charaName = string.IsNullOrEmpty(currentName) ? actor.Name : currentName;
|
||||
CheckCharacterForDrawing(playerAddress, charaName);
|
||||
if (!_objectTable.Any(o => o?.Address == playerAddress))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CheckCharacterForDrawing(playerAddress, actor.Name);
|
||||
|
||||
if (IsAnythingDrawing)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1131,7 +1190,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
});
|
||||
|
||||
// Cutscene
|
||||
HandleStateTransition(() => IsInCutscene,v => IsInCutscene = v, shouldBeInCutscene, "Cutscene",
|
||||
HandleStateTransition(() => IsInCutscene, v => IsInCutscene = v, shouldBeInCutscene, "Cutscene",
|
||||
onEnter: () =>
|
||||
{
|
||||
Mediator.Publish(new CutsceneStartMessage());
|
||||
@@ -1174,7 +1233,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
Mediator.Publish(new ZoneSwitchEndMessage());
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(ConditionFlag.BetweenAreas)));
|
||||
}
|
||||
|
||||
|
||||
//Map
|
||||
if (!_sentBetweenAreas)
|
||||
{
|
||||
@@ -1185,7 +1244,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
Mediator.Publish(new MapChangedMessage(mapid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var localPlayer = _objectTable.LocalPlayer;
|
||||
if (localPlayer != null)
|
||||
@@ -1271,4 +1330,4 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
onExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,12 +83,12 @@ public class LightFinderScannerService : DisposableMediatorSubscriberBase
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
foreach (var address in _actorTracker.PlayerAddresses)
|
||||
foreach (var descriptor in _actorTracker.PlayerDescriptors)
|
||||
{
|
||||
if (address == nint.Zero)
|
||||
if (string.IsNullOrEmpty(descriptor.HashedContentId))
|
||||
continue;
|
||||
|
||||
var cid = DalamudUtilService.GetHashedCIDFromPlayerPointer(address);
|
||||
var cid = descriptor.HashedContentId;
|
||||
var isStale = !_broadcastCache.TryGetValue(cid, out var entry) || entry.ExpiryTime <= now;
|
||||
|
||||
if (isStale && _lookupQueuedCids.Add(cid) && _lookupQueue.Count < _maxQueueSize)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using FFXIVClientStructs.Havok.Common.Serialize.Resource;
|
||||
using FFXIVClientStructs.Havok.Animation;
|
||||
using FFXIVClientStructs.Havok.Common.Base.Types;
|
||||
using FFXIVClientStructs.Havok.Common.Serialize.Util;
|
||||
@@ -145,156 +146,297 @@ public sealed partial class XivDataAnalyzer
|
||||
using var reader = new BinaryReader(fs);
|
||||
|
||||
// PAP header (mostly from vfxeditor)
|
||||
_ = reader.ReadInt32(); // ignore
|
||||
_ = reader.ReadInt32(); // ignore
|
||||
_ = reader.ReadInt16(); // num animations
|
||||
_ = reader.ReadInt16(); // modelid
|
||||
|
||||
var type = reader.ReadByte(); // type
|
||||
if (type != 0)
|
||||
return null; // not human
|
||||
|
||||
_ = reader.ReadByte(); // variant
|
||||
_ = reader.ReadInt32(); // ignore
|
||||
|
||||
var havokPosition = reader.ReadInt32();
|
||||
var footerPosition = reader.ReadInt32();
|
||||
|
||||
// sanity checks
|
||||
if (havokPosition <= 0 || footerPosition <= havokPosition || footerPosition > fs.Length)
|
||||
return null;
|
||||
|
||||
var havokDataSizeLong = (long)footerPosition - havokPosition;
|
||||
if (havokDataSizeLong <= 8 || havokDataSizeLong > int.MaxValue)
|
||||
return null;
|
||||
|
||||
var havokDataSize = (int)havokDataSizeLong;
|
||||
|
||||
reader.BaseStream.Position = havokPosition;
|
||||
var havokData = reader.ReadBytes(havokDataSize);
|
||||
if (havokData.Length <= 8)
|
||||
return null;
|
||||
|
||||
var tempSets = new Dictionary<string, HashSet<ushort>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var tempHavokDataPath = Path.Combine(Path.GetTempPath(), $"lightless_{Guid.NewGuid():N}.hkx");
|
||||
IntPtr tempHavokDataPathAnsi = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(tempHavokDataPath, havokData);
|
||||
_ = reader.ReadInt32(); // ignore
|
||||
_ = reader.ReadInt32(); // ignore
|
||||
var numAnimations = reader.ReadInt16(); // num animations
|
||||
var modelId = reader.ReadInt16(); // modelid
|
||||
|
||||
if (!File.Exists(tempHavokDataPath))
|
||||
if (numAnimations < 0 || numAnimations > 1000)
|
||||
{
|
||||
_logger.LogTrace("Temporary havok file did not exist when attempting to load: {path}", tempHavokDataPath);
|
||||
_logger.LogWarning("PAP file {hash} has invalid animation count {count}, skipping", hash, numAnimations);
|
||||
return null;
|
||||
}
|
||||
|
||||
tempHavokDataPathAnsi = Marshal.StringToHGlobalAnsi(tempHavokDataPath);
|
||||
var type = reader.ReadByte(); // type
|
||||
if (type != 0)
|
||||
return null; // not human
|
||||
|
||||
var loadoptions = stackalloc hkSerializeUtil.LoadOptions[1];
|
||||
loadoptions->TypeInfoRegistry = hkBuiltinTypeRegistry.Instance()->GetTypeInfoRegistry();
|
||||
loadoptions->ClassNameRegistry = hkBuiltinTypeRegistry.Instance()->GetClassNameRegistry();
|
||||
loadoptions->Flags = new hkFlags<hkSerializeUtil.LoadOptionBits, int>
|
||||
{
|
||||
Storage = (int)hkSerializeUtil.LoadOptionBits.Default
|
||||
};
|
||||
_ = reader.ReadByte(); // variant
|
||||
_ = reader.ReadInt32(); // ignore
|
||||
|
||||
var resource = hkSerializeUtil.LoadFromFile((byte*)tempHavokDataPathAnsi, null, loadoptions);
|
||||
if (resource == null)
|
||||
var havokPosition = reader.ReadInt32();
|
||||
var footerPosition = reader.ReadInt32();
|
||||
|
||||
if (havokPosition <= 0 || footerPosition <= havokPosition ||
|
||||
footerPosition > fs.Length || havokPosition >= fs.Length)
|
||||
{
|
||||
_logger.LogWarning("Havok resource was null after loading from {path}", tempHavokDataPath);
|
||||
_logger.LogWarning("PAP file {hash} has invalid offsets (havok={havok}, footer={footer}, length={length})",
|
||||
hash, havokPosition, footerPosition, fs.Length);
|
||||
return null;
|
||||
}
|
||||
|
||||
var rootLevelName = @"hkRootLevelContainer"u8;
|
||||
fixed (byte* n1 = rootLevelName)
|
||||
var havokDataSizeLong = (long)footerPosition - havokPosition;
|
||||
if (havokDataSizeLong <= 8 || havokDataSizeLong > int.MaxValue)
|
||||
{
|
||||
var container = (hkRootLevelContainer*)resource->GetContentsPointer(n1, hkBuiltinTypeRegistry.Instance()->GetTypeInfoRegistry());
|
||||
if (container == null)
|
||||
return null;
|
||||
_logger.LogWarning("PAP file {hash} has invalid Havok data size {size}", hash, havokDataSizeLong);
|
||||
return null;
|
||||
}
|
||||
|
||||
var animationName = @"hkaAnimationContainer"u8;
|
||||
fixed (byte* n2 = animationName)
|
||||
var havokDataSize = (int)havokDataSizeLong;
|
||||
|
||||
reader.BaseStream.Position = havokPosition;
|
||||
|
||||
var havokData = new byte[havokDataSize];
|
||||
var bytesRead = reader.Read(havokData, 0, havokDataSize);
|
||||
if (bytesRead != havokDataSize)
|
||||
{
|
||||
_logger.LogWarning("PAP file {hash}: Expected to read {expected} bytes but got {actual}",
|
||||
hash, havokDataSize, bytesRead);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (havokData.Length < 8)
|
||||
return null;
|
||||
|
||||
var tempSets = new Dictionary<string, HashSet<ushort>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var tempFileName = $"lightless_pap_{Guid.NewGuid():N}_{hash.Substring(0, Math.Min(8, hash.Length))}.hkx";
|
||||
var tempHavokDataPath = Path.Combine(Path.GetTempPath(), tempFileName);
|
||||
IntPtr tempHavokDataPathAnsi = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
var tempDir = Path.GetDirectoryName(tempHavokDataPath);
|
||||
if (!Directory.Exists(tempDir))
|
||||
{
|
||||
var animContainer = (hkaAnimationContainer*)container->findObjectByName(n2, null);
|
||||
if (animContainer == null)
|
||||
return null;
|
||||
_logger.LogWarning("Temp directory {dir} doesn't exist", tempDir);
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < animContainer->Bindings.Length; i++)
|
||||
File.WriteAllBytes(tempHavokDataPath, havokData);
|
||||
|
||||
if (!File.Exists(tempHavokDataPath))
|
||||
{
|
||||
_logger.LogWarning("Temporary havok file was not created at {path}", tempHavokDataPath);
|
||||
return null;
|
||||
}
|
||||
|
||||
var writtenFileInfo = new FileInfo(tempHavokDataPath);
|
||||
if (writtenFileInfo.Length != havokData.Length)
|
||||
{
|
||||
_logger.LogWarning("Written temp file size mismatch: expected {expected}, got {actual}",
|
||||
havokData.Length, writtenFileInfo.Length);
|
||||
File.Delete(tempHavokDataPath);
|
||||
return null;
|
||||
}
|
||||
|
||||
tempHavokDataPathAnsi = Marshal.StringToHGlobalAnsi(tempHavokDataPath);
|
||||
|
||||
var loadoptions = stackalloc hkSerializeUtil.LoadOptions[1];
|
||||
loadoptions->TypeInfoRegistry = hkBuiltinTypeRegistry.Instance()->GetTypeInfoRegistry();
|
||||
loadoptions->ClassNameRegistry = hkBuiltinTypeRegistry.Instance()->GetClassNameRegistry();
|
||||
loadoptions->Flags = new hkFlags<hkSerializeUtil.LoadOptionBits, int>
|
||||
{
|
||||
Storage = (int)hkSerializeUtil.LoadOptionBits.Default
|
||||
};
|
||||
|
||||
hkResource* resource = null;
|
||||
try
|
||||
{
|
||||
resource = hkSerializeUtil.LoadFromFile((byte*)tempHavokDataPathAnsi, null, loadoptions);
|
||||
}
|
||||
catch (SEHException ex)
|
||||
{
|
||||
_logger.LogError(ex, "SEH exception loading Havok file from {path} (hash={hash}). Native error code: 0x{code:X}",
|
||||
tempHavokDataPath, hash, ex.ErrorCode);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (resource == null)
|
||||
{
|
||||
_logger.LogDebug("Havok resource was null after loading from {path} (hash={hash})", tempHavokDataPath, hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ((nint)resource == nint.Zero || !IsValidPointer((IntPtr)resource))
|
||||
{
|
||||
_logger.LogDebug("Havok resource pointer is invalid (hash={hash})", hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
var rootLevelName = @"hkRootLevelContainer"u8;
|
||||
fixed (byte* n1 = rootLevelName)
|
||||
{
|
||||
var container = (hkRootLevelContainer*)resource->GetContentsPointer(n1, hkBuiltinTypeRegistry.Instance()->GetTypeInfoRegistry());
|
||||
if (container == null)
|
||||
{
|
||||
var binding = animContainer->Bindings[i].ptr;
|
||||
if (binding == null)
|
||||
continue;
|
||||
_logger.LogDebug("hkRootLevelContainer is null (hash={hash})", hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
var rawSkel = binding->OriginalSkeletonName.String;
|
||||
var skeletonKey = CanonicalizeSkeletonKey(rawSkel);
|
||||
if (string.IsNullOrEmpty(skeletonKey))
|
||||
continue;
|
||||
if ((nint)container == nint.Zero || !IsValidPointer((IntPtr)container))
|
||||
{
|
||||
_logger.LogDebug("hkRootLevelContainer pointer is invalid (hash={hash})", hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
var boneTransform = binding->TransformTrackToBoneIndices;
|
||||
if (boneTransform.Length <= 0)
|
||||
continue;
|
||||
|
||||
if (!tempSets.TryGetValue(skeletonKey, out var set))
|
||||
var animationName = @"hkaAnimationContainer"u8;
|
||||
fixed (byte* n2 = animationName)
|
||||
{
|
||||
var animContainer = (hkaAnimationContainer*)container->findObjectByName(n2, null);
|
||||
if (animContainer == null)
|
||||
{
|
||||
set = [];
|
||||
tempSets[skeletonKey] = set;
|
||||
_logger.LogDebug("hkaAnimationContainer is null (hash={hash})", hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int boneIdx = 0; boneIdx < boneTransform.Length; boneIdx++)
|
||||
if ((nint)animContainer == nint.Zero || !IsValidPointer((IntPtr)animContainer))
|
||||
{
|
||||
var v = boneTransform[boneIdx];
|
||||
if (v < 0) continue;
|
||||
set.Add((ushort)v);
|
||||
_logger.LogDebug("hkaAnimationContainer pointer is invalid (hash={hash})", hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (animContainer->Bindings.Length < 0 || animContainer->Bindings.Length > 10000)
|
||||
{
|
||||
_logger.LogDebug("Invalid bindings count {count} (hash={hash})", animContainer->Bindings.Length, hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < animContainer->Bindings.Length; i++)
|
||||
{
|
||||
var binding = animContainer->Bindings[i].ptr;
|
||||
if (binding == null)
|
||||
continue;
|
||||
|
||||
if ((nint)binding == nint.Zero || !IsValidPointer((IntPtr)binding))
|
||||
{
|
||||
_logger.LogDebug("Skipping invalid binding at index {index} (hash={hash})", i, hash);
|
||||
continue;
|
||||
}
|
||||
|
||||
var rawSkel = binding->OriginalSkeletonName.String;
|
||||
var skeletonKey = CanonicalizeSkeletonKey(rawSkel);
|
||||
if (string.IsNullOrEmpty(skeletonKey))
|
||||
continue;
|
||||
|
||||
var boneTransform = binding->TransformTrackToBoneIndices;
|
||||
if (boneTransform.Length <= 0 || boneTransform.Length > 10000)
|
||||
{
|
||||
_logger.LogDebug("Invalid bone transform length {length} for skeleton {skel} (hash={hash})",
|
||||
boneTransform.Length, skeletonKey, hash);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!tempSets.TryGetValue(skeletonKey, out var set))
|
||||
{
|
||||
set = [];
|
||||
tempSets[skeletonKey] = set;
|
||||
}
|
||||
|
||||
for (int boneIdx = 0; boneIdx < boneTransform.Length; boneIdx++)
|
||||
{
|
||||
var v = boneTransform[boneIdx];
|
||||
if (v < 0 || v > ushort.MaxValue)
|
||||
continue;
|
||||
set.Add((ushort)v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Could not load havok file in {path}", tempHavokDataPath);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (tempHavokDataPathAnsi != IntPtr.Zero)
|
||||
Marshal.FreeHGlobal(tempHavokDataPathAnsi);
|
||||
|
||||
try
|
||||
catch (SEHException ex)
|
||||
{
|
||||
if (File.Exists(tempHavokDataPath))
|
||||
File.Delete(tempHavokDataPath);
|
||||
_logger.LogError(ex, "SEH exception processing PAP file {hash} from {path}. Error code: 0x{code:X}",
|
||||
hash, tempHavokDataPath, ex.ErrorCode);
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogTrace(ex, "Could not delete temporary havok file: {path}", tempHavokDataPath);
|
||||
_logger.LogError(ex, "Managed exception loading havok file {hash} from {path}", hash, tempHavokDataPath);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (tempHavokDataPathAnsi != IntPtr.Zero)
|
||||
Marshal.FreeHGlobal(tempHavokDataPathAnsi);
|
||||
|
||||
int retryCount = 3;
|
||||
while (retryCount > 0 && File.Exists(tempHavokDataPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(tempHavokDataPath);
|
||||
break;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
retryCount--;
|
||||
if (retryCount == 0)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed to delete temporary havok file after retries: {path}", tempHavokDataPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "Unexpected error deleting temporary havok file: {path}", tempHavokDataPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tempSets.Count == 0)
|
||||
{
|
||||
_logger.LogDebug("No bone sets found in PAP file (hash={hash})", hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
var output = new Dictionary<string, List<ushort>>(tempSets.Count, StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var (key, set) in tempSets)
|
||||
{
|
||||
if (set.Count == 0) continue;
|
||||
|
||||
var list = set.ToList();
|
||||
list.Sort();
|
||||
output[key] = list;
|
||||
}
|
||||
|
||||
if (output.Count == 0)
|
||||
return null;
|
||||
|
||||
_configService.Current.BonesDictionary[hash] = output;
|
||||
|
||||
if (persistToConfig)
|
||||
_configService.Save();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
if (tempSets.Count == 0)
|
||||
return null;
|
||||
|
||||
var output = new Dictionary<string, List<ushort>>(tempSets.Count, StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var (key, set) in tempSets)
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (set.Count == 0) continue;
|
||||
|
||||
var list = set.ToList();
|
||||
list.Sort();
|
||||
output[key] = list;
|
||||
}
|
||||
|
||||
if (output.Count == 0)
|
||||
_logger.LogError(ex, "Outer exception reading PAP file (hash={hash})", hash);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
_configService.Current.BonesDictionary[hash] = output;
|
||||
private static bool IsValidPointer(IntPtr ptr)
|
||||
{
|
||||
if (ptr == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
if (persistToConfig)
|
||||
_configService.Save();
|
||||
|
||||
return output;
|
||||
try
|
||||
{
|
||||
_ = Marshal.ReadByte(ptr);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ using Dalamud.Utility;
|
||||
using LightlessSync.FileCache;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.LightlessConfiguration.Models;
|
||||
using LightlessSync.Localization;
|
||||
using LightlessSync.Services;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.Services.ServerConfiguration;
|
||||
using LightlessSync.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -21,7 +21,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
private readonly LightlessConfigService _configService;
|
||||
private readonly CacheMonitor _cacheMonitor;
|
||||
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
|
||||
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" }, { "中文", "zh"} };
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly DalamudUtilService _dalamudUtilService;
|
||||
private readonly UiSharedService _uiShared;
|
||||
@@ -31,7 +31,6 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
private string _secretKey = string.Empty;
|
||||
private string _timeoutLabel = string.Empty;
|
||||
private Task? _timeoutTask;
|
||||
private string[]? _tosParagraphs;
|
||||
private bool _useLegacyLogin = false;
|
||||
|
||||
public IntroUi(ILogger<IntroUi> logger, UiSharedService uiShared, LightlessConfigService configService,
|
||||
@@ -50,8 +49,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
WindowBuilder.For(this)
|
||||
.SetSizeConstraints(new Vector2(600, 400), new Vector2(600, 2000))
|
||||
.Apply();
|
||||
|
||||
GetToSLocalization();
|
||||
|
||||
|
||||
Mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = false);
|
||||
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) =>
|
||||
@@ -88,7 +86,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
for (int i = 60; i > 0; i--)
|
||||
{
|
||||
_timeoutLabel = $"{Strings.ToS.ButtonWillBeAvailableIn} {i}s";
|
||||
_timeoutLabel = $"{Resources.Resources.ToSStrings_ButtonWillBeAvailableIn} {i}s";
|
||||
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
@@ -102,44 +100,46 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
Vector2 textSize;
|
||||
using (_uiShared.UidFont.Push())
|
||||
{
|
||||
textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
|
||||
ImGui.TextUnformatted(Strings.ToS.AgreementLabel);
|
||||
textSize = ImGui.CalcTextSize(Resources.Resources.ToSStrings_LanguageLabel);
|
||||
ImGui.TextUnformatted(Resources.Resources.ToSStrings_AgreementLabel);
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
var languageSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
|
||||
var languageSize = ImGui.CalcTextSize(Resources.Resources.ToSStrings_LanguageLabel);
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - languageSize.X - 80);
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - languageSize.Y / 2);
|
||||
|
||||
ImGui.TextUnformatted(Strings.ToS.LanguageLabel);
|
||||
ImGui.TextUnformatted(Resources.Resources.ToSStrings_LanguageLabel);
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - (languageSize.Y + ImGui.GetStyle().FramePadding.Y) / 2);
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.Combo("", ref _currentLanguage, _languages.Keys.ToArray(), _languages.Count))
|
||||
{
|
||||
GetToSLocalization(_currentLanguage);
|
||||
var culture = new CultureInfo(_languages.Values.ToArray()[_currentLanguage]);
|
||||
CultureInfo.DefaultThreadCurrentCulture = culture;
|
||||
CultureInfo.DefaultThreadCurrentUICulture = culture;
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.SetWindowFontScale(1.5f);
|
||||
string readThis = Strings.ToS.ReadLabel;
|
||||
string readThis = Resources.Resources.ToSStrings_ReadLabel;
|
||||
textSize = ImGui.CalcTextSize(readThis);
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowSize().X / 2 - textSize.X / 2);
|
||||
UiSharedService.ColorText(readThis, ImGuiColors.DalamudRed);
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
ImGui.Separator();
|
||||
|
||||
UiSharedService.TextWrapped(_tosParagraphs![0]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![1]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![2]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![3]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![4]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![5]);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph1);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph2);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph3);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph4);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph5);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph6);
|
||||
|
||||
ImGui.Separator();
|
||||
if (_timeoutTask?.IsCompleted ?? true)
|
||||
{
|
||||
if (ImGui.Button(Strings.ToS.AgreeLabel + "##toSetup"))
|
||||
if (ImGui.Button(Resources.Resources.ToSStrings_AgreeLabel + "##toSetup"))
|
||||
{
|
||||
_configService.Current.AcceptedAgreement = true;
|
||||
_configService.Save();
|
||||
@@ -349,16 +349,6 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
private void GetToSLocalization(int changeLanguageTo = -1)
|
||||
{
|
||||
if (changeLanguageTo != -1)
|
||||
{
|
||||
_uiShared.LoadLocalization(_languages.ElementAt(changeLanguageTo).Value);
|
||||
}
|
||||
|
||||
_tosParagraphs = [Strings.ToS.Paragraph1, Strings.ToS.Paragraph2, Strings.ToS.Paragraph3, Strings.ToS.Paragraph4, Strings.ToS.Paragraph5, Strings.ToS.Paragraph6];
|
||||
}
|
||||
|
||||
[GeneratedRegex("^[A-F0-9]{64}$", RegexOptions.Compiled | RegexOptions.CultureInvariant)]
|
||||
private static partial Regex SecretRegex();
|
||||
}
|
||||
@@ -4812,7 +4812,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
ImGui.TextColored(UIColors.Get("LightlessBlue"),
|
||||
_apiController.OnlineUsers.ToString(CultureInfo.InvariantCulture));
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted("Users Online");
|
||||
ImGui.TextUnformatted(Resources.Resources.Users_Online);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(")");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ using LightlessSync.Interop.Ipc;
|
||||
using LightlessSync.Interop.Ipc.Framework;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.LightlessConfiguration.Models;
|
||||
using LightlessSync.Localization;
|
||||
using LightlessSync.PlayerData.Pairs;
|
||||
using LightlessSync.Services;
|
||||
using LightlessSync.Services.Mediator;
|
||||
@@ -1468,12 +1467,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
return false;
|
||||
}
|
||||
|
||||
public void LoadLocalization(string languageCode)
|
||||
{
|
||||
_localization.SetupWithLangCode(languageCode);
|
||||
Strings.ToS = new Strings.ToSStrings();
|
||||
}
|
||||
|
||||
internal static void DistanceSeparator()
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
||||
@@ -22,7 +22,6 @@ using LightlessSync.UI.Services;
|
||||
using LightlessSync.UI.Style;
|
||||
using LightlessSync.Utils;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using OtterGui.Text;
|
||||
using LightlessSync.WebAPI;
|
||||
using LightlessSync.WebAPI.SignalR.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -429,150 +428,182 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
else
|
||||
{
|
||||
var itemHeight = ImGui.GetTextLineHeightWithSpacing();
|
||||
using var clipper = ImUtf8.ListClipper(channel.Messages.Count, itemHeight);
|
||||
while (clipper.Step())
|
||||
var messageCount = channel.Messages.Count;
|
||||
var contentMaxX = ImGui.GetWindowContentRegionMax().X;
|
||||
var cursorStartX = ImGui.GetCursorPosX();
|
||||
var lineHeightWithSpacing = ImGui.GetTextLineHeightWithSpacing();
|
||||
var prefix = new float[messageCount + 1];
|
||||
var totalHeight = 0f;
|
||||
|
||||
for (var i = 0; i < messageCount; i++)
|
||||
{
|
||||
for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||
var messageHeight = MeasureMessageHeight(channel, channel.Messages[i], showTimestamps, cursorStartX, contentMaxX, itemSpacing, ref pairSnapshot);
|
||||
if (messageHeight <= 0f)
|
||||
{
|
||||
var message = channel.Messages[i];
|
||||
ImGui.PushID(i);
|
||||
messageHeight = lineHeightWithSpacing;
|
||||
}
|
||||
|
||||
if (message.IsSystem)
|
||||
totalHeight += messageHeight;
|
||||
prefix[i + 1] = totalHeight;
|
||||
}
|
||||
|
||||
var scrollY = ImGui.GetScrollY();
|
||||
var windowHeight = ImGui.GetWindowHeight();
|
||||
var startIndex = Math.Max(0, UpperBound(prefix, scrollY) - 1);
|
||||
var endIndex = Math.Min(messageCount, LowerBound(prefix, scrollY + windowHeight));
|
||||
startIndex = Math.Max(0, startIndex - 2);
|
||||
endIndex = Math.Min(messageCount, endIndex + 2);
|
||||
|
||||
if (startIndex > 0)
|
||||
{
|
||||
ImGui.Dummy(new Vector2(1f, prefix[startIndex]));
|
||||
}
|
||||
|
||||
for (var i = startIndex; i < endIndex; 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)
|
||||
{
|
||||
timestampText = $"[{message.ReceivedAtUtc.ToLocalTime().ToString("HH:mm", CultureInfo.InvariantCulture)}] ";
|
||||
}
|
||||
var color = message.FromSelf ? UIColors.Get("LightlessBlue") : ImGuiColors.DalamudWhite;
|
||||
var showRoleIcons = false;
|
||||
var isOwner = false;
|
||||
var isModerator = false;
|
||||
var isPinned = false;
|
||||
|
||||
if (channel.Type == ChatChannelType.Group
|
||||
&& payload.Sender.Kind == ChatSenderKind.IdentifiedUser
|
||||
&& payload.Sender.User is not null)
|
||||
{
|
||||
pairSnapshot ??= _pairUiService.GetSnapshot();
|
||||
var groupId = channel.Descriptor.CustomKey;
|
||||
if (!string.IsNullOrWhiteSpace(groupId)
|
||||
&& pairSnapshot.GroupsByGid.TryGetValue(groupId, out var groupInfo))
|
||||
{
|
||||
DrawSystemEntry(message);
|
||||
ImGui.PopID();
|
||||
continue;
|
||||
var senderUid = payload.Sender.User.UID;
|
||||
isOwner = string.Equals(senderUid, groupInfo.OwnerUID, StringComparison.Ordinal);
|
||||
if (groupInfo.GroupPairUserInfos.TryGetValue(senderUid, out var info))
|
||||
{
|
||||
isModerator = info.IsModerator();
|
||||
isPinned = info.IsPinned();
|
||||
}
|
||||
}
|
||||
|
||||
if (message.Payload is not { } payload)
|
||||
showRoleIcons = isOwner || isModerator || isPinned;
|
||||
}
|
||||
|
||||
ImGui.BeginGroup();
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, color);
|
||||
if (showRoleIcons)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(timestampText))
|
||||
{
|
||||
ImGui.PopID();
|
||||
continue;
|
||||
ImGui.TextUnformatted(timestampText);
|
||||
ImGui.SameLine(0f, 0f);
|
||||
}
|
||||
|
||||
var timestampText = string.Empty;
|
||||
if (showTimestamps)
|
||||
var hasIcon = false;
|
||||
if (isModerator)
|
||||
{
|
||||
timestampText = $"[{message.ReceivedAtUtc.ToLocalTime().ToString("HH:mm", CultureInfo.InvariantCulture)}] ";
|
||||
}
|
||||
var color = message.FromSelf ? UIColors.Get("LightlessBlue") : ImGuiColors.DalamudWhite;
|
||||
var showRoleIcons = false;
|
||||
var isOwner = false;
|
||||
var isModerator = false;
|
||||
var isPinned = false;
|
||||
|
||||
if (channel.Type == ChatChannelType.Group
|
||||
&& payload.Sender.Kind == ChatSenderKind.IdentifiedUser
|
||||
&& payload.Sender.User is not null)
|
||||
{
|
||||
pairSnapshot ??= _pairUiService.GetSnapshot();
|
||||
var groupId = channel.Descriptor.CustomKey;
|
||||
if (!string.IsNullOrWhiteSpace(groupId)
|
||||
&& pairSnapshot.GroupsByGid.TryGetValue(groupId, out var groupInfo))
|
||||
{
|
||||
var senderUid = payload.Sender.User.UID;
|
||||
isOwner = string.Equals(senderUid, groupInfo.OwnerUID, StringComparison.Ordinal);
|
||||
if (groupInfo.GroupPairUserInfos.TryGetValue(senderUid, out var info))
|
||||
{
|
||||
isModerator = info.IsModerator();
|
||||
isPinned = info.IsPinned();
|
||||
}
|
||||
}
|
||||
|
||||
showRoleIcons = isOwner || isModerator || isPinned;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.UserShield, UIColors.Get("LightlessPurple"));
|
||||
UiSharedService.AttachToolTip("Moderator");
|
||||
hasIcon = true;
|
||||
}
|
||||
|
||||
ImGui.BeginGroup();
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, color);
|
||||
if (showRoleIcons)
|
||||
if (isOwner)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(timestampText))
|
||||
{
|
||||
ImGui.TextUnformatted(timestampText);
|
||||
ImGui.SameLine(0f, 0f);
|
||||
}
|
||||
|
||||
var hasIcon = false;
|
||||
if (isModerator)
|
||||
{
|
||||
_uiSharedService.IconText(FontAwesomeIcon.UserShield, UIColors.Get("LightlessPurple"));
|
||||
UiSharedService.AttachToolTip("Moderator");
|
||||
hasIcon = true;
|
||||
}
|
||||
|
||||
if (isOwner)
|
||||
{
|
||||
if (hasIcon)
|
||||
{
|
||||
ImGui.SameLine(0f, itemSpacing);
|
||||
}
|
||||
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Crown, UIColors.Get("LightlessYellow"));
|
||||
UiSharedService.AttachToolTip("Owner");
|
||||
hasIcon = true;
|
||||
}
|
||||
|
||||
if (isPinned)
|
||||
{
|
||||
if (hasIcon)
|
||||
{
|
||||
ImGui.SameLine(0f, itemSpacing);
|
||||
}
|
||||
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Thumbtack, UIColors.Get("LightlessBlue"));
|
||||
UiSharedService.AttachToolTip("Pinned");
|
||||
hasIcon = true;
|
||||
}
|
||||
|
||||
if (hasIcon)
|
||||
{
|
||||
ImGui.SameLine(0f, itemSpacing);
|
||||
}
|
||||
|
||||
var messageStartX = ImGui.GetCursorPosX();
|
||||
DrawChatMessageWithEmotes($"{message.DisplayName}: ", payload.Message, messageStartX);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Crown, UIColors.Get("LightlessYellow"));
|
||||
UiSharedService.AttachToolTip("Owner");
|
||||
hasIcon = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var messageStartX = ImGui.GetCursorPosX();
|
||||
DrawChatMessageWithEmotes($"{timestampText}{message.DisplayName}: ", payload.Message, messageStartX);
|
||||
}
|
||||
ImGui.PopStyleColor();
|
||||
ImGui.EndGroup();
|
||||
|
||||
ImGui.SetNextWindowSizeConstraints(
|
||||
new Vector2(190f * ImGuiHelpers.GlobalScale, 0f),
|
||||
new Vector2(float.MaxValue, float.MaxValue));
|
||||
if (ImGui.BeginPopupContextItem($"chat_msg_ctx##{channel.Key}_{i}"))
|
||||
if (isPinned)
|
||||
{
|
||||
var contextLocalTimestamp = payload.SentAtUtc.ToLocalTime();
|
||||
var contextTimestampText = contextLocalTimestamp.ToString("yyyy-MM-dd HH:mm:ss 'UTC'z", CultureInfo.InvariantCulture);
|
||||
ImGui.TextDisabled(contextTimestampText);
|
||||
if (channel.Type == ChatChannelType.Group
|
||||
&& payload.Sender.Kind == ChatSenderKind.IdentifiedUser
|
||||
&& payload.Sender.User is not null)
|
||||
if (hasIcon)
|
||||
{
|
||||
var aliasOrUid = payload.Sender.User.AliasOrUID;
|
||||
if (!string.IsNullOrWhiteSpace(aliasOrUid)
|
||||
&& !string.Equals(message.DisplayName, aliasOrUid, StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.TextDisabled(aliasOrUid);
|
||||
}
|
||||
}
|
||||
ImGui.Separator();
|
||||
|
||||
var actionIndex = 0;
|
||||
foreach (var action in GetContextMenuActions(channel, message))
|
||||
{
|
||||
DrawContextMenuAction(action, actionIndex++);
|
||||
ImGui.SameLine(0f, itemSpacing);
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Thumbtack, UIColors.Get("LightlessBlue"));
|
||||
UiSharedService.AttachToolTip("Pinned");
|
||||
hasIcon = true;
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
if (hasIcon)
|
||||
{
|
||||
ImGui.SameLine(0f, itemSpacing);
|
||||
}
|
||||
|
||||
var messageStartX = ImGui.GetCursorPosX();
|
||||
DrawChatMessageWithEmotes($"{message.DisplayName}: ", payload.Message, messageStartX);
|
||||
}
|
||||
else
|
||||
{
|
||||
var messageStartX = ImGui.GetCursorPosX();
|
||||
DrawChatMessageWithEmotes($"{timestampText}{message.DisplayName}: ", payload.Message, messageStartX);
|
||||
}
|
||||
ImGui.PopStyleColor();
|
||||
ImGui.EndGroup();
|
||||
|
||||
ImGui.SetNextWindowSizeConstraints(
|
||||
new Vector2(190f * ImGuiHelpers.GlobalScale, 0f),
|
||||
new Vector2(float.MaxValue, float.MaxValue));
|
||||
if (ImGui.BeginPopupContextItem($"chat_msg_ctx##{channel.Key}_{i}"))
|
||||
{
|
||||
var contextLocalTimestamp = payload.SentAtUtc.ToLocalTime();
|
||||
var contextTimestampText = contextLocalTimestamp.ToString("yyyy-MM-dd HH:mm:ss 'UTC'z", CultureInfo.InvariantCulture);
|
||||
ImGui.TextDisabled(contextTimestampText);
|
||||
if (channel.Type == ChatChannelType.Group
|
||||
&& payload.Sender.Kind == ChatSenderKind.IdentifiedUser
|
||||
&& payload.Sender.User is not null)
|
||||
{
|
||||
var aliasOrUid = payload.Sender.User.AliasOrUID;
|
||||
if (!string.IsNullOrWhiteSpace(aliasOrUid)
|
||||
&& !string.Equals(message.DisplayName, aliasOrUid, StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.TextDisabled(aliasOrUid);
|
||||
}
|
||||
}
|
||||
ImGui.Separator();
|
||||
|
||||
var actionIndex = 0;
|
||||
foreach (var action in GetContextMenuActions(channel, message))
|
||||
{
|
||||
DrawContextMenuAction(action, actionIndex++);
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
var remainingHeight = totalHeight - prefix[endIndex];
|
||||
if (remainingHeight > 0f)
|
||||
{
|
||||
ImGui.Dummy(new Vector2(1f, remainingHeight));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,7 +739,20 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
var clicked = false;
|
||||
if (texture is not null)
|
||||
{
|
||||
clicked = ImGui.ImageButton(texture.Handle, new Vector2(emoteSize));
|
||||
var buttonSize = new Vector2(itemWidth, itemHeight);
|
||||
clicked = ImGui.InvisibleButton("##emote_button", buttonSize);
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
var itemMin = ImGui.GetItemRectMin();
|
||||
var itemMax = ImGui.GetItemRectMax();
|
||||
var bgColor = ImGui.IsItemActive()
|
||||
? ImGui.GetColorU32(ImGuiCol.ButtonActive)
|
||||
: ImGui.IsItemHovered()
|
||||
? ImGui.GetColorU32(ImGuiCol.ButtonHovered)
|
||||
: ImGui.GetColorU32(ImGuiCol.Button);
|
||||
drawList.AddRectFilled(itemMin, itemMax, bgColor, style.FrameRounding);
|
||||
var imageMin = itemMin + style.FramePadding;
|
||||
var imageMax = imageMin + new Vector2(emoteSize);
|
||||
drawList.AddImage(texture.Handle, imageMin, imageMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -878,7 +922,232 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
|
||||
private static bool IsEmoteChar(char value)
|
||||
{
|
||||
return char.IsLetterOrDigit(value) || value == '_' || value == '-' || value == '!';
|
||||
return char.IsLetterOrDigit(value) || value == '_' || value == '-' || value == '!' || value == '(' || value == ')';
|
||||
}
|
||||
|
||||
private float MeasureMessageHeight(
|
||||
ChatChannelSnapshot channel,
|
||||
ChatMessageEntry message,
|
||||
bool showTimestamps,
|
||||
float cursorStartX,
|
||||
float contentMaxX,
|
||||
float itemSpacing,
|
||||
ref PairUiSnapshot? pairSnapshot)
|
||||
{
|
||||
if (message.IsSystem)
|
||||
{
|
||||
return MeasureSystemEntryHeight(message);
|
||||
}
|
||||
|
||||
if (message.Payload is not { } payload)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
var timestampText = string.Empty;
|
||||
if (showTimestamps)
|
||||
{
|
||||
timestampText = $"[{message.ReceivedAtUtc.ToLocalTime().ToString("HH:mm", CultureInfo.InvariantCulture)}] ";
|
||||
}
|
||||
|
||||
var showRoleIcons = false;
|
||||
var isOwner = false;
|
||||
var isModerator = false;
|
||||
var isPinned = false;
|
||||
|
||||
if (channel.Type == ChatChannelType.Group
|
||||
&& payload.Sender.Kind == ChatSenderKind.IdentifiedUser
|
||||
&& payload.Sender.User is not null)
|
||||
{
|
||||
pairSnapshot ??= _pairUiService.GetSnapshot();
|
||||
var groupId = channel.Descriptor.CustomKey;
|
||||
if (!string.IsNullOrWhiteSpace(groupId)
|
||||
&& pairSnapshot.GroupsByGid.TryGetValue(groupId, out var groupInfo))
|
||||
{
|
||||
var senderUid = payload.Sender.User.UID;
|
||||
isOwner = string.Equals(senderUid, groupInfo.OwnerUID, StringComparison.Ordinal);
|
||||
if (groupInfo.GroupPairUserInfos.TryGetValue(senderUid, out var info))
|
||||
{
|
||||
isModerator = info.IsModerator();
|
||||
isPinned = info.IsPinned();
|
||||
}
|
||||
}
|
||||
|
||||
showRoleIcons = isOwner || isModerator || isPinned;
|
||||
}
|
||||
|
||||
var lineStartX = cursorStartX;
|
||||
string prefix;
|
||||
if (showRoleIcons)
|
||||
{
|
||||
lineStartX += MeasureRolePrefixWidth(timestampText, isOwner, isModerator, isPinned, itemSpacing);
|
||||
prefix = $"{message.DisplayName}: ";
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix = $"{timestampText}{message.DisplayName}: ";
|
||||
}
|
||||
|
||||
var lines = MeasureChatMessageLines(prefix, payload.Message, lineStartX, contentMaxX);
|
||||
return Math.Max(1, lines) * ImGui.GetTextLineHeightWithSpacing();
|
||||
}
|
||||
|
||||
private int MeasureChatMessageLines(string prefix, string message, float lineStartX, float contentMaxX)
|
||||
{
|
||||
var segments = BuildChatSegments(prefix, message);
|
||||
if (segments.Count == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var emoteWidth = ImGui.GetTextLineHeight();
|
||||
var availableWidth = Math.Max(1f, contentMaxX - lineStartX);
|
||||
var remainingWidth = availableWidth;
|
||||
var firstOnLine = true;
|
||||
var lines = 1;
|
||||
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
if (segment.IsLineBreak)
|
||||
{
|
||||
lines++;
|
||||
firstOnLine = true;
|
||||
remainingWidth = availableWidth;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (segment.IsWhitespace && firstOnLine)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var segmentWidth = segment.IsEmote ? emoteWidth : ImGui.CalcTextSize(segment.Text).X;
|
||||
if (!firstOnLine)
|
||||
{
|
||||
if (segmentWidth > remainingWidth)
|
||||
{
|
||||
lines++;
|
||||
firstOnLine = true;
|
||||
remainingWidth = availableWidth;
|
||||
if (segment.IsWhitespace)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remainingWidth -= segmentWidth;
|
||||
firstOnLine = false;
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private float MeasureRolePrefixWidth(string timestampText, bool isOwner, bool isModerator, bool isPinned, float itemSpacing)
|
||||
{
|
||||
var width = 0f;
|
||||
|
||||
if (!string.IsNullOrEmpty(timestampText))
|
||||
{
|
||||
width += ImGui.CalcTextSize(timestampText).X;
|
||||
}
|
||||
|
||||
var hasIcon = false;
|
||||
if (isModerator)
|
||||
{
|
||||
width += MeasureIconWidth(FontAwesomeIcon.UserShield);
|
||||
hasIcon = true;
|
||||
}
|
||||
|
||||
if (isOwner)
|
||||
{
|
||||
if (hasIcon)
|
||||
{
|
||||
width += itemSpacing;
|
||||
}
|
||||
|
||||
width += MeasureIconWidth(FontAwesomeIcon.Crown);
|
||||
hasIcon = true;
|
||||
}
|
||||
|
||||
if (isPinned)
|
||||
{
|
||||
if (hasIcon)
|
||||
{
|
||||
width += itemSpacing;
|
||||
}
|
||||
|
||||
width += MeasureIconWidth(FontAwesomeIcon.Thumbtack);
|
||||
hasIcon = true;
|
||||
}
|
||||
|
||||
if (hasIcon)
|
||||
{
|
||||
width += itemSpacing;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
private float MeasureIconWidth(FontAwesomeIcon icon)
|
||||
{
|
||||
using var font = _uiSharedService.IconFont.Push();
|
||||
return ImGui.CalcTextSize(icon.ToIconString()).X;
|
||||
}
|
||||
|
||||
private float MeasureSystemEntryHeight(ChatMessageEntry entry)
|
||||
{
|
||||
_ = entry;
|
||||
var spacing = ImGui.GetStyle().ItemSpacing.Y;
|
||||
var lineHeightWithSpacing = ImGui.GetTextLineHeightWithSpacing();
|
||||
var separatorHeight = Math.Max(1f, ImGuiHelpers.GlobalScale);
|
||||
|
||||
var height = spacing;
|
||||
height += lineHeightWithSpacing;
|
||||
height += spacing * 0.35f;
|
||||
height += separatorHeight;
|
||||
height += spacing;
|
||||
return height;
|
||||
}
|
||||
|
||||
private static int LowerBound(float[] values, float target)
|
||||
{
|
||||
var low = 0;
|
||||
var high = values.Length;
|
||||
while (low < high)
|
||||
{
|
||||
var mid = (low + high) / 2;
|
||||
if (values[mid] < target)
|
||||
{
|
||||
low = mid + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
high = mid;
|
||||
}
|
||||
}
|
||||
|
||||
return low;
|
||||
}
|
||||
|
||||
private static int UpperBound(float[] values, float target)
|
||||
{
|
||||
var low = 0;
|
||||
var high = values.Length;
|
||||
while (low < high)
|
||||
{
|
||||
var mid = (low + high) / 2;
|
||||
if (values[mid] <= target)
|
||||
{
|
||||
low = mid + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
high = mid;
|
||||
}
|
||||
}
|
||||
|
||||
return low;
|
||||
}
|
||||
|
||||
private void DrawEmoteTooltip(string name, IDalamudTextureWrap? texture)
|
||||
@@ -2092,6 +2361,17 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
ImGui.SetTooltip("When enabled, your notes replace user names in syncshell chat.");
|
||||
}
|
||||
|
||||
var enableAnimatedEmotes = chatConfig.EnableAnimatedEmotes;
|
||||
if (ImGui.Checkbox("Enable animated emotes", ref enableAnimatedEmotes))
|
||||
{
|
||||
chatConfig.EnableAnimatedEmotes = enableAnimatedEmotes;
|
||||
_chatConfigService.Save();
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("When disabled, emotes render as static images.");
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.TextUnformatted("Chat Visibility");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user