-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
68 lines (61 loc) · 2.06 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var Fs = require('fire-fs');
module.exports = {
load: function () {
},
unload: function () {
},
messages: {
'open' () {
Editor.Panel.open('quick-open');
},
'open-file' (event, path, metaPath) {
// Get uuid
Fs.readFile(metaPath, function (err, data) {
var uuid = '';
var error = '';
var meta = null;
if (err) {
error = 'Failed to read meta file of ' + path + '(' + err + ')';
Editor.error(error);
event.reply && event.reply(new Error(error));
return;
}
try {
meta = JSON.parse(data);
uuid = meta.uuid;
}
catch (e) {
}
if (!uuid) {
error = 'Failed to parse meta file of ' + path;
Editor.error(error);
event.reply && event.reply(new Error(error));
return;
}
// Open file
var info = Editor.assetdb.assetInfoByUuid(uuid);
var assetType = info.type;
switch (assetType) {
case 'javascript':
case 'coffeescript':
case 'markdown':
case 'text':
Editor.Ipc.sendToMain('assets:open-text-file', uuid);
break;
case 'scene':
Editor.Panel.open('scene', {
uuid: uuid,
});
break;
case 'prefab':
Editor.Ipc.sendToAll('scene:enter-prefab-edit-mode', uuid);
break;
default:
event.reply && event.reply(new Error('Failed to open file (' + path + ') of type: ' + assetType));
return;
}
event.reply && event.reply(null);
});
}
}
};