Fixed height issue of download box
This commit is contained in:
@@ -560,9 +560,12 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
|||||||
{
|
{
|
||||||
foreach (var p in perPlayer)
|
foreach (var p in perPlayer)
|
||||||
{
|
{
|
||||||
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,46 +633,23 @@ 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();
|
||||||
|
|
||||||
|
foreach (var p in orderedPlayers)
|
||||||
{
|
{
|
||||||
var orderedPlayers = perPlayer.OrderByDescending(p => p.TotalBytes).ToList();
|
var hasSpeed = p.SpeedBytesPerSecond > 0;
|
||||||
|
var playerSpeedText = hasSpeed
|
||||||
|
? $"{UiSharedService.ByteToString((long)p.SpeedBytesPerSecond)}/s"
|
||||||
|
: "-";
|
||||||
|
|
||||||
foreach (var p in orderedPlayers)
|
var showBar = _configService.Current.ShowPlayerSpeedBarsTransferWindow
|
||||||
|
&& p.TransferredBytes > 0;
|
||||||
|
|
||||||
|
var labelLine =
|
||||||
|
$"{p.Name} [W:{p.DlSlot}/Q:{p.DlQueue}/P:{p.DlProg}/D:{p.DlDecomp}] {p.TransferredFiles}/{p.TotalFiles}";
|
||||||
|
|
||||||
|
if (!showBar)
|
||||||
{
|
{
|
||||||
var hasSpeed = p.SpeedBytesPerSecond > 0;
|
|
||||||
var playerSpeedText = hasSpeed
|
|
||||||
? $"{UiSharedService.ByteToString((long)p.SpeedBytesPerSecond)}/s"
|
|
||||||
: "-";
|
|
||||||
|
|
||||||
// Label line for the player
|
|
||||||
var labelLine =
|
|
||||||
$"{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)
|
|
||||||
{
|
|
||||||
UiSharedService.DrawOutlinedFont(
|
|
||||||
drawList,
|
|
||||||
labelLine,
|
|
||||||
cursor,
|
|
||||||
UiSharedService.Color(255, 255, 255, _transferBoxTransparency),
|
|
||||||
UiSharedService.Color(0, 0, 0, _transferBoxTransparency),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
cursor.Y += lineHeight + spacingY;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Top label line (only name + W/Q/P/D + files)
|
|
||||||
UiSharedService.DrawOutlinedFont(
|
UiSharedService.DrawOutlinedFont(
|
||||||
drawList,
|
drawList,
|
||||||
labelLine,
|
labelLine,
|
||||||
@@ -678,82 +658,90 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
|||||||
UiSharedService.Color(0, 0, 0, _transferBoxTransparency),
|
UiSharedService.Color(0, 0, 0, _transferBoxTransparency),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
cursor.Y += lineHeight + spacingY;
|
cursor.Y += lineHeight + spacingY;
|
||||||
|
continue;
|
||||||
// Bar background
|
|
||||||
var barBgMin = new Vector2(boxMin.X + padding, cursor.Y);
|
|
||||||
var barBgMax = new Vector2(boxMax.X - padding, cursor.Y + perPlayerBarHeight);
|
|
||||||
|
|
||||||
drawList.AddRectFilled(
|
|
||||||
barBgMin,
|
|
||||||
barBgMax,
|
|
||||||
UiSharedService.Color(40, 40, 40, _transferBoxTransparency),
|
|
||||||
3f
|
|
||||||
);
|
|
||||||
|
|
||||||
float ratio = 0f;
|
|
||||||
if (isDownloading && p.TotalBytes > 0)
|
|
||||||
{
|
|
||||||
ratio = (float)p.TransferredBytes / p.TotalBytes;
|
|
||||||
}
|
|
||||||
else if (isDecompressing)
|
|
||||||
{
|
|
||||||
ratio = 1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ratio < 0f) ratio = 0f;
|
|
||||||
if (ratio > 1f) ratio = 1f;
|
|
||||||
|
|
||||||
var fillX = barBgMin.X + (barBgMax.X - barBgMin.X) * ratio;
|
|
||||||
var barFillMax = new Vector2(fillX, barBgMax.Y);
|
|
||||||
|
|
||||||
drawList.AddRectFilled(
|
|
||||||
barBgMin,
|
|
||||||
barFillMax,
|
|
||||||
UiSharedService.Color(UIColors.Get("LightlessPurple")),
|
|
||||||
3f
|
|
||||||
);
|
|
||||||
|
|
||||||
string barText;
|
|
||||||
|
|
||||||
if (isDownloading)
|
|
||||||
{
|
|
||||||
var bytesInside =
|
|
||||||
$"{UiSharedService.ByteToString(p.TransferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(p.TotalBytes)}";
|
|
||||||
|
|
||||||
barText = hasSpeed
|
|
||||||
? $"{bytesInside} @ {playerSpeedText}"
|
|
||||||
: bytesInside;
|
|
||||||
}
|
|
||||||
else if (isDecompressing)
|
|
||||||
{
|
|
||||||
barText = "Decompressing...";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
barText = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(barText))
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UiSharedService.DrawOutlinedFont(
|
||||||
|
drawList,
|
||||||
|
labelLine,
|
||||||
|
cursor,
|
||||||
|
UiSharedService.Color(255, 255, 255, _transferBoxTransparency),
|
||||||
|
UiSharedService.Color(0, 0, 0, _transferBoxTransparency),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
cursor.Y += lineHeight + spacingY;
|
||||||
|
|
||||||
|
// Bar background
|
||||||
|
var barBgMin = new Vector2(boxMin.X + padding, cursor.Y);
|
||||||
|
var barBgMax = new Vector2(boxMax.X - padding, cursor.Y + perPlayerBarHeight);
|
||||||
|
|
||||||
|
drawList.AddRectFilled(
|
||||||
|
barBgMin,
|
||||||
|
barBgMax,
|
||||||
|
UiSharedService.Color(40, 40, 40, _transferBoxTransparency),
|
||||||
|
3f
|
||||||
|
);
|
||||||
|
|
||||||
|
// Fill based on Progress of download
|
||||||
|
float ratio = 0f;
|
||||||
|
if (p.TotalBytes > 0)
|
||||||
|
ratio = (float)p.TransferredBytes / p.TotalBytes;
|
||||||
|
|
||||||
|
if (ratio < 0f) ratio = 0f;
|
||||||
|
if (ratio > 1f) ratio = 1f;
|
||||||
|
|
||||||
|
var fillX = barBgMin.X + (barBgMax.X - barBgMin.X) * ratio;
|
||||||
|
var barFillMax = new Vector2(fillX, barBgMax.Y);
|
||||||
|
|
||||||
|
drawList.AddRectFilled(
|
||||||
|
barBgMin,
|
||||||
|
barFillMax,
|
||||||
|
UiSharedService.Color(UIColors.Get("LightlessPurple")),
|
||||||
|
3f
|
||||||
|
);
|
||||||
|
|
||||||
|
// Text inside bar: downloading vs decompressing
|
||||||
|
string barText;
|
||||||
|
|
||||||
|
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 =
|
||||||
|
$"{UiSharedService.ByteToString(p.TransferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(p.TotalBytes)}";
|
||||||
|
|
||||||
|
barText = hasSpeed
|
||||||
|
? $"{bytesInside} @ {playerSpeedText}"
|
||||||
|
: bytesInside;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(barText))
|
||||||
|
{
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user