experimenting with auto-downloader, sandworm

This commit is contained in:
Matthias Mailänder
2012-06-10 21:13:40 +02:00
parent d110b45679
commit f9cbd1bbbf
12 changed files with 249 additions and 8 deletions

View File

@@ -62,6 +62,7 @@
<Compile Include="Widgets\Logic\D2kInstallLogic.cs" />
<Compile Include="Widgets\Logic\D2kExtractGameFilesLogic.cs" />
<Compile Include="Widgets\Logic\D2kInstallFromCDLogic.cs" />
<Compile Include="Widgets\Logic\D2kDownloadPackagesLogic.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@@ -0,0 +1,111 @@
#region Copyright & License Information
/*
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using OpenRA.FileFormats;
using OpenRA.Widgets;
namespace OpenRA.Mods.D2k.Widgets.Logic
{
public class D2kDownloadPackagesLogic
{
Widget panel;
Dictionary<string,string> installData;
ProgressBarWidget progressBar;
LabelWidget statusLabel;
Action afterInstall;
[ObjectCreator.UseCtor]
public D2kDownloadPackagesLogic(Widget widget, Dictionary<string,string> installData, Action afterInstall)
{
this.installData = installData;
this.afterInstall = afterInstall;
panel = widget.Get("INSTALL_DOWNLOAD_PANEL");
progressBar = panel.Get<ProgressBarWidget>("PROGRESS_BAR");
statusLabel = panel.Get<LabelWidget>("STATUS_LABEL");
ShowDownloadDialog();
}
void ShowDownloadDialog()
{
statusLabel.GetText = () => "Initializing...";
progressBar.SetIndeterminate(true);
var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
retryButton.IsVisible = () => false;
var cancelButton = panel.Get<ButtonWidget>("CANCEL_BUTTON");
// Save the package to a temp file
var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var dest = new string[] { Platform.SupportDir, "Content", Game.modData.Manifest.Mods[0] }.Aggregate(Path.Combine);
Action<DownloadProgressChangedEventArgs> onDownloadProgress = i =>
{
if (progressBar.Indeterminate)
progressBar.SetIndeterminate(false);
progressBar.Percentage = i.ProgressPercentage;
statusLabel.GetText = () => "Downloading {1}/{2} kB ({0}%)".F(i.ProgressPercentage, i.BytesReceived / 1024, i.TotalBytesToReceive / 1024);
};
Action<string> onExtractProgress = s =>
{
Game.RunAfterTick(() => statusLabel.GetText = () => s);
};
Action<string> onError = s =>
{
Game.RunAfterTick(() =>
{
statusLabel.GetText = () => "Error: "+s;
retryButton.IsVisible = () => true;
});
};
Action<AsyncCompletedEventArgs, bool> onDownloadComplete = (i, cancelled) =>
{
if (i.Error != null)
{
onError(Download.FormatErrorMessage(i.Error));
return;
}
else if (cancelled)
{
onError("Download cancelled");
return;
}
// Automatically extract
statusLabel.GetText = () => "Extracting...";
progressBar.SetIndeterminate(true);
if (InstallUtils.ExtractZip(file, dest, onExtractProgress, onError))
{
Game.RunAfterTick(() =>
{
Ui.CloseWindow();
//afterInstall();
});
}
};
var dl = new Download(installData["PackageURL"], file, onDownloadProgress, onDownloadComplete);
cancelButton.OnClick = () => { dl.Cancel(); Ui.CloseWindow(); };
retryButton.OnClick = () => { dl.Cancel(); ShowDownloadDialog(); };
}
}
}

View File

@@ -26,6 +26,9 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
{ "installData", installData }
};
panel.Get<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () =>
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
panel.Get<ButtonWidget>("COPY_BUTTON").OnClick = () =>
Ui.OpenWindow("INSTALL_FROMCD_PANEL", args);

View File

@@ -18,7 +18,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.</OutputPath>
<OutputPath>..\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

View File

@@ -37,3 +37,6 @@
# gamefile extraction (setup/setup.z) from CD fails
# support patch 1.06 gamefiles: DATA.R8 has more frames and currently fails to extract, also featuring new terrain with white houses and new unit: grenade thrower
# mouse cursor has no transparency and is a little pixelish
# mouse cursor does not change for infantry-only areas (Rough)
# put TilesetBuilder.Export into OpenRA.Utility
# create a minimal Freeware auto-download version from patch 1.06 files

View File

@@ -69,6 +69,13 @@ Background@INSTALL_PANEL:
Height:25
Text:Copy Music
Font:Bold
Button@DOWNLOAD_BUTTON:
X:PARENT_RIGHT - 560
Y:PARENT_BOTTOM - 45
Width:120
Height:25
Text:Download
Font:Bold
Button@QUIT_BUTTON:
X:PARENT_RIGHT - 140
Y:PARENT_BOTTOM - 45
@@ -77,6 +84,50 @@ Background@INSTALL_PANEL:
Text:Quit
Font:Bold
Background@INSTALL_DOWNLOAD_PANEL:
Logic:D2kDownloadPackagesLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:500
Height:160
Children:
Label@TITLE:
X:0
Y:20
Width:PARENT_RIGHT
Height:25
Text:Downloading Dune 2000 Content
Align:Center
Font:Bold
ProgressBar@PROGRESS_BAR:
X:50
Y:55
Width:PARENT_RIGHT - 100
Height:25
Label@STATUS_LABEL:
X:50
Y:80
Width:PARENT_RIGHT - 100
Height:25
Align:Left
Button@RETRY_BUTTON:
X:PARENT_RIGHT - 280
Y:PARENT_BOTTOM - 45
Width:120
Height:25
Visible: false
Text:Retry
Font:Bold
Key:return
Button@CANCEL_BUTTON:
X:PARENT_RIGHT - 140
Y:PARENT_BOTTOM - 45
Width:120
Height:25
Text:Cancel
Font:Bold
Key:escape
Background@INSTALL_FROMCD_PANEL:
Logic:D2kInstallFromCDLogic
X:(WINDOW_RIGHT - WIDTH)/2

Binary file not shown.

View File

@@ -93,6 +93,7 @@ Movies:
LoadScreen: D2kLoadScreen
InstallerMenuWidget: INSTALL_PANEL
TestFile: carryall.shp
PackageURL: DunePatch106R8Data.zip
ServerTraits:
LobbyCommands

View File

@@ -1,7 +1,7 @@
^Vehicle:
AppearsOnRadar:
Mobile:
Crushes: crate
Crushes: crate, worm
TerrainSpeeds:
Sand: 80
Rock: 90
@@ -34,7 +34,7 @@
^Tank:
AppearsOnRadar:
Mobile:
Crushes: crate
Crushes: crate, worm
TerrainSpeeds:
Sand: 80
Rock: 90

View File

@@ -284,3 +284,28 @@ SPICEBLOOM:
ResourceType: Spice
RadarColorFromTerrain:
Terrain: Spice
SANDWORM:
Inherits: ^Infantry
Buildable:
Owner: Creep
Valued:
Cost: 1000
Tooltip:
Name: Sandworm
Description: Attracted by vibrations in the sand. Will eat units whole and has a large appetite.
Icon: sandwormdust
Health:
HP: 10000
Mobile:
Speed: 5
TerrainSpeeds:
Sand: 100
Dune: 100
AutoTarget:
AttackWander:
AttackLeap:
PrimaryWeapon: WormJaw
CanAttackGround: no
RenderInfantry:
BelowUnits:

View File

@@ -882,7 +882,6 @@ parach:
Start: 5
Length: 11
spicebloom:
make:
Start: 0
@@ -892,3 +891,39 @@ spicebloom:
Length: 1
idle:
Start: 2
sandworm:
stand: wormsigns2
Start: 0
Length: *
Tick: 150
run: sandwormdust
Start: 0
Facings: 4
Length: 5
Tick: 150
die1: sandwormdust
Start: 0
Length: 1
die2: sandwormdust
Start: 0
Length: 1
die3: sandwormdust
Start: 0
Length: 1
die4: sandwormdust
Start: 0
Length: 1
die5: sandwormdust
Start: 0
Length: 1
die6: sandwormdust
Start: 0
Length: 1
die-crushed: sandwormdust
Start: 0
Length: 1
Tick: 1600
wormattack: sandwormmouth
Start: 0
Length: 15

View File

@@ -429,3 +429,14 @@ UnitExplodeSmall:
Explosion: large_explosion
InfDeath: 3
ImpactSound: kaboom15
WormJaw:
ROF: 10
Range: 3
Report: AI_WATTK
Warhead:
Spread: 5
Versus:
Wood: 0%
Concrete: 0%
Damage: 100