Implement extension importer.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Unity;
|
||||
using Cryville.Crtr.Extension;
|
||||
using Cryville.Crtr.Extensions;
|
||||
using Cryville.Crtr.Extensions.Umg;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
@@ -153,8 +154,14 @@ namespace Cryville.Crtr.Browsing {
|
||||
else if (res is FileResource) {
|
||||
var tres = (FileResource)res;
|
||||
DirectoryInfo dest;
|
||||
bool singleFileFlag = false;
|
||||
if (res is ChartResource)
|
||||
dest = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
|
||||
else if (res is ExtensionResource) {
|
||||
dest = new DirectoryInfo(_rootPath + "/extensions");
|
||||
singleFileFlag = true;
|
||||
Popup.Create("Please restart the game to reload the extensions");
|
||||
}
|
||||
else if (res is RulesetResource)
|
||||
dest = new DirectoryInfo(_rootPath + "/rulesets/" + res.Name);
|
||||
else if (res is SkinResource)
|
||||
@@ -165,10 +172,11 @@ namespace Cryville.Crtr.Browsing {
|
||||
LogAndPopup(3, "Attempt to import unsupported file resource: {0}", res);
|
||||
continue;
|
||||
}
|
||||
if (!dest.Exists) {
|
||||
if (singleFileFlag || !dest.Exists) {
|
||||
dest.Create();
|
||||
tres.Master.CopyTo(Path.Combine(dest.FullName, tres.Master.Extension));
|
||||
tres.Master.CopyTo(Path.Combine(dest.FullName, singleFileFlag ? tres.Master.Name : tres.Master.Extension));
|
||||
foreach (var attachment in tres.Attachments) {
|
||||
if (singleFileFlag) throw new InvalidOperationException("Internal error");
|
||||
attachment.CopyTo(Path.Combine(dest.FullName, attachment.Name));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user