@ives_xxz/packages 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AddComponent/main.js +32 -0
- package/AddComponent/package.json +26 -0
- package/AddComponent/panel/index.js +233 -0
- package/AddComponent/readme.md +38 -0
- package/AddComponent/scene-accessor.js +109 -0
- package/AddComponent/template-auto-dock.js +73 -0
- package/BitmapFontTools/i18n/en.js +1 -0
- package/BitmapFontTools/i18n/zh.js +1 -0
- package/BitmapFontTools/main.js +1 -0
- package/BitmapFontTools/package-lock.json +83 -0
- package/BitmapFontTools/package.json +37 -0
- package/BitmapFontTools/panel/font.css +1 -0
- package/BitmapFontTools/panel/font.js +58 -0
- package/BitmapFontTools/panel/font_panel.js +1 -0
- package/BitmapFontTools/panel/ttf.css +1 -0
- package/BitmapFontTools/panel/ttf.js +68 -0
- package/BitmapFontTools/panel/ttf_panel.js +1 -0
- package/FWAssetsFinder/main.js +9 -0
- package/FWAssetsFinder/package.json +20 -0
- package/FWAssetsFinder/panel/index.css +2 -0
- package/FWAssetsFinder/panel/index.html +52 -0
- package/FWAssetsFinder/panel/index.js +265 -0
- package/FWAssetsFinder/panel/less.css +71 -0
- package/FWAssetsFinder/panel/scene.js +194 -0
- package/FWExcelGenerator/main.js +367 -0
- package/FWExcelGenerator/package-lock.json +109 -0
- package/FWExcelGenerator/package.json +23 -0
- package/FWExcelGenerator/panel/index.js +648 -0
- package/FWLayerGenerator/main.js +186 -0
- package/FWLayerGenerator/package.json +21 -0
- package/FWLayerGenerator/panel/index.css +36 -0
- package/FWLayerGenerator/panel/index.html +17 -0
- package/FWLayerGenerator/panel/index.js +29 -0
- package/FWMask/inspector.js +26 -0
- package/FWMask/main.js +16 -0
- package/FWMask/package.json +6 -0
- package/FWPolygonPoints/main.js +149 -0
- package/FWPolygonPoints/package.json +9 -0
- package/PNG Auto Compress/CHANGELOG.md +32 -0
- package/PNG Auto Compress/LICENSE +21 -0
- package/PNG Auto Compress/README.md +113 -0
- package/PNG Auto Compress/config-manager.js +72 -0
- package/PNG Auto Compress/i18n/en.js +14 -0
- package/PNG Auto Compress/i18n/zh.js +14 -0
- package/PNG Auto Compress/images/setting.png +0 -0
- package/PNG Auto Compress/jsconfig.json +1 -0
- package/PNG Auto Compress/main.js +377 -0
- package/PNG Auto Compress/package.json +41 -0
- package/PNG Auto Compress/panel.setting/index.css +13 -0
- package/PNG Auto Compress/panel.setting/index.html +51 -0
- package/PNG Auto Compress/panel.setting/index.js +124 -0
- package/PNG Auto Compress/pngquant/macos/COPYRIGHT +687 -0
- package/PNG Auto Compress/pngquant/macos/README.md +78 -0
- package/PNG Auto Compress/pngquant/macos/pngquant +0 -0
- package/PNG Auto Compress/pngquant/macos/pngquant-compat +0 -0
- package/PNG Auto Compress/pngquant/windows/COPYRIGHT +687 -0
- package/PNG Auto Compress/pngquant/windows/Drag PNG here to reduce palette automatically.bat +11 -0
- package/PNG Auto Compress/pngquant/windows/Drag PNG here to reduce palette to 256.bat +10 -0
- package/PNG Auto Compress/pngquant/windows/README.txt +78 -0
- package/PNG Auto Compress/pngquant/windows/pngquant.exe +0 -0
- package/PNG Auto Compress/typings/cocos/editor.d.ts +1053 -0
- package/PNG Auto Compress/utils/file-utils.js +67 -0
- package/Quick Finder/CHANGELOG.md +100 -0
- package/Quick Finder/LICENSE +21 -0
- package/Quick Finder/README.en.md +141 -0
- package/Quick Finder/README.md +149 -0
- package/Quick Finder/i18n/en.js +42 -0
- package/Quick Finder/i18n/zh.js +42 -0
- package/Quick Finder/images/assets/animation-clip.png +0 -0
- package/Quick Finder/images/assets/asset.png +0 -0
- package/Quick Finder/images/assets/atlas.png +0 -0
- package/Quick Finder/images/assets/audio-clip.png +0 -0
- package/Quick Finder/images/assets/auto-atlas.png +0 -0
- package/Quick Finder/images/assets/bitmap-font.png +0 -0
- package/Quick Finder/images/assets/buffer.png +0 -0
- package/Quick Finder/images/assets/coffeescript.png +0 -0
- package/Quick Finder/images/assets/component.png +0 -0
- package/Quick Finder/images/assets/css.png +0 -0
- package/Quick Finder/images/assets/dragonbones-atlas.png +0 -0
- package/Quick Finder/images/assets/folder.png +0 -0
- package/Quick Finder/images/assets/html.png +0 -0
- package/Quick Finder/images/assets/javascript.png +0 -0
- package/Quick Finder/images/assets/json.png +0 -0
- package/Quick Finder/images/assets/label-atlas.png +0 -0
- package/Quick Finder/images/assets/markdown.png +0 -0
- package/Quick Finder/images/assets/material.png +0 -0
- package/Quick Finder/images/assets/mesh.png +0 -0
- package/Quick Finder/images/assets/mount.png +0 -0
- package/Quick Finder/images/assets/node.png +0 -0
- package/Quick Finder/images/assets/particle.png +0 -0
- package/Quick Finder/images/assets/physics-material.png +0 -0
- package/Quick Finder/images/assets/prefab.png +0 -0
- package/Quick Finder/images/assets/raw-asset.png +0 -0
- package/Quick Finder/images/assets/scene.png +0 -0
- package/Quick Finder/images/assets/shader.png +0 -0
- package/Quick Finder/images/assets/skeleton.png +0 -0
- package/Quick Finder/images/assets/spine.png +0 -0
- package/Quick Finder/images/assets/sprite-animation.png +0 -0
- package/Quick Finder/images/assets/sprite-atlas.png +0 -0
- package/Quick Finder/images/assets/sprite-frame.png +0 -0
- package/Quick Finder/images/assets/text.png +0 -0
- package/Quick Finder/images/assets/tiled-map.png +0 -0
- package/Quick Finder/images/assets/ttf-font.png +0 -0
- package/Quick Finder/images/assets/typescript.png +0 -0
- package/Quick Finder/images/search.png +0 -0
- package/Quick Finder/images/settings.png +0 -0
- package/Quick Finder/images/update.png +0 -0
- package/Quick Finder/images/version.png +0 -0
- package/Quick Finder/jsconfig.json +17 -0
- package/Quick Finder/lib/node-fetch.js +1649 -0
- package/Quick Finder/lib/vue.global.prod.js +7 -0
- package/Quick Finder/package.json +45 -0
- package/Quick Finder/src/common/config-manager.js +122 -0
- package/Quick Finder/src/eazax/browser-util.js +61 -0
- package/Quick Finder/src/eazax/color-util.js +37 -0
- package/Quick Finder/src/eazax/css/cocos-class.css +202 -0
- package/Quick Finder/src/eazax/css/cocos-tag.css +197 -0
- package/Quick Finder/src/eazax/css/eazax-colors.css +18 -0
- package/Quick Finder/src/eazax/editor-main-kit.js +53 -0
- package/Quick Finder/src/eazax/editor-main-util.js +112 -0
- package/Quick Finder/src/eazax/editor-renderer-kit.js +26 -0
- package/Quick Finder/src/eazax/file-util.js +158 -0
- package/Quick Finder/src/eazax/i18n.js +36 -0
- package/Quick Finder/src/eazax/main-event.js +81 -0
- package/Quick Finder/src/eazax/package-util.js +47 -0
- package/Quick Finder/src/eazax/renderer-event.js +80 -0
- package/Quick Finder/src/eazax/updater.js +92 -0
- package/Quick Finder/src/eazax/version-util.js +61 -0
- package/Quick Finder/src/eazax/window-util.js +80 -0
- package/Quick Finder/src/main/finder.js +101 -0
- package/Quick Finder/src/main/index.js +155 -0
- package/Quick Finder/src/main/opener.js +95 -0
- package/Quick Finder/src/main/panel-manager.js +159 -0
- package/Quick Finder/src/renderer/search/index.css +222 -0
- package/Quick Finder/src/renderer/search/index.html +46 -0
- package/Quick Finder/src/renderer/search/index.js +348 -0
- package/Quick Finder/src/renderer/settings/index.css +101 -0
- package/Quick Finder/src/renderer/settings/index.html +86 -0
- package/Quick Finder/src/renderer/settings/index.js +219 -0
- package/Quick Finder/typings/cocos/editor.d.ts +1053 -0
- package/Quick Finder/typings/vue.d.ts +1 -0
- package/README.md +93 -0
- package/package.json +12 -0
- package/unpack plist/main.js +253 -0
- package/unpack plist/package.json +13 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/CHANGELOG.md +30 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/LICENSE +21 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/README.en.md +111 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/README.md +115 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/i18n/en.js +55 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/i18n/zh.js +55 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/images/search.png +0 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/images/settings.png +0 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/images/update.png +0 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/images/version.png +0 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/jsconfig.json +17 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/lib/node-fetch.js +1649 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/lib/vue.global.prod.js +7 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/package.json +44 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/common/config-manager.js +104 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/browser-util.js +61 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/color-util.js +37 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/css/cocos-class.css +201 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/css/cocos-tag.css +197 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/css/eazax-colors.css +18 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/editor-main-kit.js +53 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/editor-main-util.js +147 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/editor-renderer-kit.js +26 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/file-util.js +158 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/i18n.js +36 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/main-event.js +81 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/package-util.js +47 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/renderer-event.js +80 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/updater.js +92 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/version-util.js +61 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/eazax/window-util.js +80 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/editor-api.js +90 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/finder.js +248 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/index.js +155 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/object-util.js +70 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/panel-manager.js +86 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/parser.js +161 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/printer.js +108 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/renderer/settings/index.css +61 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/renderer/settings/index.html +90 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/renderer/settings/index.js +191 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/typings/cocos/editor.d.ts +1053 -0
- package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/typings/vue.d.ts +1 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 编辑器 API(用于抹平不同版本编辑器之间的差异)
|
|
3
|
+
* @author 陈皮皮 (ifaswind)
|
|
4
|
+
* @version 20210830
|
|
5
|
+
*/
|
|
6
|
+
const EditorAPI = {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 当前语言
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
getLanguage() {
|
|
13
|
+
return Editor.lang || Editor.I18n.getLanguage();
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 绝对路径转为编辑器资源路径
|
|
18
|
+
* @param {string} fspath
|
|
19
|
+
*/
|
|
20
|
+
fspathToUrl(fspath) {
|
|
21
|
+
return Editor.assetdb.fspathToUrl(fspath);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 编辑器资源路径转为绝对路径
|
|
26
|
+
* @param {string} url
|
|
27
|
+
*/
|
|
28
|
+
urlToFspath(url) {
|
|
29
|
+
return Editor.assetdb.urlToFspath(url);
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 通过 uuid 获取资源信息
|
|
34
|
+
* @param {string} uuid
|
|
35
|
+
*/
|
|
36
|
+
assetInfoByUuid(uuid) {
|
|
37
|
+
return Editor.assetdb.assetInfoByUuid(uuid);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 通过 uuid 获取子资源信息
|
|
42
|
+
* @param {string} uuid
|
|
43
|
+
*/
|
|
44
|
+
subAssetInfosByUuid(uuid) {
|
|
45
|
+
return Editor.assetdb.subAssetInfosByUuid(uuid);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 获取当前选中的资源 uuid
|
|
50
|
+
* @returns {string[]}
|
|
51
|
+
*/
|
|
52
|
+
getCurrentSelectedAssets() {
|
|
53
|
+
return Editor.Selection.curSelection('asset');
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 获取当前选中的节点 uuid
|
|
58
|
+
* @returns {string[]}
|
|
59
|
+
*/
|
|
60
|
+
getCurrentSelectedNodes() {
|
|
61
|
+
return Editor.Selection.curSelection('node');
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 是否为 uuid
|
|
66
|
+
* @param {string} uuid
|
|
67
|
+
*/
|
|
68
|
+
isUuid(uuid) {
|
|
69
|
+
return Editor.Utils.UuidUtils.isUuid(uuid);
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 压缩 uuid
|
|
74
|
+
* @param {string} uuid
|
|
75
|
+
*/
|
|
76
|
+
compressUuid(uuid) {
|
|
77
|
+
return Editor.Utils.UuidUtils.compressUuid(uuid);
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 反压缩 uuid
|
|
82
|
+
* @param {string} uuid
|
|
83
|
+
*/
|
|
84
|
+
decompressUuid(uuid) {
|
|
85
|
+
return Editor.Utils.UuidUtils.decompressUuid(uuid);
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
module.exports = EditorAPI;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
const { extname, basename } = require("path");
|
|
2
|
+
const EditorAPI = require("./editor-api");
|
|
3
|
+
const { print, translate } = require("../eazax/editor-main-util");
|
|
4
|
+
const FileUtil = require("../eazax/file-util");
|
|
5
|
+
const { containsValue } = require("./object-util");
|
|
6
|
+
const Parser = require("./parser");
|
|
7
|
+
|
|
8
|
+
/** 扩展名对应文件类型 */
|
|
9
|
+
const ASSET_TYPE_MAP = {
|
|
10
|
+
// 场景
|
|
11
|
+
'.fire': 'scene',
|
|
12
|
+
'.scene': 'scene',
|
|
13
|
+
// 预制体
|
|
14
|
+
'.prefab': 'prefab',
|
|
15
|
+
// 动画
|
|
16
|
+
'.anim': 'animation',
|
|
17
|
+
// 材质
|
|
18
|
+
'.mtl': 'material',
|
|
19
|
+
// 字体
|
|
20
|
+
'.fnt.meta': 'font',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 查找器
|
|
25
|
+
*/
|
|
26
|
+
const Finder = {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 使用 uuid 进行查找
|
|
30
|
+
* @param {string} uuid
|
|
31
|
+
*/
|
|
32
|
+
async findByUuid(uuid) {
|
|
33
|
+
// 是否为有效 uuid
|
|
34
|
+
if (!EditorAPI.isUuid(uuid)) {
|
|
35
|
+
print('log', translate('invalid-uuid'), uuid);
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
// 获取资源信息
|
|
39
|
+
const assetInfo = EditorAPI.assetInfoByUuid(uuid);
|
|
40
|
+
if (assetInfo) {
|
|
41
|
+
// 记录子资源 uuid
|
|
42
|
+
const subAssetUuids = [];
|
|
43
|
+
// 资源类型检查
|
|
44
|
+
if (assetInfo.type === 'texture') {
|
|
45
|
+
// 纹理子资源
|
|
46
|
+
const subAssetInfos = EditorAPI.subAssetInfosByUuid(uuid);
|
|
47
|
+
if (subAssetInfos && subAssetInfos.length > 0) {
|
|
48
|
+
for (let i = 0; i < subAssetInfos.length; i++) {
|
|
49
|
+
subAssetUuids.push(subAssetInfos[i].uuid);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} else if (assetInfo.type === 'typescript' || assetInfo.type === 'javascript') {
|
|
53
|
+
// 脚本资源
|
|
54
|
+
uuid = EditorAPI.compressUuid(uuid);
|
|
55
|
+
}
|
|
56
|
+
// 查找资源引用
|
|
57
|
+
const results = [],
|
|
58
|
+
selfResults = await Finder.findRefs(uuid);
|
|
59
|
+
for (let i = 0, l = selfResults.length; i < l; i++) {
|
|
60
|
+
results.push(selfResults[i]);
|
|
61
|
+
}
|
|
62
|
+
// 查找子资源的引用
|
|
63
|
+
if (subAssetUuids.length > 0) {
|
|
64
|
+
for (let i = 0, l = subAssetUuids.length; i < l; i++) {
|
|
65
|
+
const subResults = await Finder.findRefs(subAssetUuids[i]);
|
|
66
|
+
for (let j = 0, l = subResults.length; j < l; j++) {
|
|
67
|
+
results.push(subResults[j]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return results;
|
|
72
|
+
} else {
|
|
73
|
+
// 不存在的资源,直接查找 uuid
|
|
74
|
+
print('log', translate('find-asset-refs'), uuid);
|
|
75
|
+
return (await Finder.findRefs(uuid));
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 查找引用
|
|
81
|
+
* @param {string} uuid
|
|
82
|
+
* @returns {Promise<{ type: string, url: string, refs?: object[]}[]>}
|
|
83
|
+
*/
|
|
84
|
+
async findRefs(uuid) {
|
|
85
|
+
const result = [];
|
|
86
|
+
// 文件处理函数
|
|
87
|
+
const handler = async (path, stats) => {
|
|
88
|
+
const ext = extname(path);
|
|
89
|
+
if (ext === '.fire' || ext === '.scene' || ext === '.prefab') {
|
|
90
|
+
// 场景和预制体资源(转为节点树)
|
|
91
|
+
const tree = await Parser.getNodeTree(path);
|
|
92
|
+
if (!tree) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// 遍历第一层节点查找引用
|
|
96
|
+
const refs = [];
|
|
97
|
+
for (let children = tree.children, i = 0, l = children.length; i < l; i++) {
|
|
98
|
+
Finder.findRefsInNode(tree, children[i], uuid, refs);
|
|
99
|
+
}
|
|
100
|
+
// 保存当前文件引用结果
|
|
101
|
+
if (refs.length > 0) {
|
|
102
|
+
result.push({
|
|
103
|
+
type: ASSET_TYPE_MAP[ext],
|
|
104
|
+
url: EditorAPI.fspathToUrl(path),
|
|
105
|
+
refs: refs,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
} else if (ext === '.anim') {
|
|
109
|
+
// 动画资源
|
|
110
|
+
const data = JSON.parse(await FileUtil.readFile(path)),
|
|
111
|
+
curveData = data['curveData'],
|
|
112
|
+
contains = containsValue(curveData, uuid);
|
|
113
|
+
if (contains) {
|
|
114
|
+
result.push({
|
|
115
|
+
type: ASSET_TYPE_MAP[ext],
|
|
116
|
+
url: EditorAPI.fspathToUrl(path),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
} else if (ext === '.mtl' || path.endsWith('.fnt.meta')) {
|
|
120
|
+
// 材质和字体资源
|
|
121
|
+
const data = JSON.parse(await FileUtil.readFile(path));
|
|
122
|
+
// 需排除自己
|
|
123
|
+
if ((data['uuid'] === uuid)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// 是否引用
|
|
127
|
+
const contains = containsValue(data, uuid);
|
|
128
|
+
if (contains) {
|
|
129
|
+
const _ext = (ext === '.mtl') ? '.mtl' : '.fnt.meta';
|
|
130
|
+
result.push({
|
|
131
|
+
type: ASSET_TYPE_MAP[_ext],
|
|
132
|
+
url: EditorAPI.fspathToUrl(path),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
// 遍历资源目录下的文件
|
|
138
|
+
const assetsPath = EditorAPI.urlToFspath('db://assets');
|
|
139
|
+
await FileUtil.map(assetsPath, handler);
|
|
140
|
+
return result;
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 查找节点中的引用
|
|
145
|
+
* @param {object} tree 节点树
|
|
146
|
+
* @param {object} node 目标节点
|
|
147
|
+
* @param {string} uuid 查找的 uuid
|
|
148
|
+
* @param {object[]} result 结果
|
|
149
|
+
*/
|
|
150
|
+
findRefsInNode(tree, node, uuid, result) {
|
|
151
|
+
// 检查节点上的组件是否有引用
|
|
152
|
+
const components = node.components;
|
|
153
|
+
if (components && components.length > 0) {
|
|
154
|
+
for (let i = 0, l = components.length; i < l; i++) {
|
|
155
|
+
const properties = Finder.getContainsUuidProperties(components[i], uuid);
|
|
156
|
+
if (properties.length === 0) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
// 资源类型
|
|
160
|
+
let type = components[i]['__type__'];
|
|
161
|
+
// 是否为脚本资源
|
|
162
|
+
if (EditorAPI.isUuid(type)) {
|
|
163
|
+
const scriptUuid = EditorAPI.decompressUuid(type),
|
|
164
|
+
assetInfo = EditorAPI.assetInfoByUuid(scriptUuid);
|
|
165
|
+
type = basename(assetInfo.url);
|
|
166
|
+
}
|
|
167
|
+
// 遍历相关属性名
|
|
168
|
+
for (let i = 0; i < properties.length; i++) {
|
|
169
|
+
let property = properties[i];
|
|
170
|
+
if (property === '__type__') {
|
|
171
|
+
property = null;
|
|
172
|
+
} else {
|
|
173
|
+
// 处理属性名称(Label 组件需要特殊处理)
|
|
174
|
+
if (type === 'cc.Label' && property === '_N$file') {
|
|
175
|
+
property = 'font';
|
|
176
|
+
}
|
|
177
|
+
// 去除属性名的前缀
|
|
178
|
+
if (property.startsWith('_N$')) {
|
|
179
|
+
property = property.replace('_N$', '');
|
|
180
|
+
} else if (property[0] === '_') {
|
|
181
|
+
property = property.substring(1);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// 保存结果
|
|
185
|
+
result.push({
|
|
186
|
+
node: node.path,
|
|
187
|
+
component: type,
|
|
188
|
+
property: property,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// 检查预制体是否有引用
|
|
194
|
+
const prefab = node.prefab;
|
|
195
|
+
if (prefab) {
|
|
196
|
+
// 排除预制体自己
|
|
197
|
+
if (uuid !== tree.uuid) {
|
|
198
|
+
const contains = containsValue(prefab, uuid);
|
|
199
|
+
if (contains) {
|
|
200
|
+
result.push({
|
|
201
|
+
node: node.path,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// 遍历子节点
|
|
207
|
+
const children = node.children;
|
|
208
|
+
if (children && children.length > 0) {
|
|
209
|
+
for (let i = 0, l = children.length; i < l; i++) {
|
|
210
|
+
Finder.findRefsInNode(tree, children[i], uuid, result);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 获取对象包含指定 uuid 的属性
|
|
217
|
+
* @param {object} object 对象
|
|
218
|
+
* @param {string} uuid 值
|
|
219
|
+
* @returns {string[]}
|
|
220
|
+
*/
|
|
221
|
+
getContainsUuidProperties(object, uuid) {
|
|
222
|
+
const properties = [];
|
|
223
|
+
const search = (target, path) => {
|
|
224
|
+
if (Object.prototype.toString.call(target) === '[object Object]') {
|
|
225
|
+
for (const key in target) {
|
|
226
|
+
const curPath = (path != null) ? `${path}.${key}` : key;
|
|
227
|
+
if (target[key] === uuid) {
|
|
228
|
+
properties.push(path || key);
|
|
229
|
+
}
|
|
230
|
+
search(target[key], curPath);
|
|
231
|
+
}
|
|
232
|
+
} else if (Array.isArray(target)) {
|
|
233
|
+
for (let i = 0, l = target.length; i < l; i++) {
|
|
234
|
+
const curPath = (path != null) ? `${path}[${i}]` : `[${i}]`;
|
|
235
|
+
if (target[i] === uuid) {
|
|
236
|
+
properties.push(path || `[${i}]`);
|
|
237
|
+
}
|
|
238
|
+
search(target[i], curPath);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
search(object, null);
|
|
243
|
+
return properties;
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
module.exports = Finder;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
const PanelManager = require('./panel-manager');
|
|
2
|
+
const ConfigManager = require('../common/config-manager');
|
|
3
|
+
const EditorMainKit = require('../eazax/editor-main-kit');
|
|
4
|
+
const { checkUpdate, print, translate } = require('../eazax/editor-main-util');
|
|
5
|
+
const { openRepository } = require('../eazax/package-util');
|
|
6
|
+
const EditorAPI = require('./editor-api');
|
|
7
|
+
const Parser = require('./parser');
|
|
8
|
+
const Finder = require('./finder');
|
|
9
|
+
const Printer = require('./printer');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 生命周期:加载
|
|
13
|
+
*/
|
|
14
|
+
function load() {
|
|
15
|
+
// 监听事件
|
|
16
|
+
EditorMainKit.register();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 生命周期:卸载
|
|
21
|
+
*/
|
|
22
|
+
function unload() {
|
|
23
|
+
// 取消事件监听
|
|
24
|
+
EditorMainKit.unregister();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 查找当前选中资源
|
|
29
|
+
*/
|
|
30
|
+
async function findCurrentSelection() {
|
|
31
|
+
// 过滤选中的资源 uuid
|
|
32
|
+
const uuids = EditorAPI.getCurrentSelectedAssets();
|
|
33
|
+
for (let i = 0; i < uuids.length; i++) {
|
|
34
|
+
const assetInfo = EditorAPI.assetInfoByUuid(uuids[i]);
|
|
35
|
+
if (assetInfo.type === 'folder') {
|
|
36
|
+
uuids.splice(i--);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// 未选择资源
|
|
40
|
+
if (uuids.length === 0) {
|
|
41
|
+
print('log', translate('please-select-assets'));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// 遍历查找
|
|
45
|
+
for (let i = 0; i < uuids.length; i++) {
|
|
46
|
+
const uuid = uuids[i],
|
|
47
|
+
assetInfo = EditorAPI.assetInfoByUuid(uuid),
|
|
48
|
+
shortUrl = assetInfo.url.replace('db://', '');
|
|
49
|
+
// 查找引用
|
|
50
|
+
print('log', '🔍', `${translate('find-asset-refs')} ${shortUrl}`);
|
|
51
|
+
const refs = await Finder.findByUuid(uuid);
|
|
52
|
+
if (refs.length === 0) {
|
|
53
|
+
print('log', '📂', `${translate('no-refs')} ${shortUrl}`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// 打印结果
|
|
57
|
+
Printer.printResult({
|
|
58
|
+
type: assetInfo.type,
|
|
59
|
+
uuid: uuid,
|
|
60
|
+
url: assetInfo.url,
|
|
61
|
+
path: assetInfo.path,
|
|
62
|
+
refs: refs,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getSelection() {
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 资源变化回调
|
|
73
|
+
* @param {{ type: string, uuid: string }} info
|
|
74
|
+
*/
|
|
75
|
+
function onAssetChanged(info) {
|
|
76
|
+
const { type, uuid } = info;
|
|
77
|
+
// 场景和预制体
|
|
78
|
+
if (type === 'scene' || type === 'prefab') {
|
|
79
|
+
const { url, path } = EditorAPI.assetInfoByUuid(uuid);
|
|
80
|
+
// 排除内置资源
|
|
81
|
+
if (url.indexOf('db://internal') !== -1) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// 更新节点树
|
|
85
|
+
Parser.updateCache(path);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = {
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 扩展消息
|
|
93
|
+
*/
|
|
94
|
+
messages: {
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 查找当前选中资源
|
|
98
|
+
* @param {*} event
|
|
99
|
+
*/
|
|
100
|
+
'find-current-selection'(event) {
|
|
101
|
+
findCurrentSelection();
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 打开设置面板
|
|
106
|
+
* @param {*} event
|
|
107
|
+
*/
|
|
108
|
+
'open-settings-panel'(event) {
|
|
109
|
+
PanelManager.openSettingsPanel();
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 检查更新
|
|
114
|
+
* @param {*} event
|
|
115
|
+
*/
|
|
116
|
+
'menu-check-update'(event) {
|
|
117
|
+
checkUpdate(true);
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 版本
|
|
122
|
+
* @param {*} event
|
|
123
|
+
*/
|
|
124
|
+
'menu-version'(event) {
|
|
125
|
+
openRepository();
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 场景面板加载完成后
|
|
130
|
+
* @param {*} event
|
|
131
|
+
*/
|
|
132
|
+
'scene:ready'(event) {
|
|
133
|
+
// 自动检查更新
|
|
134
|
+
const config = ConfigManager.get();
|
|
135
|
+
if (config.autoCheckUpdate) {
|
|
136
|
+
checkUpdate(false);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 资源变化
|
|
142
|
+
* @param {*} event
|
|
143
|
+
* @param {{ type: string, uuid: string }} info
|
|
144
|
+
*/
|
|
145
|
+
'asset-db:asset-changed'(event, info) {
|
|
146
|
+
onAssetChanged(info);
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
load,
|
|
152
|
+
|
|
153
|
+
unload,
|
|
154
|
+
|
|
155
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对象工具
|
|
3
|
+
* @author 陈皮皮 (ifaswind)
|
|
4
|
+
* @version 20210929
|
|
5
|
+
*/
|
|
6
|
+
const ObjectUtil = {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 判断指定值是否是一个对象
|
|
10
|
+
* @param {any} arg 参数
|
|
11
|
+
*/
|
|
12
|
+
isObject(arg) {
|
|
13
|
+
return Object.prototype.toString.call(arg) === '[object Object]';
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 对象中是否包含指定的属性
|
|
18
|
+
* @param {object} object 对象
|
|
19
|
+
* @param {string} name 属性名
|
|
20
|
+
*/
|
|
21
|
+
containsProperty(object, name) {
|
|
22
|
+
let result = false;
|
|
23
|
+
const search = (_object) => {
|
|
24
|
+
if (ObjectUtil.isObject(_object)) {
|
|
25
|
+
for (const key in _object) {
|
|
26
|
+
if (key == name) {
|
|
27
|
+
result = true;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
search(_object[key]);
|
|
31
|
+
}
|
|
32
|
+
} else if (Array.isArray(_object)) {
|
|
33
|
+
for (let i = 0, l = _object.length; i < l; i++) {
|
|
34
|
+
search(_object[i]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
search(object);
|
|
39
|
+
return result;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 对象中是否包含指定的值
|
|
44
|
+
* @param {object} object 对象
|
|
45
|
+
* @param {any} value 值
|
|
46
|
+
*/
|
|
47
|
+
containsValue(object, value) {
|
|
48
|
+
let result = false;
|
|
49
|
+
const search = (_object) => {
|
|
50
|
+
if (ObjectUtil.isObject(_object)) {
|
|
51
|
+
for (const key in _object) {
|
|
52
|
+
if (_object[key] === value) {
|
|
53
|
+
result = true;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
search(_object[key]);
|
|
57
|
+
}
|
|
58
|
+
} else if (Array.isArray(_object)) {
|
|
59
|
+
for (let i = 0, l = _object.length; i < l; i++) {
|
|
60
|
+
search(_object[i]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
search(object);
|
|
65
|
+
return result;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
module.exports = ObjectUtil;
|
package//345/274/225/347/224/250/346/237/245/346/211/276/345/231/250/src/main/panel-manager.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const { BrowserWindow } = require('electron');
|
|
2
|
+
const { join } = require('path');
|
|
3
|
+
const { language, translate } = require('../eazax/editor-main-util');
|
|
4
|
+
const { calcWindowPosition } = require('../eazax/window-util');
|
|
5
|
+
|
|
6
|
+
/** 扩展名称 */
|
|
7
|
+
const EXTENSION_NAME = translate('name');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 面板管理器 (主进程)
|
|
11
|
+
*/
|
|
12
|
+
const PanelManager = {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 面板实例
|
|
16
|
+
* @type {BrowserWindow}
|
|
17
|
+
*/
|
|
18
|
+
settings: null,
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 打开设置面板
|
|
22
|
+
*/
|
|
23
|
+
openSettingsPanel() {
|
|
24
|
+
// 已打开则直接展示
|
|
25
|
+
if (PanelManager.settings) {
|
|
26
|
+
PanelManager.settings.show();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// 窗口尺寸和位置
|
|
30
|
+
const winSize = [500, 346],
|
|
31
|
+
winPos = calcWindowPosition(winSize, 'center');
|
|
32
|
+
// 创建窗口
|
|
33
|
+
const win = PanelManager.settings = new BrowserWindow({
|
|
34
|
+
width: winSize[0],
|
|
35
|
+
height: winSize[1],
|
|
36
|
+
minWidth: winSize[0],
|
|
37
|
+
minHeight: winSize[1],
|
|
38
|
+
x: winPos[0],
|
|
39
|
+
y: winPos[1] - 100,
|
|
40
|
+
useContentSize: true,
|
|
41
|
+
frame: true,
|
|
42
|
+
title: `${EXTENSION_NAME} | Cocos Creator`,
|
|
43
|
+
autoHideMenuBar: true,
|
|
44
|
+
resizable: true,
|
|
45
|
+
minimizable: false,
|
|
46
|
+
maximizable: false,
|
|
47
|
+
fullscreenable: false,
|
|
48
|
+
skipTaskbar: false,
|
|
49
|
+
alwaysOnTop: true,
|
|
50
|
+
hasShadow: true,
|
|
51
|
+
show: false,
|
|
52
|
+
webPreferences: {
|
|
53
|
+
nodeIntegration: true,
|
|
54
|
+
contextIsolation: false,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
// 就绪后(展示,避免闪烁)
|
|
58
|
+
win.on('ready-to-show', () => win.show());
|
|
59
|
+
// 关闭后
|
|
60
|
+
win.on('closed', () => (PanelManager.settings = null));
|
|
61
|
+
// 监听按键
|
|
62
|
+
win.webContents.on('before-input-event', (event, input) => {
|
|
63
|
+
if (input.key === 'Escape') PanelManager.closeSettingsPanel();
|
|
64
|
+
});
|
|
65
|
+
// 调试用的 devtools
|
|
66
|
+
// win.webContents.openDevTools({ mode: 'detach' });
|
|
67
|
+
// 加载页面
|
|
68
|
+
const path = join(__dirname, '../renderer/settings/index.html');
|
|
69
|
+
win.loadURL(`file://${path}?lang=${language}`);
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 关闭面板
|
|
74
|
+
*/
|
|
75
|
+
closeSettingsPanel() {
|
|
76
|
+
if (!PanelManager.settings) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
PanelManager.settings.hide();
|
|
80
|
+
PanelManager.settings.close();
|
|
81
|
+
PanelManager.settings = null;
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
module.exports = PanelManager;
|