Remove legacy file dialog.
This commit is contained in:
@@ -1,147 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace Cryville.Common.Unity {
|
|
||||||
public class FileDialog : MonoBehaviour {
|
|
||||||
Transform panel;
|
|
||||||
Transform title;
|
|
||||||
Transform drives;
|
|
||||||
Transform dirs;
|
|
||||||
Transform files;
|
|
||||||
|
|
||||||
public event Action OnClose;
|
|
||||||
|
|
||||||
#if UNITY_ANDROID && !UNITY_EDITOR_WIN
|
|
||||||
string androidStorage = "";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
string fileName = null;
|
|
||||||
public string FileName {
|
|
||||||
get { return fileName; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string[] m_filter = new string[]{};
|
|
||||||
public string[] Filter {
|
|
||||||
set { m_filter = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public IReadOnlyDictionary<string, string> m_presetPaths = new Dictionary<string, string>();
|
|
||||||
public IReadOnlyDictionary<string, string> PresetPaths {
|
|
||||||
get { return m_presetPaths; }
|
|
||||||
set { m_presetPaths = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
GameObject prefabButton;
|
|
||||||
|
|
||||||
void Start() {
|
|
||||||
prefabButton = Resources.Load<GameObject>("Common/Button");
|
|
||||||
panel = gameObject.transform.Find("Panel");
|
|
||||||
title = panel.Find("Title/Text");
|
|
||||||
drives = panel.Find("Drives/DrivesInner");
|
|
||||||
dirs = panel.Find("Directories/DirectoriesInner");
|
|
||||||
files = panel.Find("Files/FilesInner");
|
|
||||||
if (CurrentDirectory == null) {
|
|
||||||
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
|
|
||||||
CurrentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
|
||||||
#elif UNITY_ANDROID
|
|
||||||
using (AndroidJavaClass ajc = new AndroidJavaClass("android.os.Environment"))
|
|
||||||
using (AndroidJavaObject file = ajc.CallStatic<AndroidJavaObject>("getExternalStorageDirectory")) {
|
|
||||||
androidStorage = file.Call<string>("getAbsolutePath");
|
|
||||||
CurrentDirectory = new DirectoryInfo(androidStorage);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#error No default directory
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
UpdateGUI(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Show() {
|
|
||||||
fileName = null;
|
|
||||||
gameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close() {
|
|
||||||
var ev = OnClose;
|
|
||||||
if (ev != null) ev.Invoke();
|
|
||||||
gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DirectoryInfo CurrentDirectory;
|
|
||||||
|
|
||||||
void ChangeDirectory(DirectoryInfo s) {
|
|
||||||
CurrentDirectory = s;
|
|
||||||
UpdateGUI(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SelectFile(string s) {
|
|
||||||
fileName = s;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateGUI(int depth) {
|
|
||||||
title.GetComponent<Text>().text = CurrentDirectory.FullName;
|
|
||||||
|
|
||||||
if (depth <= 0) {
|
|
||||||
CallHelper.Purge(drives);
|
|
||||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
|
||||||
var dl = Directory.GetLogicalDrives();
|
|
||||||
foreach (string d in dl) {
|
|
||||||
GameObject btn = Instantiate(prefabButton);
|
|
||||||
btn.GetComponentInChildren<Text>().text = d;
|
|
||||||
btn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(new DirectoryInfo(d)));
|
|
||||||
btn.transform.SetParent(drives, false);
|
|
||||||
}
|
|
||||||
#elif UNITY_ANDROID
|
|
||||||
GameObject sbtn = GameObject.Instantiate<GameObject>(prefabButton);
|
|
||||||
sbtn.GetComponentInChildren<Text>().text = "Storage";
|
|
||||||
sbtn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(new DirectoryInfo(androidStorage)));
|
|
||||||
sbtn.transform.SetParent(drives, false);
|
|
||||||
#else
|
|
||||||
#error No update GUI logic
|
|
||||||
#endif
|
|
||||||
foreach (var p in m_presetPaths) {
|
|
||||||
var d = new DirectoryInfo(p.Value);
|
|
||||||
if (d.Exists) {
|
|
||||||
GameObject btn = Instantiate(prefabButton);
|
|
||||||
btn.GetComponentInChildren<Text>().text = p.Key;
|
|
||||||
btn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(d));
|
|
||||||
btn.transform.SetParent(drives, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CallHelper.Purge(dirs);
|
|
||||||
DirectoryInfo[] subdirs = CurrentDirectory.GetDirectories();
|
|
||||||
GameObject pbtn = Instantiate(prefabButton);
|
|
||||||
pbtn.GetComponentInChildren<Text>().text = "..";
|
|
||||||
pbtn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(new DirectoryInfo(Path.Combine(CurrentDirectory.FullName, ".."))));
|
|
||||||
pbtn.transform.SetParent(dirs, false);
|
|
||||||
foreach (DirectoryInfo d in subdirs) {
|
|
||||||
GameObject btn = Instantiate(prefabButton);
|
|
||||||
btn.GetComponentInChildren<Text>().text = d.Name;
|
|
||||||
var ts = d;
|
|
||||||
btn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(ts));
|
|
||||||
btn.transform.SetParent(dirs, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
CallHelper.Purge(files);
|
|
||||||
FileInfo[] fl = CurrentDirectory.GetFiles();
|
|
||||||
foreach (FileInfo d in fl) {
|
|
||||||
foreach (string ext in m_filter) {
|
|
||||||
if (d.Extension == ext) {
|
|
||||||
GameObject btn = Instantiate(prefabButton);
|
|
||||||
btn.GetComponentInChildren<Text>().text = d.Name + " / " + (d.Length / 1024.0).ToString("0.0 KiB");
|
|
||||||
var ts = d.FullName;
|
|
||||||
btn.GetComponentInChildren<Button>().onClick.AddListener(() => SelectFile(ts));
|
|
||||||
btn.transform.SetParent(files, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 9865f498871e30548959e6b28f91feae
|
|
||||||
timeCreated: 1608801352
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using Cryville.Common.Unity;
|
|
||||||
using Cryville.Common.Unity.UI;
|
using Cryville.Common.Unity.UI;
|
||||||
using Cryville.Crtr.Browsing.Actions;
|
using Cryville.Crtr.Browsing.Actions;
|
||||||
using Cryville.Crtr.UI;
|
using Cryville.Crtr.UI;
|
||||||
@@ -29,12 +28,8 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
readonly HashSet<int> _selectedItems = new HashSet<int>();
|
readonly HashSet<int> _selectedItems = new HashSet<int>();
|
||||||
readonly Dictionary<int, BrowserItem> _items = new Dictionary<int, BrowserItem>();
|
readonly Dictionary<int, BrowserItem> _items = new Dictionary<int, BrowserItem>();
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
FileDialog _dialog;
|
|
||||||
|
|
||||||
protected virtual void Start() {
|
protected virtual void Start() {
|
||||||
m_itemContainer.LoadItem = LoadItem;
|
m_itemContainer.LoadItem = LoadItem;
|
||||||
InitDialog();
|
|
||||||
}
|
}
|
||||||
void OnDestroy() {
|
void OnDestroy() {
|
||||||
UnregisterManager();
|
UnregisterManager();
|
||||||
@@ -114,21 +109,5 @@ namespace Cryville.Crtr.Browsing.UI {
|
|||||||
public void OnPathClicked(int index) {
|
public void OnPathClicked(int index) {
|
||||||
_manager.ReturnToDirectory(index);
|
_manager.ReturnToDirectory(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public void OnAddButtonClicked() {
|
|
||||||
_dialog.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
private void OnAddDialogClosed() {
|
|
||||||
if (_dialog.FileName == null) return;
|
|
||||||
if (ResourceManager.ImportItemFrom(new Uri(_dialog.FileName))) {
|
|
||||||
Popup.Create("Import succeeded");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Popup.Create("Import failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,204 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!1 &115880
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 22421578}
|
|
||||||
- component: {fileID: 22277180}
|
|
||||||
- component: {fileID: 11431732}
|
|
||||||
m_Layer: 5
|
|
||||||
m_Name: Text
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!224 &22421578
|
|
||||||
RectTransform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 115880}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 22442474}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
m_AnchorMin: {x: 0.1, y: 0.25}
|
|
||||||
m_AnchorMax: {x: 0.9, y: 0.75}
|
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
|
||||||
--- !u!222 &22277180
|
|
||||||
CanvasRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 115880}
|
|
||||||
m_CullTransparentMesh: 1
|
|
||||||
--- !u!114 &11431732
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 115880}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
|
||||||
m_RaycastTarget: 1
|
|
||||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
m_Maskable: 1
|
|
||||||
m_OnCullStateChanged:
|
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls: []
|
|
||||||
m_FontData:
|
|
||||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
m_FontSize: 14
|
|
||||||
m_FontStyle: 0
|
|
||||||
m_BestFit: 1
|
|
||||||
m_MinSize: 8
|
|
||||||
m_MaxSize: 40
|
|
||||||
m_Alignment: 4
|
|
||||||
m_AlignByGeometry: 0
|
|
||||||
m_RichText: 1
|
|
||||||
m_HorizontalOverflow: 0
|
|
||||||
m_VerticalOverflow: 0
|
|
||||||
m_LineSpacing: 1
|
|
||||||
m_Text: Button
|
|
||||||
--- !u!1 &154602
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 22442474}
|
|
||||||
- component: {fileID: 22210468}
|
|
||||||
- component: {fileID: 11464750}
|
|
||||||
- component: {fileID: 11455310}
|
|
||||||
m_Layer: 5
|
|
||||||
m_Name: Button
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!224 &22442474
|
|
||||||
RectTransform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 154602}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children:
|
|
||||||
- {fileID: 22421578}
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
|
||||||
m_Pivot: {x: 0, y: 1}
|
|
||||||
--- !u!222 &22210468
|
|
||||||
CanvasRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 154602}
|
|
||||||
m_CullTransparentMesh: 1
|
|
||||||
--- !u!114 &11464750
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 154602}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
m_RaycastTarget: 1
|
|
||||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
m_Maskable: 1
|
|
||||||
m_OnCullStateChanged:
|
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls: []
|
|
||||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
|
||||||
m_Type: 1
|
|
||||||
m_PreserveAspect: 0
|
|
||||||
m_FillCenter: 1
|
|
||||||
m_FillMethod: 4
|
|
||||||
m_FillAmount: 1
|
|
||||||
m_FillClockwise: 1
|
|
||||||
m_FillOrigin: 0
|
|
||||||
m_UseSpriteMesh: 0
|
|
||||||
m_PixelsPerUnitMultiplier: 1
|
|
||||||
--- !u!114 &11455310
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 154602}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_Navigation:
|
|
||||||
m_Mode: 3
|
|
||||||
m_WrapAround: 0
|
|
||||||
m_SelectOnUp: {fileID: 0}
|
|
||||||
m_SelectOnDown: {fileID: 0}
|
|
||||||
m_SelectOnLeft: {fileID: 0}
|
|
||||||
m_SelectOnRight: {fileID: 0}
|
|
||||||
m_Transition: 1
|
|
||||||
m_Colors:
|
|
||||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
|
||||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
|
||||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
|
||||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
|
||||||
m_ColorMultiplier: 1
|
|
||||||
m_FadeDuration: 0.1
|
|
||||||
m_SpriteState:
|
|
||||||
m_HighlightedSprite: {fileID: 0}
|
|
||||||
m_PressedSprite: {fileID: 0}
|
|
||||||
m_SelectedSprite: {fileID: 0}
|
|
||||||
m_DisabledSprite: {fileID: 0}
|
|
||||||
m_AnimationTriggers:
|
|
||||||
m_NormalTrigger: Normal
|
|
||||||
m_HighlightedTrigger: Highlighted
|
|
||||||
m_PressedTrigger: Pressed
|
|
||||||
m_SelectedTrigger: Highlighted
|
|
||||||
m_DisabledTrigger: Disabled
|
|
||||||
m_Interactable: 1
|
|
||||||
m_TargetGraphic: {fileID: 11464750}
|
|
||||||
m_OnClick:
|
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls: []
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a152ea0b3ae1c8a4b972552577d5400c
|
|
||||||
timeCreated: 1594270092
|
|
||||||
licenseType: Pro
|
|
||||||
NativeFormatImporter:
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 96d3d4cd793ecb9418e2e77107caa4bf
|
|
||||||
timeCreated: 1594270092
|
|
||||||
licenseType: Pro
|
|
||||||
NativeFormatImporter:
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Reference in New Issue
Block a user