(0946322ab) Fixed file transfer progress bars not being visible in NetLobbyScreen. Closes #1412
This commit is contained in:
@@ -2246,7 +2246,47 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
if (!gameStarted || Screen.Selected != GameMain.GameScreen || GUI.DisableHUD || GUI.DisableUpperHUD) return;
|
if (GUI.DisableHUD || GUI.DisableUpperHUD) return;
|
||||||
|
|
||||||
|
if (fileReceiver != null && fileReceiver.ActiveTransfers.Count > 0)
|
||||||
|
{
|
||||||
|
Vector2 downloadBarSize = new Vector2(250, 35) * GUI.Scale;
|
||||||
|
Vector2 pos = new Vector2(GameMain.NetLobbyScreen.InfoFrame.Rect.X, GameMain.GraphicsHeight - downloadBarSize.Y - 5);
|
||||||
|
|
||||||
|
GUI.DrawRectangle(spriteBatch, new Rectangle(
|
||||||
|
(int)pos.X,
|
||||||
|
(int)pos.Y,
|
||||||
|
(int)(fileReceiver.ActiveTransfers.Count * (downloadBarSize.X + 10)),
|
||||||
|
(int)downloadBarSize.Y),
|
||||||
|
Color.Black * 0.8f, true);
|
||||||
|
|
||||||
|
for (int i = 0; i < fileReceiver.ActiveTransfers.Count; i++)
|
||||||
|
{
|
||||||
|
var transfer = fileReceiver.ActiveTransfers[i];
|
||||||
|
|
||||||
|
GUI.DrawString(spriteBatch,
|
||||||
|
pos,
|
||||||
|
ToolBox.LimitString(TextManager.Get("DownloadingFile").Replace("[filename]", transfer.FileName), GUI.SmallFont, (int)downloadBarSize.X),
|
||||||
|
Color.White, null, 0, GUI.SmallFont);
|
||||||
|
GUI.DrawProgressBar(spriteBatch, new Vector2(pos.X, -pos.Y - downloadBarSize.Y / 2), new Vector2(downloadBarSize.X * 0.7f, downloadBarSize.Y / 2), transfer.Progress, Color.Green);
|
||||||
|
GUI.DrawString(spriteBatch, pos + new Vector2(5, downloadBarSize.Y / 2),
|
||||||
|
MathUtils.GetBytesReadable((long)transfer.Received) + " / " + MathUtils.GetBytesReadable((long)transfer.FileSize),
|
||||||
|
Color.White, null, 0, GUI.SmallFont);
|
||||||
|
|
||||||
|
if (GUI.DrawButton(spriteBatch, new Rectangle(
|
||||||
|
(int)(pos.X + downloadBarSize.X * 0.7f), (int)(pos.Y + downloadBarSize.Y / 2),
|
||||||
|
(int)(downloadBarSize.X * 0.3f), (int)(downloadBarSize.Y / 2)),
|
||||||
|
TextManager.Get("Cancel"), new Color(0.47f, 0.13f, 0.15f, 0.08f)))
|
||||||
|
{
|
||||||
|
CancelFileTransfer(transfer);
|
||||||
|
fileReceiver.StopTransfer(transfer);
|
||||||
|
}
|
||||||
|
|
||||||
|
pos.X += (downloadBarSize.X + 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gameStarted || Screen.Selected != GameMain.GameScreen) return;
|
||||||
|
|
||||||
inGameHUD.DrawManually(spriteBatch);
|
inGameHUD.DrawManually(spriteBatch);
|
||||||
|
|
||||||
@@ -2297,40 +2337,6 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileReceiver != null && fileReceiver.ActiveTransfers.Count > 0)
|
|
||||||
{
|
|
||||||
Vector2 pos = new Vector2(GameMain.NetLobbyScreen.InfoFrame.Rect.X, GameMain.GraphicsHeight - 35);
|
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch, new Rectangle(
|
|
||||||
(int)pos.X,
|
|
||||||
(int)pos.Y,
|
|
||||||
fileReceiver.ActiveTransfers.Count * 210 + 10,
|
|
||||||
32),
|
|
||||||
Color.Black * 0.8f, true);
|
|
||||||
|
|
||||||
for (int i = 0; i < fileReceiver.ActiveTransfers.Count; i++)
|
|
||||||
{
|
|
||||||
var transfer = fileReceiver.ActiveTransfers[i];
|
|
||||||
|
|
||||||
GUI.DrawString(spriteBatch,
|
|
||||||
pos,
|
|
||||||
ToolBox.LimitString(TextManager.Get("DownloadingFile").Replace("[filename]", transfer.FileName), GUI.SmallFont, 200),
|
|
||||||
Color.White, null, 0, GUI.SmallFont);
|
|
||||||
GUI.DrawProgressBar(spriteBatch, new Vector2(pos.X, -pos.Y - 15), new Vector2(135, 15), transfer.Progress, Color.Green);
|
|
||||||
GUI.DrawString(spriteBatch, pos + new Vector2(5, 15),
|
|
||||||
MathUtils.GetBytesReadable((long)transfer.Received) + " / " + MathUtils.GetBytesReadable((long)transfer.FileSize),
|
|
||||||
Color.White, null, 0, GUI.SmallFont);
|
|
||||||
|
|
||||||
if (GUI.DrawButton(spriteBatch, new Rectangle((int)pos.X + 140, (int)pos.Y + 18, 60, 15), TextManager.Get("Cancel"), new Color(0.47f, 0.13f, 0.15f, 0.08f)))
|
|
||||||
{
|
|
||||||
CancelFileTransfer(transfer);
|
|
||||||
fileReceiver.StopTransfer(transfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
pos.X += 210;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ShowNetStats) return;
|
if (!ShowNetStats) return;
|
||||||
|
|
||||||
netStats.Draw(spriteBatch, new Rectangle(300, 10, 300, 150));
|
netStats.Draw(spriteBatch, new Rectangle(300, 10, 300, 150));
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public NetLobbyScreen()
|
public NetLobbyScreen()
|
||||||
{
|
{
|
||||||
defaultModeContainer = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.95f), Frame.RectTransform, Anchor.Center), style: null);
|
defaultModeContainer = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.95f), Frame.RectTransform, Anchor.Center) { MaxSize = new Point(int.MaxValue, GameMain.GraphicsHeight - 100) }, style: null);
|
||||||
campaignContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.75f), Frame.RectTransform, Anchor.TopCenter), style: null)
|
campaignContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.75f), Frame.RectTransform, Anchor.TopCenter), style: null)
|
||||||
{
|
{
|
||||||
Visible = false
|
Visible = false
|
||||||
|
|||||||
Reference in New Issue
Block a user