downloader works.
This commit is contained in:
@@ -146,6 +146,8 @@ namespace OpenRa.Game
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
DrawDownloadBar();
|
||||
|
||||
if (!Game.orderManager.GameStarted)
|
||||
{
|
||||
DrawLobby();
|
||||
@@ -184,6 +186,36 @@ namespace OpenRa.Game
|
||||
DrawOptionsMenu();
|
||||
}
|
||||
|
||||
public void DrawDownloadBar()
|
||||
{
|
||||
if (PackageDownloader.IsIdle())
|
||||
return;
|
||||
|
||||
var r = new Rectangle((Game.viewport.Width - 400) / 2, Game.viewport.Height - 110, 400, 100);
|
||||
DrawDialogBackground(r, optionsSprites, true);
|
||||
|
||||
DrawCentered("Downloading: {0} (+{1} more)".F(
|
||||
PackageDownloader.CurrentPackage.Split(':')[0],
|
||||
PackageDownloader.RemainingPackages),
|
||||
new int2( Game.viewport.Width /2, Game.viewport.Height - 90),
|
||||
Color.White);
|
||||
|
||||
DrawDialogBackground(new Rectangle(r.Left + 30, r.Top + 50, r.Width - 60, 20),
|
||||
panelSprites, false);
|
||||
|
||||
var x1 = r.Left + 35;
|
||||
var x2 = r.Right - 35;
|
||||
var x = float2.Lerp(x1, x2, PackageDownloader.Fraction);
|
||||
|
||||
for (var y = r.Top + 55; y < r.Top + 65; y++)
|
||||
lineRenderer.DrawLine(
|
||||
new float2(x1, y) + Game.viewport.Location,
|
||||
new float2(x, y) + Game.viewport.Location,
|
||||
Color.White, Color.White);
|
||||
|
||||
lineRenderer.Flush();
|
||||
}
|
||||
|
||||
public void DrawLobby()
|
||||
{
|
||||
var w = 800;
|
||||
@@ -199,17 +231,17 @@ namespace OpenRa.Game
|
||||
panelSprites, false);
|
||||
|
||||
renderer.DrawText2("Name", new int2(r.Left + 30, r.Top + 50), Color.White);
|
||||
renderer.DrawText2("Color", new int2(r.Left + 250, r.Top + 50), Color.White);
|
||||
renderer.DrawText2("Faction", new int2(r.Left + 320, r.Top + 50), Color.White);
|
||||
renderer.DrawText2("Status", new int2(r.Left + 390, r.Top + 50), Color.White);
|
||||
renderer.DrawText2("Color", new int2(r.Left + 230, r.Top + 50), Color.White);
|
||||
renderer.DrawText2("Faction", new int2(r.Left + 300, r.Top + 50), Color.White);
|
||||
renderer.DrawText2("Status", new int2(r.Left + 370, r.Top + 50), Color.White);
|
||||
|
||||
var y = r.Top + 80;
|
||||
foreach (var client in Game.LobbyInfo.Clients)
|
||||
{
|
||||
renderer.DrawText(client.Name, new int2(r.Left + 30, y), Color.White);
|
||||
renderer.DrawText(((PaletteType)client.Palette).ToString(), new int2(r.Left + 250, y), Color.White);
|
||||
renderer.DrawText(((Race)client.Race).ToString(), new int2(r.Left + 320, y), Color.White);
|
||||
renderer.DrawText(client.State.ToString(), new int2(r.Left + 390, y), Color.White);
|
||||
renderer.DrawText(((PaletteType)client.Palette).ToString(), new int2(r.Left + 230, y), Color.White);
|
||||
renderer.DrawText(((Race)client.Race).ToString(), new int2(r.Left + 300, y), Color.White);
|
||||
renderer.DrawText(client.State.ToString(), new int2(r.Left + 370, y), Color.White);
|
||||
y += 30;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,11 @@ namespace OpenRa.Game
|
||||
public static Minimap minimap;
|
||||
public static Session LobbyInfo = new Session();
|
||||
public static int2[] SpawnPoints;
|
||||
static bool changePending;
|
||||
|
||||
public static void ChangeMap(string mapName)
|
||||
{
|
||||
Game.changePending = false;
|
||||
Game.mapName = mapName;
|
||||
SheetBuilder.Initialize(renderer);
|
||||
SpriteSheetBuilder.Initialize();
|
||||
@@ -170,6 +172,12 @@ namespace OpenRa.Game
|
||||
|
||||
public static void Tick()
|
||||
{
|
||||
if (changePending && PackageDownloader.IsIdle())
|
||||
{
|
||||
ChangeMap(LobbyInfo.GlobalSettings.Map);
|
||||
return;
|
||||
}
|
||||
|
||||
int t = Environment.TickCount;
|
||||
int dt = t - lastTime;
|
||||
if (dt >= Settings.Timestep)
|
||||
@@ -392,7 +400,10 @@ namespace OpenRa.Game
|
||||
|
||||
PackageDownloader.SetPackageList(LobbyInfo.GlobalSettings.Packages);
|
||||
if (!PackageDownloader.IsIdle())
|
||||
{
|
||||
changePending = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mapName != LobbyInfo.GlobalSettings.Map)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using OpenRa.FileFormats;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
@@ -14,6 +15,11 @@ namespace OpenRa.Game
|
||||
static string currentPackage = null;
|
||||
static MemoryStream content = null;
|
||||
|
||||
public static string CurrentPackage { get { return currentPackage; } }
|
||||
public static int RemainingPackages { get { return missingPackages.Count; } }
|
||||
public static float Fraction { get; private set; }
|
||||
public static int DownloadedBytes { get { return (int)content.Length; } }
|
||||
|
||||
public static void SetPackageList(string[] packages)
|
||||
{
|
||||
allPackages = packages;
|
||||
@@ -21,6 +27,8 @@ namespace OpenRa.Game
|
||||
|
||||
if (currentPackage == null || !missingPackages.Contains(currentPackage))
|
||||
BeginDownload();
|
||||
else
|
||||
missingPackages.Remove(currentPackage);
|
||||
}
|
||||
|
||||
class Chunk { public int Index = 0; public int Count = 0; public string Data = ""; }
|
||||
@@ -32,6 +40,8 @@ namespace OpenRa.Game
|
||||
var bytes = Convert.FromBase64String(c.Data);
|
||||
content.Write(bytes, 0, bytes.Length);
|
||||
|
||||
Fraction = (float)c.Index / c.Count;
|
||||
|
||||
if (c.Index == c.Count - 1)
|
||||
EndDownload();
|
||||
}
|
||||
@@ -49,9 +59,12 @@ namespace OpenRa.Game
|
||||
|
||||
content = new MemoryStream();
|
||||
|
||||
Game.chat.AddLine(Color.White, "Debug", "Requesting package: {0}".F(currentPackage));
|
||||
|
||||
Game.controller.AddOrder(
|
||||
new Order("RequestFile", null, null, int2.Zero, currentPackage)
|
||||
{ IsImmediate = true });
|
||||
new Order("RequestFile", Game.LocalPlayer.PlayerActor, null, int2.Zero, currentPackage) { IsImmediate = true });
|
||||
|
||||
Fraction = 0f;
|
||||
}
|
||||
|
||||
static void EndDownload()
|
||||
@@ -63,6 +76,8 @@ namespace OpenRa.Game
|
||||
if (CalculateSHA1(parts[0]) != parts[1])
|
||||
throw new InvalidOperationException("Broken download");
|
||||
|
||||
Game.chat.AddLine(Color.White, "Debug", "Finished receiving package: {0}".F(currentPackage));
|
||||
|
||||
currentPackage = null;
|
||||
|
||||
BeginDownload();
|
||||
|
||||
Reference in New Issue
Block a user