From 69b504c42ffacfe380b1c0143e78e91278a71366 Mon Sep 17 00:00:00 2001 From: cake Date: Fri, 5 Dec 2025 04:43:30 +0100 Subject: [PATCH] Added the old system of WQPD back. added more options of it. --- .../Configurations/LightlessConfig.cs | 1 + LightlessSync/UI/DownloadUi.cs | 486 +++++++++++++----- LightlessSync/UI/SettingsUi.cs | 155 +----- 3 files changed, 390 insertions(+), 252 deletions(-) diff --git a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs index e3305a2..0b448ad 100644 --- a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs +++ b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs @@ -66,6 +66,7 @@ public class LightlessConfig : ILightlessConfiguration public bool ShowTransferBars { get; set; } = true; public bool ShowTransferWindow { get; set; } = false; public bool ShowPlayerLinesTransferWindow { get; set; } = true; + public bool ShowPlayerSpeedBarsTransferWindow { get; set; } = true; public bool UseNotificationsForDownloads { get; set; } = true; public bool ShowUploading { get; set; } = true; public bool ShowUploadingBigText { get; set; } = true; diff --git a/LightlessSync/UI/DownloadUi.cs b/LightlessSync/UI/DownloadUi.cs index 51111ed..dac49c1 100644 --- a/LightlessSync/UI/DownloadUi.cs +++ b/LightlessSync/UI/DownloadUi.cs @@ -1,4 +1,4 @@ -using Dalamud.Bindings.ImGui; +using Dalamud.Bindings.ImGui; using Dalamud.Interface.Colors; using LightlessSync.LightlessConfiguration; using LightlessSync.LightlessConfiguration.Models; @@ -154,102 +154,228 @@ public class DownloadUi : WindowMediatorSubscriberBase if (_configService.Current.ShowTransferBars) { - const int dlBarBorder = 3; - const float rounding = 6f; - var shadowOffset = new Vector2(2, 2); + DrawTransferBar(); + } + } - foreach (var transfer in _currentDownloads.ToList()) + private void DrawTransferBar() + { + const int dlBarBorder = 3; + const float rounding = 6f; + var shadowOffset = new Vector2(2, 2); + + foreach (var transfer in _currentDownloads.ToList()) + { + var transferKey = transfer.Key; + var rawPos = _dalamudUtilService.WorldToScreen(transferKey.GetGameObject()); + + // If RawPos is zero, remove it from smoothed dictionary + if (rawPos == Vector2.Zero) { - var transferKey = transfer.Key; - var rawPos = _dalamudUtilService.WorldToScreen(transferKey.GetGameObject()); + _smoothed.Remove(transferKey); + continue; + } - //If RawPos is zero, remove it from smoothed dictionary - if (rawPos == Vector2.Zero) + // 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 transferredBytes = transfer.Value.Sum(c => c.Value.TransferredBytes); + + // Per-player state counts + var dlSlot = 0; + var dlQueue = 0; + var dlProg = 0; + var dlDecomp = 0; + + foreach (var entry in transfer.Value) + { + var fileStatus = entry.Value; + switch (fileStatus.DownloadStatus) { - _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 transferredBytes = transfer.Value.Sum(c => c.Value.TransferredBytes); - - var maxDlText = $"{UiSharedService.ByteToString(totalBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)}"; - var textSize = _configService.Current.TransferBarsShowText - ? ImGui.CalcTextSize(maxDlText) - : new Vector2(10, 10); - - int dlBarHeight = _configService.Current.TransferBarsHeight > ((int)textSize.Y + 5) - ? _configService.Current.TransferBarsHeight - : (int)textSize.Y + 5; - int dlBarWidth = _configService.Current.TransferBarsWidth > ((int)textSize.X + 10) - ? _configService.Current.TransferBarsWidth - : (int)textSize.X + 10; - - var dlBarStart = new Vector2(screenPos.X - dlBarWidth / 2f, screenPos.Y - dlBarHeight / 2f); - var dlBarEnd = new Vector2(screenPos.X + dlBarWidth / 2f, screenPos.Y + dlBarHeight / 2f); - - // Precompute rects - var outerStart = new Vector2(dlBarStart.X - dlBarBorder - 1, dlBarStart.Y - dlBarBorder - 1); - var outerEnd = new Vector2(dlBarEnd.X + dlBarBorder + 1, dlBarEnd.Y + dlBarBorder + 1); - var borderStart = new Vector2(dlBarStart.X - dlBarBorder, dlBarStart.Y - dlBarBorder); - var borderEnd = new Vector2(dlBarEnd.X + dlBarBorder, dlBarEnd.Y + dlBarBorder); - - var drawList = ImGui.GetBackgroundDrawList(); - - //Shadow, background, border, bar background - drawList.AddRectFilled(outerStart + shadowOffset, outerEnd + shadowOffset, UiSharedService.Color(0, 0, 0, 100 / 2), rounding + 2); - drawList.AddRectFilled(outerStart, outerEnd, UiSharedService.Color(0, 0, 0, 100), rounding + 2); - drawList.AddRectFilled(borderStart, borderEnd, UiSharedService.Color(ImGuiColors.DalamudGrey), rounding); - drawList.AddRectFilled(dlBarStart, dlBarEnd, UiSharedService.Color(0, 0, 0, 100), rounding); - - var dlProgressPercent = transferredBytes / (double)totalBytes; - var progressEndX = dlBarStart.X + (float)(dlProgressPercent * dlBarWidth); - var progressEnd = new Vector2(progressEndX, dlBarEnd.Y); - - drawList.AddRectFilled(dlBarStart, progressEnd, UiSharedService.Color(UIColors.Get("LightlessPurple")), rounding); - - if (_configService.Current.TransferBarsShowText) - { - var downloadText = $"{UiSharedService.ByteToString(transferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)}"; - UiSharedService.DrawOutlinedFont(drawList, downloadText, screenPos with { X = screenPos.X - textSize.X / 2f - 1, Y = screenPos.Y - textSize.Y / 2f - 1 }, - UiSharedService.Color(ImGuiColors.DalamudGrey), - UiSharedService.Color(0, 0, 0, 100), - 1 - ); + case DownloadStatus.WaitingForSlot: + dlSlot++; + break; + case DownloadStatus.WaitingForQueue: + dlQueue++; + break; + case DownloadStatus.Downloading: + dlProg++; + break; + case DownloadStatus.Decompressing: + dlDecomp++; + break; } } - if (_configService.Current.ShowUploading) + string statusText; + if (dlProg > 0) { - foreach (var player in _uploadingPlayers.Select(p => p.Key).ToList()) + statusText = "Downloading"; + } + else if (dlDecomp > 0 || (totalBytes > 0 && transferredBytes >= totalBytes)) + { + statusText = "Decompressing"; + } + else if (dlQueue > 0) + { + statusText = "Waiting for queue"; + } + else if (dlSlot > 0) + { + statusText = "Waiting for slot"; + } + else + { + statusText = "Waiting"; + } + + var hasValidSize = totalBytes > 0; + + var maxDlText = $"{UiSharedService.ByteToString(totalBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)}"; + var textSize = _configService.Current.TransferBarsShowText + ? ImGui.CalcTextSize(maxDlText) + : new Vector2(10, 10); + + int dlBarHeight = _configService.Current.TransferBarsHeight > ((int)textSize.Y + 5) + ? _configService.Current.TransferBarsHeight + : (int)textSize.Y + 5; + int dlBarWidth = _configService.Current.TransferBarsWidth > ((int)textSize.X + 10) + ? _configService.Current.TransferBarsWidth + : (int)textSize.X + 10; + + var dlBarStart = new Vector2(screenPos.X - dlBarWidth / 2f, screenPos.Y - dlBarHeight / 2f); + var dlBarEnd = new Vector2(screenPos.X + dlBarWidth / 2f, screenPos.Y + dlBarHeight / 2f); + + // Precompute rects + var outerStart = new Vector2(dlBarStart.X - dlBarBorder - 1, dlBarStart.Y - dlBarBorder - 1); + var outerEnd = new Vector2(dlBarEnd.X + dlBarBorder + 1, dlBarEnd.Y + dlBarBorder + 1); + var borderStart = new Vector2(dlBarStart.X - dlBarBorder, dlBarStart.Y - dlBarBorder); + var borderEnd = new Vector2(dlBarEnd.X + dlBarBorder, dlBarEnd.Y + dlBarBorder); + + var drawList = ImGui.GetBackgroundDrawList(); + + drawList.AddRectFilled( + outerStart + shadowOffset, + outerEnd + shadowOffset, + UiSharedService.Color(0, 0, 0, 100 / 2), + rounding + 2 + ); + drawList.AddRectFilled( + outerStart, + outerEnd, + UiSharedService.Color(0, 0, 0, 100), + rounding + 2 + ); + drawList.AddRectFilled( + borderStart, + borderEnd, + UiSharedService.Color(ImGuiColors.DalamudGrey), + rounding + ); + drawList.AddRectFilled( + dlBarStart, + dlBarEnd, + UiSharedService.Color(0, 0, 0, 100), + rounding + ); + + bool showFill = false; + double fillPercent = 0.0; + + if (hasValidSize) + { + if (dlProg > 0) { - var screenPos = _dalamudUtilService.WorldToScreen(player.GetGameObject()); - if (screenPos == Vector2.Zero) continue; + fillPercent = transferredBytes / (double)totalBytes; + showFill = true; + } + else if (dlDecomp > 0 || transferredBytes >= totalBytes) + { + fillPercent = 1.0; + showFill = true; + } + } - try + if (showFill) + { + if (fillPercent < 0) fillPercent = 0; + if (fillPercent > 1) fillPercent = 1; + + var progressEndX = dlBarStart.X + (float)(fillPercent * dlBarWidth); + var progressEnd = new Vector2(progressEndX, dlBarEnd.Y); + + drawList.AddRectFilled( + dlBarStart, + progressEnd, + UiSharedService.Color(UIColors.Get("LightlessPurple")), + rounding + ); + } + + if (_configService.Current.TransferBarsShowText) + { + string downloadText; + + if (dlProg > 0 && hasValidSize) + { + downloadText = + $"{statusText} {UiSharedService.ByteToString(transferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)}"; + } + else if ((dlDecomp > 0 || transferredBytes >= totalBytes) && hasValidSize) + { + downloadText = "Decompressing"; + } + else + { + // Waiting states + downloadText = statusText; + } + + var actualTextSize = ImGui.CalcTextSize(downloadText); + + UiSharedService.DrawOutlinedFont( + drawList, + downloadText, + screenPos with { - using var _ = _uiShared.UidFont.Push(); - var uploadText = "Uploading"; + X = screenPos.X - actualTextSize.X / 2f - 1, + Y = screenPos.Y - actualTextSize.Y / 2f - 1 + }, + UiSharedService.Color(ImGuiColors.DalamudGrey), + UiSharedService.Color(0, 0, 0, 100), + 1 + ); + } + } - var textSize = ImGui.CalcTextSize(uploadText); + if (_configService.Current.ShowUploading) + { + foreach (var player in _uploadingPlayers.Select(p => p.Key).ToList()) + { + var screenPos = _dalamudUtilService.WorldToScreen(player.GetGameObject()); + if (screenPos == Vector2.Zero) continue; - var drawList = ImGui.GetBackgroundDrawList(); - UiSharedService.DrawOutlinedFont(drawList, uploadText, screenPos with { X = screenPos.X - textSize.X / 2f - 1, Y = screenPos.Y - textSize.Y / 2f - 1 }, - UiSharedService.Color(ImGuiColors.DalamudYellow), - UiSharedService.Color(0, 0, 0, 100), - 2 - ); - } - catch - { - _logger.LogDebug("Error drawing upload progress"); - } + try + { + using var _ = _uiShared.UidFont.Push(); + var uploadText = "Uploading"; + + var textSize = ImGui.CalcTextSize(uploadText); + + var drawList = ImGui.GetBackgroundDrawList(); + UiSharedService.DrawOutlinedFont(drawList, uploadText, screenPos with { X = screenPos.X - textSize.X / 2f - 1, Y = screenPos.Y - textSize.Y / 2f - 1 }, + UiSharedService.Color(ImGuiColors.DalamudYellow), + UiSharedService.Color(0, 0, 0, 100), + 2 + ); + } + catch + { + _logger.LogDebug("Error drawing upload progress"); } } } @@ -257,7 +383,7 @@ public class DownloadUi : WindowMediatorSubscriberBase private void DrawDownloadSummaryBox() { - if (!_currentDownloads.Any()) + if (_currentDownloads.IsEmpty) return; const float padding = 6f; @@ -271,10 +397,24 @@ public class DownloadUi : WindowMediatorSubscriberBase long totalBytes = 0; long transferredBytes = 0; - // (Name, files done, files total, bytes done, bytes total, speed) - var perPlayer = new List<(string Name, int TransferredFiles, int TotalFiles, long TransferredBytes, long TotalBytes, double SpeedBytesPerSecond)>(); + var totalDlSlot = 0; + var totalDlQueue = 0; + var totalDlProg = 0; + var totalDlDecomp = 0; - foreach (var transfer in _currentDownloads.ToList()) + var perPlayer = new List<( + string Name, + int TransferredFiles, + int TotalFiles, + long TransferredBytes, + long TotalBytes, + double SpeedBytesPerSecond, + int DlSlot, + int DlQueue, + int DlProg, + int DlDecomp)>(); + + foreach (var transfer in _currentDownloads) { var handler = transfer.Key; var statuses = transfer.Value.Values; @@ -289,6 +429,36 @@ public class DownloadUi : WindowMediatorSubscriberBase totalBytes += playerTotalBytes; transferredBytes += playerTransferredBytes; + // per-player W/Q/P/D + var playerDlSlot = 0; + var playerDlQueue = 0; + var playerDlProg = 0; + var playerDlDecomp = 0; + + foreach (var entry in transfer.Value) + { + var fileStatus = entry.Value; + switch (fileStatus.DownloadStatus) + { + case DownloadStatus.WaitingForSlot: + playerDlSlot++; + totalDlSlot++; + break; + case DownloadStatus.WaitingForQueue: + playerDlQueue++; + totalDlQueue++; + break; + case DownloadStatus.Downloading: + playerDlProg++; + totalDlProg++; + break; + case DownloadStatus.Decompressing: + playerDlDecomp++; + totalDlDecomp++; + break; + } + } + double speed = 0; if (playerTotalBytes > 0) { @@ -307,7 +477,11 @@ public class DownloadUi : WindowMediatorSubscriberBase playerTotalFiles, playerTransferredBytes, playerTotalBytes, - speed + speed, + playerDlSlot, + playerDlQueue, + playerDlProg, + playerDlDecomp )); } @@ -321,7 +495,7 @@ public class DownloadUi : WindowMediatorSubscriberBase if (totalFiles == 0 || totalBytes == 0) return; - // max speed for scale (clamped) + // max speed for per-player bar scale (clamped) double maxSpeed = perPlayer.Count > 0 ? perPlayer.Max(p => p.SpeedBytesPerSecond) : 0; if (maxSpeed <= 0) maxSpeed = 1; @@ -330,8 +504,11 @@ public class DownloadUi : WindowMediatorSubscriberBase var windowPos = ImGui.GetWindowPos(); // Overall texts - var headerText = $"Downloading {transferredFiles}/{totalFiles} files"; - var bytesText = $"{UiSharedService.ByteToString(transferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)}"; + var headerText = + $"Downloading {transferredFiles}/{totalFiles} files [W:{totalDlSlot}/Q:{totalDlQueue}/P:{totalDlProg}/D:{totalDlDecomp}]"; + + var bytesText = + $"{UiSharedService.ByteToString(transferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)}"; var totalSpeed = perPlayer.Sum(p => p.SpeedBytesPerSecond); var speedText = totalSpeed > 0 @@ -346,19 +523,17 @@ public class DownloadUi : WindowMediatorSubscriberBase if (bytesSize.X > contentWidth) contentWidth = bytesSize.X; if (totalSpeedSize.X > contentWidth) contentWidth = totalSpeedSize.X; - foreach (var p in perPlayer) + if (_configService.Current.ShowPlayerLinesTransferWindow) { - var playerSpeedText = p.SpeedBytesPerSecond > 0 - ? $"{UiSharedService.ByteToString((long)p.SpeedBytesPerSecond)}/s" - : "-"; + foreach (var p in perPlayer) + { + var line = + $"{p.Name} [W:{p.DlSlot}/Q:{p.DlQueue}/P:{p.DlProg}/D:{p.DlDecomp}] {p.TransferredFiles}/{p.TotalFiles}"; - var line = $"{p.Name}: {p.TransferredFiles}/{p.TotalFiles} " + - $"({UiSharedService.ByteToString(p.TransferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(p.TotalBytes)}) " + - $"@ {playerSpeedText}"; - - var lineSize = ImGui.CalcTextSize(line); - if (lineSize.X > contentWidth) - contentWidth = lineSize.X; + var lineSize = ImGui.CalcTextSize(line); + if (lineSize.X > contentWidth) + contentWidth = lineSize.X; + } } var lineHeight = ImGui.GetTextLineHeight(); @@ -370,16 +545,29 @@ public class DownloadUi : WindowMediatorSubscriberBase if (boxWidth < minBoxWidth) boxWidth = minBoxWidth; + // Box height float boxHeight = 0; - boxHeight += padding; - boxHeight += globalBarHeight; + boxHeight += padding; + boxHeight += globalBarHeight; boxHeight += padding; boxHeight += lineHeight + spacingY; boxHeight += lineHeight + spacingY; - boxHeight += lineHeight * 1.4f + spacingY; + boxHeight += lineHeight * 1.4f + spacingY; + + if (_configService.Current.ShowPlayerLinesTransferWindow) + { + foreach (var p in perPlayer) + { + boxHeight += lineHeight + spacingY; + + if (_configService.Current.ShowPlayerSpeedBarsTransferWindow && p.DlProg > 0) + { + boxHeight += perPlayerBarHeight + spacingY; + } + } + } - boxHeight += perPlayer.Count * (lineHeight + perPlayerBarHeight + spacingY * 2); boxHeight += padding; var boxMin = windowPos; @@ -399,25 +587,50 @@ public class DownloadUi : WindowMediatorSubscriberBase if (progress > 1f) progress = 1f; drawList.AddRectFilled(barMin, barMax, UiSharedService.Color(40, 40, 40, _transferBoxTransparency), 3f); - drawList.AddRectFilled(barMin, new Vector2(barMin.X + (barMax.X - barMin.X) * progress, barMax.Y), UiSharedService.Color(UIColors.Get("LightlessPurple")), 3f); + drawList.AddRectFilled( + barMin, + new Vector2(barMin.X + (barMax.X - barMin.X) * progress, barMax.Y), + UiSharedService.Color(UIColors.Get("LightlessPurple")), + 3f + ); cursor.Y = barMax.Y + padding; // Header - UiSharedService.DrawOutlinedFont(drawList, headerText, cursor, UiSharedService.Color(ImGuiColors.DalamudWhite), UiSharedService.Color(0, 0, 0, _transferBoxTransparency), 1); + UiSharedService.DrawOutlinedFont( + drawList, + headerText, + cursor, + UiSharedService.Color(ImGuiColors.DalamudWhite), + UiSharedService.Color(0, 0, 0, _transferBoxTransparency), + 1 + ); cursor.Y += lineHeight + spacingY; // Bytes - UiSharedService.DrawOutlinedFont(drawList, bytesText, cursor, UiSharedService.Color(ImGuiColors.DalamudWhite), UiSharedService.Color(0, 0, 0, _transferBoxTransparency), 1); + UiSharedService.DrawOutlinedFont( + drawList, + bytesText, + cursor, + UiSharedService.Color(ImGuiColors.DalamudWhite), + UiSharedService.Color(0, 0, 0, _transferBoxTransparency), + 1 + ); cursor.Y += lineHeight + spacingY; - // Total speed WIP - UiSharedService.DrawOutlinedFont(drawList, speedText, cursor, UiSharedService.Color(UIColors.Get("LightlessPurple")), UiSharedService.Color(0, 0, 0, _transferBoxTransparency), 1); + // Total speed + UiSharedService.DrawOutlinedFont( + drawList, + speedText, + cursor, + UiSharedService.Color(UIColors.Get("LightlessPurple")), + UiSharedService.Color(0, 0, 0, _transferBoxTransparency), + 1 + ); cursor.Y += lineHeight * 1.4f + spacingY; if (_configService.Current.ShowPlayerLinesTransferWindow) { - // Per-player lines var orderedPlayers = perPlayer.OrderByDescending(p => p.TotalBytes).ToList(); foreach (var p in orderedPlayers) @@ -426,13 +639,31 @@ public class DownloadUi : WindowMediatorSubscriberBase ? $"{UiSharedService.ByteToString((long)p.SpeedBytesPerSecond)}/s" : "-"; - var line = $"{p.Name}: {p.TransferredFiles}/{p.TotalFiles} " + - $"({UiSharedService.ByteToString(p.TransferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(p.TotalBytes)}) " + - $"@ {playerSpeedText}"; + var labelLine = + $"{p.Name} [W:{p.DlSlot}/Q:{p.DlQueue}/P:{p.DlProg}/D:{p.DlDecomp}] {p.TransferredFiles}/{p.TotalFiles}"; + + if (!_configService.Current.ShowPlayerSpeedBarsTransferWindow || p.DlProg <= 0) + { + var fullLine = + $"{labelLine} " + + $"({UiSharedService.ByteToString(p.TransferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(p.TotalBytes)}) " + + $"@ {playerSpeedText}"; + + UiSharedService.DrawOutlinedFont( + drawList, + fullLine, + cursor, + UiSharedService.Color(255, 255, 255, _transferBoxTransparency), + UiSharedService.Color(0, 0, 0, _transferBoxTransparency), + 1 + ); + cursor.Y += lineHeight + spacingY; + continue; + } UiSharedService.DrawOutlinedFont( drawList, - line, + labelLine, cursor, UiSharedService.Color(255, 255, 255, _transferBoxTransparency), UiSharedService.Color(0, 0, 0, _transferBoxTransparency), @@ -467,7 +698,26 @@ public class DownloadUi : WindowMediatorSubscriberBase 3f ); - cursor.Y += perPlayerBarHeight + spacingY * 2; + var barText = + $"{UiSharedService.ByteToString(p.TransferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(p.TotalBytes)} @ {playerSpeedText}"; + + var barTextSize = ImGui.CalcTextSize(barText); + + var barTextPos = new Vector2( + barBgMin.X + ((barBgMax.X - barBgMin.X) - barTextSize.X) / 2f - 1, + barBgMin.Y + ((perPlayerBarHeight - barTextSize.Y) / 2f) - 1 + ); + + UiSharedService.DrawOutlinedFont( + drawList, + barText, + barTextPos, + UiSharedService.Color(255, 255, 255, _transferBoxTransparency), + UiSharedService.Color(0, 0, 0, _transferBoxTransparency), + 1 + ); + + cursor.Y += perPlayerBarHeight + spacingY; } } } diff --git a/LightlessSync/UI/SettingsUi.cs b/LightlessSync/UI/SettingsUi.cs index 255e99e..8b79c53 100644 --- a/LightlessSync/UI/SettingsUi.cs +++ b/LightlessSync/UI/SettingsUi.cs @@ -65,7 +65,6 @@ public class SettingsUi : WindowMediatorSubscriberBase private readonly UiSharedService _uiShared; private readonly IProgress<(int, int, FileCacheEntity)> _validationProgress; private readonly NameplateService _nameplateService; - private readonly NameplateHandler _nameplateHandler; private (int, int, FileCacheEntity) _currentProgress; private bool _deleteAccountPopupModalShown = false; private bool _deleteFilesPopupModalShown = false; @@ -170,7 +169,6 @@ public class SettingsUi : WindowMediatorSubscriberBase IpcManager ipcManager, CacheMonitor cacheMonitor, DalamudUtilService dalamudUtilService, HttpClient httpClient, NameplateService nameplateService, - NameplateHandler nameplateHandler, ActorObjectService actorObjectService) : base(logger, mediator, "Lightless Sync Settings", performanceCollector) { @@ -192,7 +190,6 @@ public class SettingsUi : WindowMediatorSubscriberBase _fileCompactor = fileCompactor; _uiShared = uiShared; _nameplateService = nameplateService; - _nameplateHandler = nameplateHandler; _actorObjectService = actorObjectService; AllowClickthrough = false; AllowPinning = true; @@ -887,11 +884,29 @@ public class SettingsUi : WindowMediatorSubscriberBase } bool showPlayerLinesTransferWindow = _configService.Current.ShowPlayerLinesTransferWindow; - if (ImGui.Checkbox("Toggle the Player Lines in the Transfer Window", ref showPlayerLinesTransferWindow)) + if (ImGui.Checkbox("Toggle the player lines in the Transfer Window", ref showPlayerLinesTransferWindow)) { _configService.Current.ShowPlayerLinesTransferWindow = showPlayerLinesTransferWindow; _configService.Save(); } + + if (!showPlayerLinesTransferWindow) + { + _configService.Current.ShowPlayerSpeedBarsTransferWindow = false; + ImGui.BeginDisabled(); + } + + bool showPlayerSpeedBarsTransferWindow = _configService.Current.ShowPlayerSpeedBarsTransferWindow; + if (ImGui.Checkbox("Toggle the download bars in player lines in the Transfer Window", ref showPlayerSpeedBarsTransferWindow)) + { + _configService.Current.ShowPlayerSpeedBarsTransferWindow = showPlayerSpeedBarsTransferWindow; + _configService.Save(); + } + + if (!showPlayerLinesTransferWindow) + { + ImGui.EndDisabled(); + } ImGui.Unindent(); if (!_configService.Current.ShowTransferWindow) ImGui.EndDisabled(); @@ -1928,8 +1943,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelOffsetX = (short)offsetX; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1937,8 +1950,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelOffsetX = 0; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1953,8 +1964,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelOffsetY = (short)offsetY; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1962,8 +1971,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelOffsetY = 0; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1975,8 +1982,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelScale = labelScale; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1984,8 +1989,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelScale = 1.0f; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1999,8 +2002,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderAutoAlign = autoAlign; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -2032,7 +2033,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LabelAlignment = option; _configService.Save(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -2053,8 +2053,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelShowOwn = showOwn; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -2065,8 +2063,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelShowPaired = showPaired; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -2077,8 +2073,6 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelShowHidden = showHidden; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } _uiShared.DrawHelpText("Toggles Lightfinder label when no nameplate(s) is visible."); @@ -2091,13 +2085,11 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelUseIcon = useIcon; _configService.Save(); - _nameplateHandler.ClearNameplateCaches(); - _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); if (useIcon) { - RefreshLightfinderIconState(); + // redo } else { @@ -2110,78 +2102,7 @@ public class SettingsUi : WindowMediatorSubscriberBase if (useIcon) { - if (!_lightfinderIconInputInitialized) - { - RefreshLightfinderIconState(); - } - - var currentPresetLabel = _lightfinderIconPresetIndex >= 0 - ? $"{GetLightfinderPresetGlyph(_lightfinderIconPresetIndex)} {LightfinderIconPresets[_lightfinderIconPresetIndex].Label}" - : "Custom"; - - if (ImGui.BeginCombo("Preset Icon", currentPresetLabel)) - { - for (int i = 0; i < LightfinderIconPresets.Length; i++) - { - var optionGlyph = GetLightfinderPresetGlyph(i); - var preview = $"{optionGlyph} {LightfinderIconPresets[i].Label}"; - var selected = i == _lightfinderIconPresetIndex; - if (ImGui.Selectable(preview, selected)) - { - _lightfinderIconInput = NameplateHandler.ToIconEditorString(optionGlyph); - _lightfinderIconPresetIndex = i; - } - } - - if (ImGui.Selectable("Custom", _lightfinderIconPresetIndex == -1)) - { - _lightfinderIconPresetIndex = -1; - } - - ImGui.EndCombo(); - } - - var editorBuffer = _lightfinderIconInput; - if (ImGui.InputText("Icon Glyph", ref editorBuffer, 16)) - { - _lightfinderIconInput = editorBuffer; - _lightfinderIconPresetIndex = -1; - } - - if (ImGui.Button("Apply Icon")) - { - var normalized = NameplateHandler.NormalizeIconGlyph(_lightfinderIconInput); - ApplyLightfinderIcon(normalized, _lightfinderIconPresetIndex); - } - - ImGui.SameLine(); - if (ImGui.Button("Reset Icon")) - { - var defaultGlyph = NameplateHandler.NormalizeIconGlyph(null); - var defaultIndex = -1; - for (int i = 0; i < LightfinderIconPresets.Length; i++) - { - if (string.Equals(GetLightfinderPresetGlyph(i), defaultGlyph, StringComparison.Ordinal)) - { - defaultIndex = i; - break; - } - } - - if (defaultIndex < 0) - { - defaultIndex = 0; - } - - ApplyLightfinderIcon(GetLightfinderPresetGlyph(defaultIndex), defaultIndex); - } - - var previewGlyph = NameplateHandler.NormalizeIconGlyph(_lightfinderIconInput); - ImGui.SameLine(); - ImGui.AlignTextToFramePadding(); - ImGui.Text($"Preview: {previewGlyph}"); - _uiShared.DrawHelpText( - "Enter a hex code (e.g. E0BB), pick a preset, or paste an icon character directly."); + //redo } else { @@ -3852,40 +3773,6 @@ public class SettingsUi : WindowMediatorSubscriberBase return (true, failedConversions.Count != 0, sb.ToString()); } - private static string GetLightfinderPresetGlyph(int index) - { - return NameplateHandler.NormalizeIconGlyph( - SeIconCharExtensions.ToIconString(LightfinderIconPresets[index].Icon)); - } - - private void RefreshLightfinderIconState() - { - var normalized = NameplateHandler.NormalizeIconGlyph(_configService.Current.LightfinderLabelIconGlyph); - _lightfinderIconInput = NameplateHandler.ToIconEditorString(normalized); - _lightfinderIconInputInitialized = true; - - _lightfinderIconPresetIndex = -1; - for (int i = 0; i < LightfinderIconPresets.Length; i++) - { - if (string.Equals(GetLightfinderPresetGlyph(i), normalized, StringComparison.Ordinal)) - { - _lightfinderIconPresetIndex = i; - break; - } - } - } - - private void ApplyLightfinderIcon(string normalizedGlyph, int presetIndex) - { - _configService.Current.LightfinderLabelIconGlyph = normalizedGlyph; - _configService.Save(); - _nameplateHandler.FlagRefresh(); - _nameplateService.RequestRedraw(); - _lightfinderIconInput = NameplateHandler.ToIconEditorString(normalizedGlyph); - _lightfinderIconPresetIndex = presetIndex; - _lightfinderIconInputInitialized = true; - } - private void DrawSettingsContent() { if (_apiController.ServerState is ServerState.Connected)