-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCachedAnimationClips.cs
More file actions
117 lines (109 loc) · 4.3 KB
/
Copy pathCachedAnimationClips.cs
File metadata and controls
117 lines (109 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.IO;
using System.Windows.Forms;
namespace CustomStreamMaker
{
public partial class CachedAnimationClips : Form
{
string customPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\CustomStreamMaker\CustomAnimationClips";
public CachedAnimationClips()
{
InitializeComponent();
}
private void CachedAnimationClips_Load(object sender, EventArgs e)
{
LoadCachedPreview();
if (!CheckIfNodesAreEmpty())
{
MessageBox.Show("Could not load animation clips:\n\nNo cached animation clips currently exist.", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
DialogResult = DialogResult.Cancel;
Close();
}
}
private void LoadCachedPreview()
{
if (!Directory.Exists(customPath))
return;
var directories = Directory.GetDirectories(customPath);
if (directories.Length == 0)
return;
foreach (var path in directories)
{
var pathName = Path.GetFileName(path);
var bundleInfo = File.ReadAllText(Path.Combine(path, "bundlePath.txt"));
if (bundleInfo.Contains("\n"))
{
var catalog = CustomAssetExtractor.catalogPath;
var catalogPath = bundleInfo.Split('\n')[1];
if (string.IsNullOrEmpty(catalog) || !catalogPath.Contains(catalog))
continue;
pathName += " (Addressable)";
}
var node = CachedAnimationsTreeView.Nodes.Add(pathName);
var files = Directory.GetFiles(path);
if (files.Length == 0)
continue;
foreach (var file in files)
{
if (Path.HasExtension(file)) continue;
node.Nodes.Add(Path.GetFileName(file));
}
}
}
private bool CheckIfNodesAreEmpty()
{
if (CachedAnimationsTreeView.Nodes.Count == 0) return false;
bool hasSubNodes = false;
foreach (TreeNode node in CachedAnimationsTreeView.Nodes)
{
if (node.Nodes.Count == 0)
continue;
hasSubNodes = true;
}
return hasSubNodes;
}
private void OkButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
SetCustomAssets();
Close();
}
private void CancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void SetCustomAssets()
{
foreach (TreeNode node in CachedAnimationsTreeView.Nodes)
{
var subDirectory = node.Text.Replace(" (Addressable)", "");
if (node.Nodes.Count == 0)
continue;
foreach (TreeNode subNode in node.Nodes)
{
var fileName = subNode.Text;
var bundleInfo = Path.Combine(customPath, subDirectory, "bundlePath.txt");
string bundlePath = File.ReadAllText(bundleInfo);
if (bundlePath.Contains("\n"))
bundlePath = bundlePath.Split('\n')[0];
if (CustomAssetExtractor.customAssets.Exists(a => a.filePath == bundlePath && a.fileName == fileName))
continue;
var importPic = new CustomAsset(CustomAssetType.Sprite, node.Text.Contains(" (Addressable)") ? CustomAssetFileType.AddressableBundle : CustomAssetFileType.AssetBundle, fileName, bundlePath);
CustomAssetExtractor.customAssets.Add(importPic);
}
}
}
private void CachedAnimationClips_FormClosing(object sender, FormClosingEventArgs e)
{
Dispose();
}
private void CachedAnimationsTreeView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
CachedAnimationsTreeView.SelectedNode.Remove();
}
}
}
}