Implement preset path in file dialog.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public interface IResourceManager<T> {
|
||||
string[] CurrentDirectory { get; }
|
||||
int ChangeDirectory(string[] dir);
|
||||
@@ -10,5 +12,6 @@
|
||||
|
||||
bool ImportItemFrom(string path);
|
||||
string[] GetSupportedFormats();
|
||||
Dictionary<string, string> GetPresetPaths();
|
||||
}
|
||||
}
|
@@ -17,6 +17,8 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
static readonly Dictionary<string, List<ResourceConverter>> converters
|
||||
= new Dictionary<string, List<ResourceConverter>>();
|
||||
static readonly Dictionary<string, string> localRes
|
||||
= new Dictionary<string, string>();
|
||||
|
||||
public LegacyResourceManager(string rootPath) {
|
||||
_rootPath = rootPath;
|
||||
@@ -35,14 +37,23 @@ namespace Cryville.Crtr.Browsing {
|
||||
if (fs == null) continue;
|
||||
foreach (var f in fs) {
|
||||
if (f == null) continue;
|
||||
if (!converters.ContainsKey(f))
|
||||
if (!converters.ContainsKey(f))
|
||||
converters.Add(f, new List<ResourceConverter> { c });
|
||||
else converters[f].Add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger.Log("main", 1, "Resource", "Loaded extension {0}", ReflectionHelper.GetNamespaceQualifiedName(type));
|
||||
var fs2 = ext.GetResourceFinders();
|
||||
if (fs2 != null) {
|
||||
foreach (var f in fs2) {
|
||||
var name = f.Name;
|
||||
var path = f.GetRootPath();
|
||||
if (name != null && path != null)
|
||||
localRes.Add(name, path);
|
||||
}
|
||||
}
|
||||
Logger.Log("main", 1, "Resource", "Loaded extension {0}", ReflectionHelper.GetNamespaceQualifiedName(type));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Log("main", 4, "Resource", "Failed to initialize extension {0}: {1}", ReflectionHelper.GetNamespaceQualifiedName(type), ex);
|
||||
}
|
||||
@@ -211,5 +222,9 @@ namespace Cryville.Crtr.Browsing {
|
||||
public string[] GetSupportedFormats() {
|
||||
return converters.Keys.ToArray();
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetPresetPaths() {
|
||||
return localRes;
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
_dialog = GameObject.Instantiate(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>();
|
||||
_dialog.gameObject.SetActive(false);
|
||||
_dialog.Filter = ResourceManager.GetSupportedFormats();
|
||||
_dialog.PresetPaths = ResourceManager.GetPresetPaths();
|
||||
_dialog.OnClose += OnAddDialogClosed;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user