-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
47 lines (41 loc) · 1.48 KB
/
main.js
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
// @ts-nocheck
GMEdit.register('file-icons', {
init: (state) => {
function setThumb(item) {
if ($gmedit['ui.treeview.TreeView'].isDirectory(item)) {
if (item.attributes['data-filter'].value == 'extension') {
console.log(item);
$gmedit['ui.treeview.TreeView'].setThumb(
item.attributes['data-full-path'].value,
state.dir + '/icons/extentions.png',
item,
);
}
Array.from(item.children[1].children).forEach(setThumb);
return;
}
const path = item.attributes['data-full-path'].value;
const kind = item.attributes['data-kind'].value;
if (!$gmedit['ui.treeview.TreeView'].hasThumb(path) && kind != 'sprite') {
$gmedit['ui.treeview.TreeView'].setThumb(path, state.dir + '/icons/' + kind + '.png');
}
}
const handleDirClick = $gmedit['ui.treeview.TreeView'].handleDirClick;
const handleItemClick = $gmedit['ui.treeview.TreeView'].handleItemClick;
$gmedit['ui.treeview.TreeView'].handleDirClick = (e) => {
updateThumbs();
handleDirClick(e);
};
$gmedit['ui.treeview.TreeView'].handleItemClick = (e) => {
updateThumbs();
handleItemClick(e);
};
function updateThumbs() {
const rootElement = $gmedit['ui.treeview.TreeView'].find(0, 0).children[1];
Array.from(rootElement.children).forEach((item) => setThumb(item));
}
GMEdit.on('projectOpen', (project) => {
updateThumbs();
});
},
});