Smoothed download bar, fixed many warnings

This commit is contained in:
cake
2025-11-17 04:06:20 +01:00
parent f3a6c7b5b9
commit 1615f2433b
19 changed files with 181 additions and 141 deletions

View File

@@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 18
VisualStudioVersion = 17.1.32328.378 VisualStudioVersion = 18.0.11205.157
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{585B740D-BA2C-429B-9CF3-B2D223423748}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{585B740D-BA2C-429B-9CF3-B2D223423748}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
@@ -22,24 +22,24 @@ Global
Release|x64 = Release|x64 Release|x64 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|Any CPU.ActiveCfg = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|Any CPU.ActiveCfg = Debug|x64
{BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|Any CPU.Build.0 = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|Any CPU.Build.0 = Debug|x64
{BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|x64.ActiveCfg = Debug|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|x64.ActiveCfg = Debug|x64
{BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|x64.Build.0 = Debug|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|x64.Build.0 = Debug|x64
{BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|Any CPU.ActiveCfg = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|Any CPU.ActiveCfg = Release|x64
{BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|Any CPU.Build.0 = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|Any CPU.Build.0 = Release|x64
{BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|x64.ActiveCfg = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|x64.ActiveCfg = Release|x64
{BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|x64.Build.0 = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|x64.Build.0 = Release|x64
{A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|Any CPU.ActiveCfg = Release|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|Any CPU.Build.0 = Release|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|x64.ActiveCfg = Debug|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|x64.Build.0 = Debug|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|x64.Build.0 = Debug|Any CPU
{A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|Any CPU.ActiveCfg = Release|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|Any CPU.Build.0 = Release|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|Any CPU.Build.0 = Release|Any CPU
{A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|x64.ActiveCfg = Release|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|x64.ActiveCfg = Release|Any CPU
{A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|x64.Build.0 = Release|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|x64.Build.0 = Release|Any CPU
{C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Debug|Any CPU.ActiveCfg = Debug|x64 {C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Debug|Any CPU.ActiveCfg = Release|x64
{C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Debug|Any CPU.Build.0 = Debug|x64 {C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Debug|Any CPU.Build.0 = Release|x64
{C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Debug|x64.ActiveCfg = Debug|x64 {C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Debug|x64.ActiveCfg = Debug|x64
{C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Debug|x64.Build.0 = Debug|x64 {C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Debug|x64.Build.0 = Debug|x64
{C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Release|Any CPU.ActiveCfg = Release|x64 {C104F6BE-9CC4-9CF7-271C-5C3A1F646601}.Release|Any CPU.ActiveCfg = Release|x64

View File

@@ -72,7 +72,7 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
{ {
while (_dalamudUtil.IsOnFrameworkThread && !token.IsCancellationRequested) while (_dalamudUtil.IsOnFrameworkThread && !token.IsCancellationRequested)
{ {
await Task.Delay(1).ConfigureAwait(false); await Task.Delay(1, token).ConfigureAwait(false);
} }
RecalculateFileCacheSize(token); RecalculateFileCacheSize(token);
@@ -101,8 +101,8 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
} }
record WatcherChange(WatcherChangeTypes ChangeType, string? OldPath = null); record WatcherChange(WatcherChangeTypes ChangeType, string? OldPath = null);
private readonly Dictionary<string, WatcherChange> _watcherChanges = new Dictionary<string, WatcherChange>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, WatcherChange> _watcherChanges = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, WatcherChange> _lightlessChanges = new Dictionary<string, WatcherChange>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, WatcherChange> _lightlessChanges = new(StringComparer.OrdinalIgnoreCase);
public void StopMonitoring() public void StopMonitoring()
{ {
@@ -128,7 +128,7 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
} }
var fsType = FileSystemHelper.GetFilesystemType(_configService.Current.CacheFolder, _dalamudUtil.IsWine); var fsType = FileSystemHelper.GetFilesystemType(_configService.Current.CacheFolder, _dalamudUtil.IsWine);
if (fsType == FileSystemHelper.FilesystemType.NTFS) if (fsType == FileSystemHelper.FilesystemType.NTFS && !_dalamudUtil.IsWine)
{ {
StorageisNTFS = true; StorageisNTFS = true;
Logger.LogInformation("Lightless Storage is on NTFS drive: {isNtfs}", StorageisNTFS); Logger.LogInformation("Lightless Storage is on NTFS drive: {isNtfs}", StorageisNTFS);
@@ -403,54 +403,59 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
public void RecalculateFileCacheSize(CancellationToken token) public void RecalculateFileCacheSize(CancellationToken token)
{ {
if (string.IsNullOrEmpty(_configService.Current.CacheFolder) || var folder = _configService.Current.CacheFolder;
!Directory.Exists(_configService.Current.CacheFolder)) if (string.IsNullOrWhiteSpace(folder) || !Directory.Exists(folder))
{ {
FileCacheSize = 0; FileCacheSize = 0;
return; return;
} }
FileCacheSize = -1; FileCacheSize = -1;
bool isWine = _dalamudUtil?.IsWine ?? false;
try try
{ {
var drive = DriveInfo.GetDrives() var drive = DriveInfo.GetDrives()
.FirstOrDefault(d => _configService.Current.CacheFolder .FirstOrDefault(d => folder.StartsWith(d.Name, StringComparison.OrdinalIgnoreCase));
.StartsWith(d.Name, StringComparison.OrdinalIgnoreCase));
if (drive != null) if (drive != null)
FileCacheDriveFree = drive.AvailableFreeSpace; FileCacheDriveFree = drive.AvailableFreeSpace;
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogWarning(ex, "Could not determine drive size for storage folder {folder}", _configService.Current.CacheFolder); Logger.LogWarning(ex, "Could not determine drive size for storage folder {folder}", folder);
} }
var files = Directory.EnumerateFiles(_configService.Current.CacheFolder) List<FileInfo> files;
.Select(f => new FileInfo(f)) try
.OrderBy(f => f.LastAccessTime) {
.ToList(); files = [.. new DirectoryInfo(folder)
.EnumerateFiles("*", SearchOption.TopDirectoryOnly)
.OrderBy(f => f.LastAccessTimeUtc)];
}
catch (Exception ex)
{
Logger.LogWarning(ex, "Failed to enumerate files in {folder}", folder);
FileCacheSize = 0;
return;
}
long totalSize = 0; var entries = new List<(FileInfo fi, long size)>(files.Count);
long total = 0;
foreach (var f in files) foreach (var f in files)
{ {
token.ThrowIfCancellationRequested(); token.ThrowIfCancellationRequested();
try long size;
{ if (_configService.Current.UseCompactor)
long size = 0;
if (!isWine)
{ {
try try
{ {
size = _fileCompactor.GetFileSizeOnDisk(f); size = _fileCompactor.GetFileSizeOnDisk(f);
if (size < 0) size = f.Length;
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogTrace(ex, "GetFileSizeOnDisk failed for {file}, using fallback length", f.FullName); Logger.LogTrace(ex, "GetFileSizeOnDisk failed for {file}, using Length", f.FullName);
size = f.Length; size = f.Length;
} }
} }
@@ -459,38 +464,38 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
size = f.Length; size = f.Length;
} }
totalSize += size;
entries.Add((f, size));
total += size;
} }
catch (Exception ex)
FileCacheSize = total;
var maxCacheBytes = (long)(_configService.Current.MaxLocalCacheInGiB * 1024d * 1024d * 1024d);
if (FileCacheSize < maxCacheBytes) return;
var buffer = (long)(maxCacheBytes * 0.05d);
var target = maxCacheBytes - buffer;
var i = 0;
while (i < entries.Count && FileCacheSize > target)
{ {
Logger.LogTrace(ex, "Error getting size for {file}", f.FullName); token.ThrowIfCancellationRequested();
}
}
FileCacheSize = totalSize;
var maxCacheInBytes = (long)(_configService.Current.MaxLocalCacheInGiB * 1024d * 1024d * 1024d);
if (FileCacheSize < maxCacheInBytes)
return;
var maxCacheBuffer = maxCacheInBytes * 0.05d;
while (FileCacheSize > maxCacheInBytes - (long)maxCacheBuffer && files.Count > 0)
{
var oldestFile = files[0];
var (fi, sz) = entries[i];
try try
{ {
long fileSize = oldestFile.Length; File.Delete(fi.FullName);
File.Delete(oldestFile.FullName); FileCacheSize -= sz;
FileCacheSize -= fileSize;
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogTrace(ex, "Failed to delete old file {file}", oldestFile.FullName); Logger.LogTrace(ex, "Failed to delete old file {file}", fi.FullName);
}
finally
{
i++;
} }
files.RemoveAt(0);
} }
} }
@@ -510,12 +515,19 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);
_scanCancellationTokenSource?.Cancel(); // Disposing of file system watchers
PenumbraWatcher?.Dispose(); PenumbraWatcher?.Dispose();
LightlessWatcher?.Dispose(); LightlessWatcher?.Dispose();
// Disposing of cancellation token sources
_scanCancellationTokenSource?.CancelDispose();
_scanCancellationTokenSource?.Dispose();
_penumbraFswCts?.CancelDispose(); _penumbraFswCts?.CancelDispose();
_penumbraFswCts?.Dispose();
_lightlessFswCts?.CancelDispose(); _lightlessFswCts?.CancelDispose();
_lightlessFswCts?.Dispose();
_periodicCalculationTokenSource?.CancelDispose(); _periodicCalculationTokenSource?.CancelDispose();
_periodicCalculationTokenSource?.Dispose();
} }
private void FullFileScan(CancellationToken ct) private void FullFileScan(CancellationToken ct)
@@ -593,7 +605,7 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
List<FileCacheEntity> entitiesToRemove = []; List<FileCacheEntity> entitiesToRemove = [];
List<FileCacheEntity> entitiesToUpdate = []; List<FileCacheEntity> entitiesToUpdate = [];
object sync = new(); Lock sync = new();
Thread[] workerThreads = new Thread[threadCount]; Thread[] workerThreads = new Thread[threadCount];
ConcurrentQueue<FileCacheEntity> fileCaches = new(_fileDbManager.GetAllFileCaches()); ConcurrentQueue<FileCacheEntity> fileCaches = new(_fileDbManager.GetAllFileCaches());

View File

@@ -41,11 +41,8 @@ public sealed class FileCacheManager : IHostedService
private string CsvBakPath => _csvPath + ".bak"; private string CsvBakPath => _csvPath + ".bak";
private static string NormalizeSeparators(string path) private static string NormalizeSeparators(string path) => path.Replace("/", "\\", StringComparison.Ordinal)
{
return path.Replace("/", "\\", StringComparison.Ordinal)
.Replace("\\\\", "\\", StringComparison.Ordinal); .Replace("\\\\", "\\", StringComparison.Ordinal);
}
private static string NormalizePrefixedPathKey(string prefixedPath) private static string NormalizePrefixedPathKey(string prefixedPath)
{ {

View File

@@ -463,12 +463,16 @@ internal sealed partial class CharaDataHubUi
else else
{ {
var desc = pose.Description; var desc = pose.Description;
if (desc != null)
{
if (ImGui.InputTextWithHint("##description", "Description", ref desc, 100)) if (ImGui.InputTextWithHint("##description", "Description", ref desc, 100))
{ {
pose.Description = desc; pose.Description = desc;
updateDto.UpdatePoseList(); updateDto.UpdatePoseList();
} }
ImGui.SameLine(); ImGui.SameLine();
}
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete"))
{ {
updateDto.RemovePose(pose); updateDto.RemovePose(pose);

View File

@@ -23,6 +23,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
private readonly UiSharedService _uiShared; private readonly UiSharedService _uiShared;
private readonly PairProcessingLimiter _pairProcessingLimiter; private readonly PairProcessingLimiter _pairProcessingLimiter;
private readonly ConcurrentDictionary<GameObjectHandler, bool> _uploadingPlayers = new(); private readonly ConcurrentDictionary<GameObjectHandler, bool> _uploadingPlayers = new();
private readonly Dictionary<GameObjectHandler, Vector2> _smoothed = [];
private bool _notificationDismissed = true; private bool _notificationDismissed = true;
private int _lastDownloadStateHash = 0; private int _lastDownloadStateHash = 0;
@@ -204,8 +205,18 @@ public class DownloadUi : WindowMediatorSubscriberBase
foreach (var transfer in _currentDownloads.ToList()) foreach (var transfer in _currentDownloads.ToList())
{ {
var screenPos = _dalamudUtilService.WorldToScreen(transfer.Key.GetGameObject()); var transferKey = transfer.Key;
if (screenPos == Vector2.Zero) continue; var rawPos = _dalamudUtilService.WorldToScreen(transferKey.GetGameObject());
//If RawPos is zero, remove it from smoothed dictionary
if (rawPos == Vector2.Zero)
{
_smoothed.Remove(transferKey);
continue;
}
//Smoothing out the movement and fix jitter around the position.
Vector2 screenPos = _smoothed.TryGetValue(transferKey, out var lastPos) ? (rawPos - lastPos).Length() < 4f ? lastPos : rawPos : rawPos;
_smoothed[transferKey] = screenPos;
var totalBytes = transfer.Value.Sum(c => c.Value.TotalBytes); var totalBytes = transfer.Value.Sum(c => c.Value.TotalBytes);
var transferredBytes = transfer.Value.Sum(c => c.Value.TransferredBytes); var transferredBytes = transfer.Value.Sum(c => c.Value.TransferredBytes);

View File

@@ -1,43 +0,0 @@
namespace LightlessSync.UI.Models
{
public class ChangelogFile
{
public string Tagline { get; init; } = string.Empty;
public string Subline { get; init; } = string.Empty;
public List<ChangelogEntry> Changelog { get; init; } = new();
public List<CreditCategory>? Credits { get; init; }
}
public class ChangelogEntry
{
public string Name { get; init; } = string.Empty;
public string Date { get; init; } = string.Empty;
public string Tagline { get; init; } = string.Empty;
public bool? IsCurrent { get; init; }
public string? Message { get; init; }
public List<ChangelogVersion>? Versions { get; init; }
}
public class ChangelogVersion
{
public string Number { get; init; } = string.Empty;
public List<string> Items { get; init; } = new();
}
public class CreditCategory
{
public string Category { get; init; } = string.Empty;
public List<CreditItem> Items { get; init; } = new();
}
public class CreditItem
{
public string Name { get; init; } = string.Empty;
public string Role { get; init; } = string.Empty;
}
public class CreditsFile
{
public List<CreditCategory> Credits { get; init; } = new();
}
}

View File

@@ -0,0 +1,12 @@
namespace LightlessSync.UI.Models
{
public class ChangelogEntry
{
public string Name { get; init; } = string.Empty;
public string Date { get; init; } = string.Empty;
public string Tagline { get; init; } = string.Empty;
public bool? IsCurrent { get; init; }
public string? Message { get; init; }
public List<ChangelogVersion>? Versions { get; init; }
}
}

View File

@@ -0,0 +1,10 @@
namespace LightlessSync.UI.Models
{
public class ChangelogFile
{
public string Tagline { get; init; } = string.Empty;
public string Subline { get; init; } = string.Empty;
public List<ChangelogEntry> Changelog { get; init; } = new();
public List<CreditCategory>? Credits { get; init; }
}
}

View File

@@ -0,0 +1,8 @@
namespace LightlessSync.UI.Models
{
public class ChangelogVersion
{
public string Number { get; init; } = string.Empty;
public List<string> Items { get; init; } = [];
}
}

View File

@@ -0,0 +1,8 @@
namespace LightlessSync.UI.Models
{
public class CreditCategory
{
public string Category { get; init; } = string.Empty;
public List<CreditItem> Items { get; init; } = [];
}
}

View File

@@ -0,0 +1,8 @@
namespace LightlessSync.UI.Models
{
public class CreditItem
{
public string Name { get; init; } = string.Empty;
public string Role { get; init; } = string.Empty;
}
}

View File

@@ -0,0 +1,7 @@
namespace LightlessSync.UI.Models
{
public class CreditsFile
{
public List<CreditCategory> Credits { get; init; } = [];
}
}

View File

@@ -1,7 +1,7 @@
using Dalamud.Interface;
using LightlessSync.LightlessConfiguration.Models; using LightlessSync.LightlessConfiguration.Models;
using System.Numerics;
namespace LightlessSync.UI.Models; namespace LightlessSync.UI.Models;
public class LightlessNotification public class LightlessNotification
{ {
public string Id { get; set; } = Guid.NewGuid().ToString(); public string Id { get; set; } = Guid.NewGuid().ToString();
@@ -20,13 +20,3 @@ public class LightlessNotification
public bool IsAnimatingOut { get; set; } = false; public bool IsAnimatingOut { get; set; } = false;
public uint? SoundEffectId { get; set; } = null; public uint? SoundEffectId { get; set; } = null;
} }
public class LightlessNotificationAction
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string Label { get; set; } = string.Empty;
public FontAwesomeIcon Icon { get; set; } = FontAwesomeIcon.None;
public Vector4 Color { get; set; } = Vector4.One;
public Action<LightlessNotification> OnClick { get; set; } = _ => { };
public bool IsPrimary { get; set; } = false;
public bool IsDestructive { get; set; } = false;
}

View File

@@ -0,0 +1,15 @@
using Dalamud.Interface;
using System.Numerics;
namespace LightlessSync.UI.Models;
public class LightlessNotificationAction
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string Label { get; set; } = string.Empty;
public FontAwesomeIcon Icon { get; set; } = FontAwesomeIcon.None;
public Vector4 Color { get; set; } = Vector4.One;
public Action<LightlessNotification> OnClick { get; set; } = _ => { };
public bool IsPrimary { get; set; } = false;
public bool IsDestructive { get; set; } = false;
}

View File

@@ -96,10 +96,10 @@ namespace LightlessSync.UI
public static Vector4 HexToRgba(string hexColor) public static Vector4 HexToRgba(string hexColor)
{ {
hexColor = hexColor.TrimStart('#'); hexColor = hexColor.TrimStart('#');
int r = int.Parse(hexColor.Substring(0, 2), NumberStyles.HexNumber); int r = int.Parse(hexColor[..2], NumberStyles.HexNumber);
int g = int.Parse(hexColor.Substring(2, 2), NumberStyles.HexNumber); int g = int.Parse(hexColor[2..4], NumberStyles.HexNumber);
int b = int.Parse(hexColor.Substring(4, 2), NumberStyles.HexNumber); int b = int.Parse(hexColor[4..6], NumberStyles.HexNumber);
int a = hexColor.Length == 8 ? int.Parse(hexColor.Substring(6, 2), NumberStyles.HexNumber) : 255; int a = hexColor.Length == 8 ? int.Parse(hexColor[6..8], NumberStyles.HexNumber) : 255;
return new Vector4(r / 255f, g / 255f, b / 255f, a / 255f); return new Vector4(r / 255f, g / 255f, b / 255f, a / 255f);
} }

View File

@@ -70,7 +70,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
private bool _isOneDrive = false; private bool _isOneDrive = false;
private bool _isPenumbraDirectory = false; private bool _isPenumbraDirectory = false;
private bool _moodlesExists = false; private bool _moodlesExists = false;
private Dictionary<string, DateTime> _oauthTokenExpiry = new(); private readonly Dictionary<string, DateTime> _oauthTokenExpiry = [];
private bool _penumbraExists = false; private bool _penumbraExists = false;
private bool _petNamesExists = false; private bool _petNamesExists = false;
private int _serverSelectionIndex = -1; private int _serverSelectionIndex = -1;
@@ -1067,7 +1067,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
{ {
using (ImRaii.Disabled(_discordOAuthUIDs == null)) using (ImRaii.Disabled(_discordOAuthUIDs == null))
{ {
var aliasPairs = _discordOAuthUIDs?.Result?.Select(t => new UIDAliasPair(t.Key, t.Value)).ToList() ?? [new UIDAliasPair(item.UID ?? null, null)]; var aliasPairs = _discordOAuthUIDs?.Result?.Select(t => new UidAliasPair(t.Key, t.Value)).ToList() ?? [new UidAliasPair(item.UID ?? null, null)];
var uidComboName = "UID###" + item.CharacterName + item.WorldId + serverUri + indexOffset + aliasPairs.Count; var uidComboName = "UID###" + item.CharacterName + item.WorldId + serverUri + indexOffset + aliasPairs.Count;
DrawCombo(uidComboName, aliasPairs, DrawCombo(uidComboName, aliasPairs,
(v) => (v) =>
@@ -1253,6 +1253,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
UidFont.Dispose(); UidFont.Dispose();
GameFont.Dispose(); GameFont.Dispose();
MediumFont.Dispose(); MediumFont.Dispose();
_discordOAuthGetCts.Dispose();
} }
private static void CenterWindow(float width, float height, ImGuiCond cond = ImGuiCond.None) private static void CenterWindow(float width, float height, ImGuiCond cond = ImGuiCond.None)
@@ -1325,6 +1326,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return result; return result;
} }
public sealed record IconScaleData(Vector2 IconSize, Vector2 NormalizedIconScale, float OffsetX, float IconScaling); public sealed record IconScaleData(Vector2 IconSize, Vector2 NormalizedIconScale, float OffsetX, float IconScaling);
private record UIDAliasPair(string? UID, string? Alias); private sealed record UidAliasPair(string? UID, string? Alias);
} }

View File

@@ -742,7 +742,7 @@ public class UpdateNotesUi : WindowMediatorSubscriberBase
using var changelogStream = assembly.GetManifestResourceStream("LightlessSync.Changelog.changelog.yaml"); using var changelogStream = assembly.GetManifestResourceStream("LightlessSync.Changelog.changelog.yaml");
if (changelogStream != null) if (changelogStream != null)
{ {
using var reader = new StreamReader(changelogStream, Encoding.UTF8, true, 128); using var reader = new StreamReader(changelogStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, 128);
var yaml = reader.ReadToEnd(); var yaml = reader.ReadToEnd();
_changelog = deserializer.Deserialize<ChangelogFile>(yaml) ?? new(); _changelog = deserializer.Deserialize<ChangelogFile>(yaml) ?? new();
} }
@@ -751,7 +751,7 @@ public class UpdateNotesUi : WindowMediatorSubscriberBase
using var creditsStream = assembly.GetManifestResourceStream("LightlessSync.Changelog.credits.yaml"); using var creditsStream = assembly.GetManifestResourceStream("LightlessSync.Changelog.credits.yaml");
if (creditsStream != null) if (creditsStream != null)
{ {
using var reader = new StreamReader(creditsStream, Encoding.UTF8, true, 128); using var reader = new StreamReader(creditsStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, 128);
var yaml = reader.ReadToEnd(); var yaml = reader.ReadToEnd();
_credits = deserializer.Deserialize<CreditsFile>(yaml) ?? new(); _credits = deserializer.Deserialize<CreditsFile>(yaml) ?? new();
} }

View File

@@ -46,7 +46,7 @@ public static class Crypto
return hash; return hash;
return _hashListPlayersSHA256[playerToHash] = return _hashListPlayersSHA256[playerToHash] =
BitConverter.ToString(_sha256CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(playerToHash.Item1 + playerToHash.Item2.ToString()))).Replace("-", "", StringComparison.Ordinal); Convert.ToHexString(_sha256CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(playerToHash.Item1 + playerToHash.Item2.ToString())));
} }
public static string GetHash256(this string stringToHash) public static string GetHash256(this string stringToHash)
@@ -60,7 +60,7 @@ public static class Crypto
return hash; return hash;
return _hashListSHA256[stringToCompute] = return _hashListSHA256[stringToCompute] =
BitConverter.ToString(_sha256CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(stringToCompute))).Replace("-", "", StringComparison.Ordinal); Convert.ToHexString(_sha256CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(stringToCompute)));
} }
#pragma warning restore SYSLIB0021 // Type or member is obsolete #pragma warning restore SYSLIB0021 // Type or member is obsolete
} }

View File

@@ -57,10 +57,9 @@ public static class SeStringUtils
continue; continue;
var hasColor = fragment.Color.HasValue; var hasColor = fragment.Color.HasValue;
Vector4 color = default;
if (hasColor) if (hasColor)
{ {
color = fragment.Color!.Value; Vector4 color = fragment.Color!.Value;
builder.PushColorRgba(color); builder.PushColorRgba(color);
} }
@@ -233,7 +232,7 @@ public static class SeStringUtils
protected abstract byte ChunkType { get; } protected abstract byte ChunkType { get; }
} }
private class ColorPayload : AbstractColorPayload private sealed class ColorPayload : AbstractColorPayload
{ {
protected override byte ChunkType => 0x13; protected override byte ChunkType => 0x13;
@@ -247,12 +246,12 @@ public static class SeStringUtils
public ColorPayload(Vector4 color) : this(new Vector3(color.X, color.Y, color.Z)) { } public ColorPayload(Vector4 color) : this(new Vector3(color.X, color.Y, color.Z)) { }
} }
private class ColorEndPayload : AbstractColorEndPayload private sealed class ColorEndPayload : AbstractColorEndPayload
{ {
protected override byte ChunkType => 0x13; protected override byte ChunkType => 0x13;
} }
private class GlowPayload : AbstractColorPayload private sealed class GlowPayload : AbstractColorPayload
{ {
protected override byte ChunkType => 0x14; protected override byte ChunkType => 0x14;
@@ -266,7 +265,7 @@ public static class SeStringUtils
public GlowPayload(Vector4 color) : this(new Vector3(color.X, color.Y, color.Z)) { } public GlowPayload(Vector4 color) : this(new Vector3(color.X, color.Y, color.Z)) { }
} }
private class GlowEndPayload : AbstractColorEndPayload private sealed class GlowEndPayload : AbstractColorEndPayload
{ {
protected override byte ChunkType => 0x14; protected override byte ChunkType => 0x14;
} }