add a dump everything to PNG options for @xanax

This commit is contained in:
Matthias Mailänder
2013-04-28 20:36:18 +02:00
parent 7f40f59d85
commit 0c1b6f21b9
4 changed files with 39 additions and 10 deletions

View File

@@ -26,14 +26,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
static ShpImageWidget spriteImage; static ShpImageWidget spriteImage;
static TextFieldWidget filenameInput; static TextFieldWidget filenameInput;
static SliderWidget frameSlider; static SliderWidget frameSlider;
static ButtonWidget playButton; static ButtonWidget playButton, pauseButton;
static ButtonWidget pauseButton;
static ScrollPanelWidget assetList; static ScrollPanelWidget assetList;
static ScrollItemWidget template; static ScrollItemWidget template;
public enum SourceType { Folders, Packages } public enum SourceType { Folders, Packages }
public static SourceType AssetSource = SourceType.Folders; public static SourceType AssetSource = SourceType.Folders;
public static List<string> AvailableShps = new List<string>();
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public AssetBrowserLogic(Widget widget, Action onExit, World world) public AssetBrowserLogic(Widget widget, Action onExit, World world)
{ {
@@ -95,10 +96,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
template = panel.Get<ScrollItemWidget>("ASSET_TEMPLATE"); template = panel.Get<ScrollItemWidget>("ASSET_TEMPLATE");
PopulateAssetList(); PopulateAssetList();
var palette = (WidgetUtils.ActiveModId() == "d2k") ? "d2k.pal" : "egopal.pal";
panel.Get<ButtonWidget>("EXPORT_BUTTON").OnClick = () => panel.Get<ButtonWidget>("EXPORT_BUTTON").OnClick = () =>
{ {
var palette = (WidgetUtils.ActiveModId() == "d2k") ? "d2k.pal" : "egopal.pal";
var ExtractGameFiles = new string[][] var ExtractGameFiles = new string[][]
{ {
new string[] {"--extract", WidgetUtils.ActiveModId(), palette}, new string[] {"--extract", WidgetUtils.ActiveModId(), palette},
@@ -115,7 +116,32 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ "ExtractGameFiles", ExtractGameFiles }, { "ExtractGameFiles", ExtractGameFiles },
{ "ExportToPng", ExportToPng } { "ExportToPng", ExportToPng }
}; };
Ui.OpenWindow("EXTRACT_ASSETS_PANEL", args);
};
panel.Get<ButtonWidget>("EXTRACT_BUTTON").OnClick = () =>
{
var ExtractGameFilesList = new List<string[]>();
var ExportToPngList = new List<string[]>();
ExtractGameFilesList.Add(new string[] { "--extract", WidgetUtils.ActiveModId(), palette} );
foreach (var shp in AvailableShps)
{
ExtractGameFilesList.Add(new string[] { "--extract", WidgetUtils.ActiveModId(), shp } );
ExportToPngList.Add(new string[] { "--png", shp, palette } );
}
var ExtractGameFiles = ExtractGameFilesList.ToArray();
var ExportToPng = ExportToPngList.ToArray();
var args = new WidgetArgs()
{
{ "ExtractGameFiles", ExtractGameFiles },
{ "ExportToPng", ExportToPng }
};
Ui.OpenWindow("EXTRACT_ASSETS_PANEL", args); Ui.OpenWindow("EXTRACT_ASSETS_PANEL", args);
}; };
@@ -171,6 +197,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public static void PopulateAssetList() public static void PopulateAssetList()
{ {
assetList.RemoveChildren(); assetList.RemoveChildren();
AvailableShps.Clear();
if (AssetSource == SourceType.Folders) if (AssetSource == SourceType.Folders)
{ {
@@ -180,14 +207,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
var shps = Directory.GetFiles(folder, "*.shp"); var shps = Directory.GetFiles(folder, "*.shp");
foreach (var shp in shps) foreach (var shp in shps)
{
AddAsset(assetList, shp, template); AddAsset(assetList, shp, template);
AvailableShps.Add(shp);
}
} }
} }
} }
if (AssetSource == SourceType.Packages) if (AssetSource == SourceType.Packages)
foreach (var hiddenFile in Rules.PackageContents.Keys) foreach (var hiddenFile in Rules.PackageContents.Keys)
{
AddAsset(assetList, hiddenFile, template); AddAsset(assetList, hiddenFile, template);
AvailableShps.Add(hiddenFile);
}
} }
} }
} }

View File

@@ -46,9 +46,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
extractingContainer = panel.Get("EXTRACTING"); extractingContainer = panel.Get("EXTRACTING");
this.ExtractGameFiles = ExtractGameFiles; this.ExtractGameFiles = ExtractGameFiles;
foreach (var s in ExtractGameFiles)
foreach (var ss in s)
Console.WriteLine(ss);
this.ExportToPng = ExportToPng; this.ExportToPng = ExportToPng;
Extract(); Extract();

View File

@@ -99,7 +99,6 @@ Background@ASSETBROWSER_BG:
Height:25 Height:25
Text:Extract all to PNG Text:Extract all to PNG
Font:Bold Font:Bold
Disabled: yes
Button@EXPORT_BUTTON: Button@EXPORT_BUTTON:
X:PARENT_RIGHT - 200 X:PARENT_RIGHT - 200
Y:PARENT_BOTTOM - 200 Y:PARENT_BOTTOM - 200

View File

@@ -28,7 +28,7 @@ agun.shp:
agunmake.shp: agunmake.shp:
apc.shp: apc.shp:
apwr.shp: apwr.shp:
apwramke.shp: apwrmake.shp:
armor.shp: armor.shp:
art-exp1.shp: art-exp1.shp:
arty.shp: arty.shp:
@@ -39,7 +39,7 @@ atomicup.shp:
atomsfx.shp: atomsfx.shp:
badr.shp: badr.shp:
bar3bhr.shp: bar3bhr.shp:
bar3blue.shp: bar3blu.shp:
bar3red.shp: bar3red.shp:
bar3rhr.shp: bar3rhr.shp:
barb.shp: barb.shp: