Fixed height issue of download box

This commit is contained in:
cake
2025-12-16 01:41:02 +01:00
parent 4e4d19ad00
commit 0dd520d926

View File

@@ -562,7 +562,10 @@ public class DownloadUi : WindowMediatorSubscriberBase
{ {
boxHeight += lineHeight + spacingY; boxHeight += lineHeight + spacingY;
if (_configService.Current.ShowPlayerSpeedBarsTransferWindow && p.DlProg > 0) var showBar = _configService.Current.ShowPlayerSpeedBarsTransferWindow
&& p.TransferredBytes > 0;
if (showBar)
{ {
boxHeight += perPlayerBarHeight + spacingY; boxHeight += perPlayerBarHeight + spacingY;
} }
@@ -630,8 +633,6 @@ public class DownloadUi : WindowMediatorSubscriberBase
); );
cursor.Y += lineHeight * 1.4f + spacingY; cursor.Y += lineHeight * 1.4f + spacingY;
if (_configService.Current.ShowPlayerLinesTransferWindow)
{
var orderedPlayers = perPlayer.OrderByDescending(p => p.TotalBytes).ToList(); var orderedPlayers = perPlayer.OrderByDescending(p => p.TotalBytes).ToList();
foreach (var p in orderedPlayers) foreach (var p in orderedPlayers)
@@ -641,19 +642,12 @@ public class DownloadUi : WindowMediatorSubscriberBase
? $"{UiSharedService.ByteToString((long)p.SpeedBytesPerSecond)}/s" ? $"{UiSharedService.ByteToString((long)p.SpeedBytesPerSecond)}/s"
: "-"; : "-";
// Label line for the player var showBar = _configService.Current.ShowPlayerSpeedBarsTransferWindow
&& p.TransferredBytes > 0;
var labelLine = var labelLine =
$"{p.Name} [W:{p.DlSlot}/Q:{p.DlQueue}/P:{p.DlProg}/D:{p.DlDecomp}] {p.TransferredFiles}/{p.TotalFiles}"; $"{p.Name} [W:{p.DlSlot}/Q:{p.DlQueue}/P:{p.DlProg}/D:{p.DlDecomp}] {p.TransferredFiles}/{p.TotalFiles}";
// State flags
var isDownloading = p.DlProg > 0;
var isDecompressing = p.DlDecomp > 0
|| (!isDownloading && p.TotalBytes > 0 && p.TransferredBytes >= p.TotalBytes);
var showBar = _configService.Current.ShowPlayerSpeedBarsTransferWindow
&& (isDownloading || isDecompressing);
if (!showBar) if (!showBar)
{ {
UiSharedService.DrawOutlinedFont( UiSharedService.DrawOutlinedFont(
@@ -669,7 +663,6 @@ public class DownloadUi : WindowMediatorSubscriberBase
continue; continue;
} }
// Top label line (only name + W/Q/P/D + files)
UiSharedService.DrawOutlinedFont( UiSharedService.DrawOutlinedFont(
drawList, drawList,
labelLine, labelLine,
@@ -691,15 +684,10 @@ public class DownloadUi : WindowMediatorSubscriberBase
3f 3f
); );
// Fill based on Progress of download
float ratio = 0f; float ratio = 0f;
if (isDownloading && p.TotalBytes > 0) if (p.TotalBytes > 0)
{
ratio = (float)p.TransferredBytes / p.TotalBytes; ratio = (float)p.TransferredBytes / p.TotalBytes;
}
else if (isDecompressing)
{
ratio = 1f;
}
if (ratio < 0f) ratio = 0f; if (ratio < 0f) ratio = 0f;
if (ratio > 1f) ratio = 1f; if (ratio > 1f) ratio = 1f;
@@ -714,9 +702,17 @@ public class DownloadUi : WindowMediatorSubscriberBase
3f 3f
); );
// Text inside bar: downloading vs decompressing
string barText; string barText;
if (isDownloading) var isDecompressing = p.DlDecomp > 0 && p.TransferredBytes >= p.TotalBytes && p.TotalBytes > 0;
if (isDecompressing)
{
// Keep bar full, static text showing decompressing
barText = "Decompressing...";
}
else
{ {
var bytesInside = var bytesInside =
$"{UiSharedService.ByteToString(p.TransferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(p.TotalBytes)}"; $"{UiSharedService.ByteToString(p.TransferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(p.TotalBytes)}";
@@ -725,18 +721,11 @@ public class DownloadUi : WindowMediatorSubscriberBase
? $"{bytesInside} @ {playerSpeedText}" ? $"{bytesInside} @ {playerSpeedText}"
: bytesInside; : bytesInside;
} }
else if (isDecompressing)
{
barText = "Decompressing...";
}
else
{
barText = string.Empty;
}
if (!string.IsNullOrEmpty(barText)) if (!string.IsNullOrEmpty(barText))
{ {
var barTextSize = ImGui.CalcTextSize(barText); var barTextSize = ImGui.CalcTextSize(barText);
var barTextPos = new Vector2( var barTextPos = new Vector2(
barBgMin.X + ((barBgMax.X - barBgMin.X) - barTextSize.X) / 2f - 1, barBgMin.X + ((barBgMax.X - barBgMin.X) - barTextSize.X) / 2f - 1,
barBgMin.Y + ((perPlayerBarHeight - barTextSize.Y) / 2f) - 1 barBgMin.Y + ((perPlayerBarHeight - barTextSize.Y) / 2f) - 1
@@ -755,7 +744,6 @@ public class DownloadUi : WindowMediatorSubscriberBase
cursor.Y += perPlayerBarHeight + spacingY; cursor.Y += perPlayerBarHeight + spacingY;
} }
} }
}
public override bool DrawConditions() public override bool DrawConditions()
{ {