|
|
|
@@ -6,6 +6,7 @@ using Cryville.Crtr.Extensions.Umg;
|
|
|
|
|
using Cryville.Crtr.UI;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
@@ -18,7 +19,7 @@ namespace Cryville.Crtr.Browsing {
|
|
|
|
|
private DirectoryInfo cd;
|
|
|
|
|
private DirectoryInfo[] items = new DirectoryInfo[0];
|
|
|
|
|
public string[] CurrentDirectory { get; private set; }
|
|
|
|
|
public int ItemCount { get { return items.Length; } }
|
|
|
|
|
public int Count { get { return items.Length; } }
|
|
|
|
|
|
|
|
|
|
static bool _init;
|
|
|
|
|
|
|
|
|
@@ -46,80 +47,52 @@ namespace Cryville.Crtr.Browsing {
|
|
|
|
|
ChangeDirectory(nd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReturnToDirectory(int id) {
|
|
|
|
|
string[] nd = new string[id + 1];
|
|
|
|
|
Array.Copy(CurrentDirectory, nd, id + 1);
|
|
|
|
|
public void ReturnToDirectory(int index) {
|
|
|
|
|
string[] nd = new string[index + 1];
|
|
|
|
|
Array.Copy(CurrentDirectory, nd, index + 1);
|
|
|
|
|
ChangeDirectory(nd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResourceItemMeta GetItemMeta(int id) {
|
|
|
|
|
var item = items[id];
|
|
|
|
|
var meta = new ChartMeta();
|
|
|
|
|
string name = item.Name;
|
|
|
|
|
string desc = "(Unknown)";
|
|
|
|
|
var metaFile = new FileInfo(item.FullName + "/.umgc");
|
|
|
|
|
if (metaFile.Exists) {
|
|
|
|
|
using (var reader = new StreamReader(metaFile.FullName)) {
|
|
|
|
|
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
|
|
|
|
name = meta.song.name;
|
|
|
|
|
desc = meta.name;
|
|
|
|
|
public ChartDetail this[int index] {
|
|
|
|
|
get {
|
|
|
|
|
var item = items[index];
|
|
|
|
|
ChartMeta meta = null;
|
|
|
|
|
var metaFile = new FileInfo(Path.Combine(item.FullName, ".umgc"));
|
|
|
|
|
if (metaFile.Exists) {
|
|
|
|
|
using (var reader = new StreamReader(metaFile.FullName)) {
|
|
|
|
|
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AsyncDelivery<Texture2D> cover = null;
|
|
|
|
|
if (meta.cover != null && meta.cover != "") {
|
|
|
|
|
var coverFile = item.GetFiles(meta.cover);
|
|
|
|
|
if (coverFile.Length > 0) {
|
|
|
|
|
cover = new AsyncDelivery<Texture2D>();
|
|
|
|
|
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
|
|
|
|
cover.CancelSource = task.Cancel;
|
|
|
|
|
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
|
|
|
|
AsyncDelivery<Texture2D> cover = null;
|
|
|
|
|
if (meta.cover != null && meta.cover != "") {
|
|
|
|
|
var coverFile = item.GetFiles(meta.cover);
|
|
|
|
|
if (coverFile.Length > 0) {
|
|
|
|
|
cover = new AsyncDelivery<Texture2D>();
|
|
|
|
|
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
|
|
|
|
cover.CancelSource = task.Cancel;
|
|
|
|
|
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new ChartDetail {
|
|
|
|
|
Cover = cover,
|
|
|
|
|
Meta = meta,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return new ResourceItemMeta {
|
|
|
|
|
IsDirectory = false,
|
|
|
|
|
Icon = cover,
|
|
|
|
|
Name = name,
|
|
|
|
|
DescriptionMain = desc,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ChartDetail GetItemDetail(int id) {
|
|
|
|
|
public Uri GetItemUri(int id) {
|
|
|
|
|
var item = items[id];
|
|
|
|
|
var meta = new ChartMeta();
|
|
|
|
|
var metaFile = new FileInfo(item.FullName + "/.umgc");
|
|
|
|
|
if (metaFile.Exists) {
|
|
|
|
|
using (var reader = new StreamReader(metaFile.FullName)) {
|
|
|
|
|
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AsyncDelivery<Texture2D> cover = null;
|
|
|
|
|
if (meta.cover != null && meta.cover != "") {
|
|
|
|
|
var coverFile = item.GetFiles(meta.cover);
|
|
|
|
|
if (coverFile.Length > 0) {
|
|
|
|
|
cover = new AsyncDelivery<Texture2D>();
|
|
|
|
|
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
|
|
|
|
cover.CancelSource = task.Cancel;
|
|
|
|
|
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new ChartDetail {
|
|
|
|
|
Cover = cover,
|
|
|
|
|
Meta = meta,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetItemPath(int id) {
|
|
|
|
|
var item = items[id];
|
|
|
|
|
var meta = new ChartMeta();
|
|
|
|
|
var metaFile = new FileInfo(item.FullName + "/.umgc");
|
|
|
|
|
var metaFile = new FileInfo(Path.Combine(item.FullName, ".umgc"));
|
|
|
|
|
using (var reader = new StreamReader(metaFile.FullName)) {
|
|
|
|
|
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
|
|
|
|
}
|
|
|
|
|
return string.Format("{0}/{1}.json", items[id].Name, meta.data);
|
|
|
|
|
return new Uri(Path.Combine(items[id].Name, string.Format("{0}.json", meta.data)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ImportItemFrom(string path) {
|
|
|
|
|
var file = new FileInfo(path);
|
|
|
|
|
public bool ImportItemFrom(Uri uri) {
|
|
|
|
|
if (!uri.IsFile) throw new NotSupportedException();
|
|
|
|
|
var file = new FileInfo(uri.LocalPath);
|
|
|
|
|
IEnumerable<ResourceConverter> converters;
|
|
|
|
|
if (!ExtensionManager.TryGetConverters(file.Extension, out converters)) return false;
|
|
|
|
|
foreach (var converter in converters) {
|
|
|
|
@@ -195,6 +168,27 @@ namespace Cryville.Crtr.Browsing {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Enumerator GetEnumerator() { return new Enumerator(this); }
|
|
|
|
|
IEnumerator<ChartDetail> IEnumerable<ChartDetail>.GetEnumerator() { return GetEnumerator(); }
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
|
|
|
|
|
|
|
|
|
public struct Enumerator : IEnumerator<ChartDetail> {
|
|
|
|
|
readonly LegacyResourceManager _list;
|
|
|
|
|
public ChartDetail Current => throw new NotImplementedException();
|
|
|
|
|
object IEnumerator.Current => Current;
|
|
|
|
|
|
|
|
|
|
public Enumerator(LegacyResourceManager list) { _list = list; }
|
|
|
|
|
public void Dispose() { }
|
|
|
|
|
|
|
|
|
|
public bool MoveNext() {
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Reset() {
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LogAndPopup(int level, string format, params object[] args) {
|
|
|
|
|
var msg = string.Format(format, args);
|
|
|
|
|
Logger.Log("main", level, "Resource", msg);
|
|
|
|
|