diff --git a/OpenRA.Game/Widgets/WidgetUtils.cs b/OpenRA.Game/Widgets/WidgetUtils.cs
index ad179c422f..7120dacc3e 100644
--- a/OpenRA.Game/Widgets/WidgetUtils.cs
+++ b/OpenRA.Game/Widgets/WidgetUtils.cs
@@ -227,6 +227,12 @@ namespace OpenRA.Widgets
return Mod.AllMods[mod].Title;
}
+ public static string ActiveModId()
+ {
+ var mod = Game.modData.Manifest.Mods[0];
+ return Mod.AllMods[mod].Id;
+ }
+
public static string ChooseInitialMap(string map)
{
var availableMaps = Game.modData.AvailableMaps;
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 9bcf55ea19..5d1a147e5a 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -437,6 +437,7 @@
+
@@ -449,6 +450,10 @@
OpenRA.Game
False
+
+ {F33337BE-CB69-4B24-850F-07D23E408DDF}
+ OpenRA.Utility
+
diff --git a/OpenRA.Mods.RA/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/AssetBrowserLogic.cs
index cc6f67b072..1d3d5ea16b 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/AssetBrowserLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/AssetBrowserLogic.cs
@@ -95,6 +95,30 @@ namespace OpenRA.Mods.RA.Widgets.Logic
template = panel.Get("ASSET_TEMPLATE");
PopulateAssetList();
+ panel.Get("EXPORT_BUTTON").OnClick = () =>
+ {
+ var palette = (WidgetUtils.ActiveModId() == "d2k") ? "d2k.pal" : "egopal.pal";
+
+ var ExtractGameFiles = new string[][]
+ {
+ new string[] {"--extract", WidgetUtils.ActiveModId(), palette},
+ new string[] {"--extract", WidgetUtils.ActiveModId(), "{0}.shp".F(spriteImage.Image)},
+ };
+
+ var ExportToPng = new string[][]
+ {
+ new string[] {"--png", "{0}.shp".F(spriteImage.Image), palette},
+ };
+
+ var args = new WidgetArgs()
+ {
+ { "ExtractGameFiles", ExtractGameFiles },
+ { "ExportToPng", ExportToPng }
+ };
+
+ Ui.OpenWindow("EXTRACT_ASSETS_PANEL", args);
+ };
+
panel.Get("CLOSE_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/ExtractGameFilesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ExtractGameFilesLogic.cs
new file mode 100644
index 0000000000..db4520ff65
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/ExtractGameFilesLogic.cs
@@ -0,0 +1,103 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2013 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.IO;
+using System.Linq;
+using System.Threading;
+using System.Diagnostics;
+using OpenRA.FileFormats;
+using OpenRA.FileFormats.Graphics;
+using OpenRA.Widgets;
+using OpenRA.Utility;
+
+namespace OpenRA.Mods.RA.Widgets.Logic
+{
+ public class ExtractGameFilesLogic
+ {
+ Widget panel;
+ ProgressBarWidget progressBar;
+ LabelWidget statusLabel;
+ ButtonWidget retryButton, backButton;
+ Widget extractingContainer;
+
+ string[][] ExtractGameFiles, ExportToPng;
+
+ [ObjectCreator.UseCtor]
+ public ExtractGameFilesLogic(Widget widget, string[][] ExtractGameFiles, string[][] ExportToPng)
+ {
+ panel = widget.Get("EXTRACT_ASSETS_PANEL");
+ progressBar = panel.Get("PROGRESS_BAR");
+ statusLabel = panel.Get("STATUS_LABEL");
+
+ backButton = panel.Get("BACK_BUTTON");
+ backButton.OnClick = Ui.CloseWindow;
+
+ retryButton = panel.Get("RETRY_BUTTON");
+ retryButton.OnClick = Extract;
+
+ extractingContainer = panel.Get("EXTRACTING");
+
+ this.ExtractGameFiles = ExtractGameFiles;
+ foreach (var s in ExtractGameFiles)
+ foreach (var ss in s)
+ Console.WriteLine(ss);
+ this.ExportToPng = ExportToPng;
+
+ Extract();
+ }
+
+ void Extract()
+ {
+ backButton.IsDisabled = () => true;
+ retryButton.IsDisabled = () => true;
+ extractingContainer.IsVisible = () => true;
+
+ var onError = (Action)(s => Game.RunAfterTick(() =>
+ {
+ statusLabel.GetText = () => "Error: "+s;
+ backButton.IsDisabled = () => false;
+ retryButton.IsDisabled = () => false;
+ }));
+
+ var t = new Thread( _ =>
+ {
+ try
+ {
+ for (int i = 0; i < ExtractGameFiles.Length; i++)
+ {
+ progressBar.Percentage = i*100/ExtractGameFiles.Count();
+ statusLabel.GetText = () => "Extracting...";
+ Utility.Command.ExtractFiles(ExtractGameFiles[i]);
+ }
+
+ for (int i = 0; i < ExportToPng.Length; i++)
+ {
+ progressBar.Percentage = i*100/ExportToPng.Count();
+ statusLabel.GetText = () => "Converting...";
+ Utility.Command.ConvertShpToPng(ExportToPng[i]);
+ }
+
+ Game.RunAfterTick(() =>
+ {
+ progressBar.Percentage = 100;
+ statusLabel.GetText = () => "Extraction and conversion complete.";
+ backButton.IsDisabled = () => false;
+ });
+ }
+ catch
+ {
+ onError("Extraction or conversion failed");
+ }
+ }) { IsBackground = true };
+ t.Start();
+ }
+ }
+}
diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml
index 62442e1ebd..22ce2ee495 100644
--- a/mods/d2k/mod.yaml
+++ b/mods/d2k/mod.yaml
@@ -69,6 +69,7 @@ ChromeLayout:
mods/ra/chrome/musicplayer.yaml
mods/d2k/chrome/tooltips.yaml
mods/ra/chrome/assetbrowser.yaml
+ mods/ra/chrome/extractassets.yaml
Weapons:
mods/d2k/weapons/defaults.yaml
diff --git a/mods/ra/chrome/assetbrowser.yaml b/mods/ra/chrome/assetbrowser.yaml
index 2e3243059c..619a562a5b 100644
--- a/mods/ra/chrome/assetbrowser.yaml
+++ b/mods/ra/chrome/assetbrowser.yaml
@@ -97,7 +97,7 @@ Background@ASSETBROWSER_BG:
Y:PARENT_BOTTOM - 235
Width:160
Height:25
- Text:Extract to Folder
+ Text:Extract all to PNG
Font:Bold
Disabled: yes
Button@EXPORT_BUTTON:
@@ -105,9 +105,8 @@ Background@ASSETBROWSER_BG:
Y:PARENT_BOTTOM - 200
Width:160
Height:25
- Text:Export as PNG
+ Text:Selected to PNG
Font:Bold
- Disabled: yes
Button@CLOSE_BUTTON:
X:PARENT_RIGHT - 200
Y:PARENT_BOTTOM - 115
diff --git a/mods/ra/chrome/extractassets.yaml b/mods/ra/chrome/extractassets.yaml
new file mode 100644
index 0000000000..199eb7a06b
--- /dev/null
+++ b/mods/ra/chrome/extractassets.yaml
@@ -0,0 +1,47 @@
+Background@EXTRACT_ASSETS_PANEL:
+ Logic:ExtractGameFilesLogic
+ 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:Extracting and Converting Gamefiles
+ Align:Center
+ Font:Bold
+ Container@EXTRACTING:
+ Width:PARENT_RIGHT
+ Height:PARENT_BOTTOM
+ Visible: false
+ Children:
+ 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
+ Text:Retry
+ Font:Bold
+ Key:return
+ Button@BACK_BUTTON:
+ X:PARENT_RIGHT - 140
+ Y:PARENT_BOTTOM - 45
+ Width:120
+ Height:25
+ Text:Back
+ Font:Bold
+ Key:escape
\ No newline at end of file
diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml
index 64df95e7cf..2af52f08d0 100644
--- a/mods/ra/mod.yaml
+++ b/mods/ra/mod.yaml
@@ -78,6 +78,7 @@ ChromeLayout:
mods/ra/chrome/musicplayer.yaml
mods/ra/chrome/tooltips.yaml
mods/ra/chrome/assetbrowser.yaml
+ mods/ra/chrome/extractassets.yaml
Weapons:
mods/ra/weapons.yaml