1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var FairyEditor = CS.FairyEditor;
- const FindFailureAssetsWnd_1 = require("./FindFailureAssetsWnd");
- const UIWindow_1 = require("./UIWindow");
- const FindDependencyQueryWnd_1 = require("./FindDependencyQueryWnd");
- const PsdToFgui_1 = require("./PsdToFgui");
- const App = FairyEditor.App;
- const XGameMenuName = "XGameMenu";
- const NoExportKey = "noexport"; // 不导出的贴图
- class MenuExtension {
- start() {
- this.registerMenu();
- }
- registerMenu() {
- // 主菜单不能加回调事件,否则会报错
- App.menu.AddItem("XGame", XGameMenuName, 5, true, null);
- let xgMenu = App.menu.GetSubMenu(XGameMenuName);
- xgMenu.AddItem("psd->fgui", "psd2fgui", this.onPsd2Fgui.bind(this));
- xgMenu.AddSeperator();
- xgMenu.AddItem("贴图检测", "CollectAtlas", this.onCollectAtlas.bind(this));
- // xgMenu.AddItem("测试导入", "TestImport", () => {
- // // let cPackage = FairyEditor.App.project.AddPackage("F:/TJWork/psd2fgui/test/test-fairypackage");
- // let cPackage = FairyEditor.App.project.allPackages[0];
- // let importQueue = FairyEditor.ResourceImportQueue.Create(cPackage);
- // importQueue.Add("F:/TJWork/psd2fgui/test/test.fairypackage");
- // importQueue.Process((items)=>{
- // App.consoleView.Log(`11111111`);
- // });
- // App.consoleView.Log(`click TestImport pkgItem:${cPackage?.name ?? "0000"}`);
- // // FairyEditor.App.libView.ShowImportResourcesDialog(pkgItem, "F:/CCWork/zhetian_client/fgui-project/assets/test-fairypackage");
- // // FairyEditor.BuilderUtil.OpenURL("file://F:/TJWork/psd2fgui/test/test.fairypackage");
- // });
- xgMenu.AddSeperator();
- xgMenu.AddItem("查找组件依赖关系", "findDependency", this.onFindDependency.bind(this));
- xgMenu.AddItem("查找无效组件", "findFailureAssets", this.onFindFailureAssets.bind(this));
- }
- onPsd2Fgui() {
- let psd2fgui = new PsdToFgui_1.default();
- psd2fgui.start();
- }
- onFindDependency() {
- FindDependencyQueryWnd_1.default.show();
- }
- onFindFailureAssets() {
- FindFailureAssetsWnd_1.default.show();
- }
- onCollectAtlas() {
- let pkgs = App.project.allPackages;
- for (let index = 0; index < pkgs.Count; index++) {
- let pkg = pkgs.get_Item(index);
- for (let j = 0; j < pkg.items.Count; j++) {
- let item = pkg.items.get_Item(j);
- if (item.type != CS.FairyEditor.FObjectType.IMAGE && item.type != CS.FairyEditor.FObjectType.COMPONENT) {
- continue;
- }
- if (item.path.toLowerCase().includes(NoExportKey)) {
- if (!pkg.publishSettings.excludedList.Contains(item.id)) {
- pkg.publishSettings.excludedList.Add(item.id);
- App.consoleView.Log(`排除资源. pkg:${pkg.name} name:${item.name} file:${item.fileName}`);
- }
- continue;
- }
- if (item.type != CS.FairyEditor.FObjectType.IMAGE) {
- continue;
- }
- let isPng = item.fileName.toLowerCase().endsWith(".png");
- if (item.GetAtlasIndex() == 0 && isPng) {
- continue;
- }
- let imgAsset = item.GetAsset();
- imgAsset.atlas = isPng ? "0" : "9";
- item.SetChanged();
- App.consoleView.Log(`Image pkg:${pkg.name} fileName:${item.fileName} atlas:${item.folderAtlas} support:${item.supportAtlas} Index:${item.GetAtlasIndex()} file:${imgAsset.file} atlas:${imgAsset.atlas}`);
- }
- pkg.SetChanged();
- pkg.Save();
- }
- App.RefreshProject();
- }
- onDestroy() {
- UIWindow_1.default.delAll([]);
- App.menu.RemoveItem(XGameMenuName);
- }
- }
- exports.default = MenuExtension;
|