@gedit/editor-2d 0.3.5 → 0.3.6
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/LICENSE +21 -0
- package/lib/browser/editor2d-anim-path-selection-service.d.ts +24 -0
- package/lib/browser/editor2d-anim-path-selection-service.d.ts.map +1 -0
- package/lib/browser/editor2d-anim-path-selection-service.js +52 -0
- package/lib/browser/editor2d-anim-path-selection-service.js.map +1 -0
- package/lib/browser/editor2d-context-key-service.js +7 -10
- package/lib/browser/editor2d-context-key-service.js.map +1 -1
- package/lib/browser/editor2d-contribution.js +25 -28
- package/lib/browser/editor2d-contribution.js.map +1 -1
- package/lib/browser/editor2d-frontend-module.d.ts.map +1 -1
- package/lib/browser/editor2d-frontend-module.js +38 -38
- package/lib/browser/editor2d-frontend-module.js.map +1 -1
- package/lib/browser/editor2d-label-provider.js +18 -21
- package/lib/browser/editor2d-label-provider.js.map +1 -1
- package/lib/browser/editor2d-model-provider.js +16 -19
- package/lib/browser/editor2d-model-provider.js.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.js +13 -16
- package/lib/browser/editor2d-ref-provider-contribution.js.map +1 -1
- package/lib/browser/editor2d-service.d.ts +2 -0
- package/lib/browser/editor2d-service.d.ts.map +1 -1
- package/lib/browser/editor2d-service.js +28 -27
- package/lib/browser/editor2d-service.js.map +1 -1
- package/lib/browser/index.d.ts +2 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +6 -20
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/model/editor2d-document.d.ts +22 -9
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +248 -133
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d-iterator.js +1 -5
- package/lib/browser/model/editor2d-iterator.js.map +1 -1
- package/lib/browser/model/editor2d-model-container.js +22 -26
- package/lib/browser/model/editor2d-model-container.js.map +1 -1
- package/lib/browser/model/editor2d-model.js +21 -24
- package/lib/browser/model/editor2d-model.js.map +1 -1
- package/lib/browser/model/editor2d-selection.js +7 -10
- package/lib/browser/model/editor2d-selection.js.map +1 -1
- package/lib/browser/model/editor2d-widget.js +17 -20
- package/lib/browser/model/editor2d-widget.js.map +1 -1
- package/lib/browser/model/editor2d.d.ts.map +1 -1
- package/lib/browser/model/editor2d.js +37 -35
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/model/index.js +7 -23
- package/lib/browser/model/index.js.map +1 -1
- package/lib/browser/model/utils/anim.utils.d.ts +2 -1
- package/lib/browser/model/utils/anim.utils.d.ts.map +1 -1
- package/lib/browser/model/utils/anim.utils.js +14 -16
- package/lib/browser/model/utils/anim.utils.js.map +1 -1
- package/lib/browser/model/utils/index.js +1 -17
- package/lib/browser/model/utils/index.js.map +1 -1
- package/lib/browser/playground/anim-path-edit-layer.d.ts +33 -0
- package/lib/browser/playground/anim-path-edit-layer.d.ts.map +1 -0
- package/lib/browser/playground/anim-path-edit-layer.js +352 -0
- package/lib/browser/playground/anim-path-edit-layer.js.map +1 -0
- package/lib/browser/playground/canvas-draw.d.ts +3 -0
- package/lib/browser/playground/canvas-draw.d.ts.map +1 -1
- package/lib/browser/playground/canvas-draw.js +57 -39
- package/lib/browser/playground/canvas-draw.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +29 -32
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/entities/document-entity.js +2 -6
- package/lib/browser/playground/entities/document-entity.js.map +1 -1
- package/lib/browser/playground/entities/editor2d-entity.js +3 -7
- package/lib/browser/playground/entities/editor2d-entity.js.map +1 -1
- package/lib/browser/playground/entities/extend-entity.js +2 -6
- package/lib/browser/playground/entities/extend-entity.js.map +1 -1
- package/lib/browser/playground/entities/index.js +3 -19
- package/lib/browser/playground/entities/index.js.map +1 -1
- package/lib/browser/playground/extend-edit/gradient-conic-node.d.ts +4 -0
- package/lib/browser/playground/extend-edit/gradient-conic-node.d.ts.map +1 -0
- package/lib/browser/playground/extend-edit/gradient-conic-node.js +69 -0
- package/lib/browser/playground/extend-edit/gradient-conic-node.js.map +1 -0
- package/lib/browser/playground/{extend-edit-layer-point-event.d.ts → extend-edit/gradient-edit-layer-point-event.d.ts} +1 -1
- package/lib/browser/playground/extend-edit/gradient-edit-layer-point-event.d.ts.map +1 -0
- package/lib/browser/playground/{extend-edit-layer-point-event.js → extend-edit/gradient-edit-layer-point-event.js} +3 -28
- package/lib/browser/playground/extend-edit/gradient-edit-layer-point-event.js.map +1 -0
- package/lib/browser/playground/extend-edit/gradient-node.d.ts +13 -0
- package/lib/browser/playground/extend-edit/gradient-node.d.ts.map +1 -0
- package/lib/browser/playground/extend-edit/gradient-node.js +154 -0
- package/lib/browser/playground/extend-edit/gradient-node.js.map +1 -0
- package/lib/browser/playground/extend-edit-layer.d.ts +0 -8
- package/lib/browser/playground/extend-edit-layer.d.ts.map +1 -1
- package/lib/browser/playground/extend-edit-layer.js +30 -249
- package/lib/browser/playground/extend-edit-layer.js.map +1 -1
- package/lib/browser/playground/index.js +11 -30
- package/lib/browser/playground/index.js.map +1 -1
- package/lib/browser/playground/path-edit/anim-path-edit-svg.d.ts +17 -0
- package/lib/browser/playground/path-edit/anim-path-edit-svg.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/anim-path-edit-svg.js +58 -0
- package/lib/browser/playground/path-edit/anim-path-edit-svg.js.map +1 -0
- package/lib/browser/playground/path-edit/index.js +3 -19
- package/lib/browser/playground/path-edit/index.js.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js +9 -39
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts +2 -6
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js +20 -50
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js.map +1 -1
- package/lib/browser/playground/path-edit/utils.js +64 -100
- package/lib/browser/playground/path-edit/utils.js.map +1 -1
- package/lib/browser/playground/path-edit-layer.d.ts.map +1 -1
- package/lib/browser/playground/path-edit-layer.js +67 -95
- package/lib/browser/playground/path-edit-layer.js.map +1 -1
- package/lib/browser/playground/playground-context.d.ts +3 -3
- package/lib/browser/playground/playground-context.d.ts.map +1 -1
- package/lib/browser/playground/playground-context.js +48 -54
- package/lib/browser/playground/playground-context.js.map +1 -1
- package/lib/browser/playground/playground-contribution.d.ts.map +1 -1
- package/lib/browser/playground/playground-contribution.js +41 -42
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/playground/selection-entity-manager.d.ts.map +1 -1
- package/lib/browser/playground/selection-entity-manager.js +26 -54
- package/lib/browser/playground/selection-entity-manager.js.map +1 -1
- package/lib/browser/playground/selector-extend-icons.js +12 -39
- package/lib/browser/playground/selector-extend-icons.js.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.js +22 -52
- package/lib/browser/playground/selector-extend-renderer.js.map +1 -1
- package/lib/browser/utils/bezier.path.utils.d.ts +23 -0
- package/lib/browser/utils/bezier.path.utils.d.ts.map +1 -0
- package/lib/browser/utils/bezier.path.utils.js +64 -0
- package/lib/browser/utils/bezier.path.utils.js.map +1 -0
- package/lib/browser/utils/bounds.js +17 -21
- package/lib/browser/utils/bounds.js.map +1 -1
- package/lib/browser/utils/snapshot.js +17 -20
- package/lib/browser/utils/snapshot.js.map +1 -1
- package/lib/i18n/zh-CN.js +1 -3
- package/lib/i18n/zh-CN.js.map +1 -1
- package/package.json +11 -10
- package/src/browser/editor2d-anim-path-selection-service.ts +48 -0
- package/src/browser/editor2d-frontend-module.ts +2 -0
- package/src/browser/editor2d-service.ts +2 -0
- package/src/browser/index.ts +2 -1
- package/src/browser/model/editor2d-document.ts +198 -20
- package/src/browser/model/editor2d.ts +13 -2
- package/src/browser/model/utils/anim.utils.ts +10 -6
- package/src/browser/playground/anim-path-edit-layer.tsx +435 -0
- package/src/browser/playground/canvas-draw.ts +37 -2
- package/src/browser/playground/canvas-layer.ts +1 -0
- package/src/browser/playground/extend-edit/gradient-conic-node.tsx +106 -0
- package/src/browser/playground/extend-edit/gradient-node.tsx +232 -0
- package/src/browser/playground/extend-edit-layer.tsx +32 -312
- package/src/browser/playground/path-edit/anim-path-edit-svg.tsx +168 -0
- package/src/browser/playground/path-edit/path-edit-layer-move-point.tsx +1 -1
- package/src/browser/playground/path-edit/path-edit-layer-svg-path.tsx +3 -7
- package/src/browser/playground/path-edit/utils.tsx +1 -1
- package/src/browser/playground/path-edit-layer.tsx +4 -4
- package/src/browser/playground/playground-context.ts +2 -6
- package/src/browser/playground/playground-contribution.ts +2 -0
- package/src/browser/playground/selection-entity-manager.tsx +7 -7
- package/src/browser/style/path-edit-layer.less +13 -5
- package/src/browser/utils/bezier.path.utils.ts +89 -0
- package/lib/browser/playground/extend-edit-layer-point-event.d.ts.map +0 -1
- package/lib/browser/playground/extend-edit-layer-point-event.js.map +0 -1
- /package/src/browser/playground/{extend-edit-layer-point-event.tsx → extend-edit/gradient-edit-layer-point-event.tsx} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,54 +10,55 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
import { inject, injectable, optional } from 'inversify';
|
|
14
|
+
import { Compare, deepClone, Emitter, omit, debounce, PromiseDeferred, URI, getByKey, coverData, setByKey, } from '@gedit/utils';
|
|
15
|
+
import { checkDuplicateNodes, Editor2dModelOptions, Editor2dNode,
|
|
16
|
+
// Editor2dNodeCache,
|
|
17
|
+
} from './editor2d';
|
|
18
|
+
import { GameObjectBaseType, GameObjectData, } from '@gedit/render-engine';
|
|
19
|
+
import { RenderEngineIDEService } from '@gedit/render-engine-ide';
|
|
20
|
+
import { CompositeTreeNode, TreeImpl, TreeNode } from '@gedit/tree';
|
|
21
|
+
import { ResourceAutoSaveService } from '@gedit/resource/lib/browser';
|
|
22
|
+
import { MessageService } from '@gedit/connection';
|
|
23
|
+
import { WorkspaceResourceService } from '@gedit/workspace-2d';
|
|
24
|
+
import { ResourceProvider } from '@gedit/resource';
|
|
25
|
+
import { AppConfigService } from '@gedit/app-config';
|
|
26
|
+
import { Editor2dIterator } from './editor2d-iterator';
|
|
27
|
+
import { ThemeService } from '@gedit/theme';
|
|
28
|
+
import { followKeyType, getFollowValue } from '@gedit/render-engine-pixi';
|
|
29
|
+
import { ConfirmDialog } from '@gedit/layout';
|
|
30
|
+
import { toFixedValue } from '@gedit/canvas-draw';
|
|
31
|
+
import { getPIXILocalBoundsByNode } from '../utils/bounds';
|
|
32
|
+
import { sortFrame } from './utils';
|
|
33
33
|
// import { getAnimationKeys, getChangeAnimationData } from './utils';
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
export const maskShowArray = [
|
|
35
|
+
GameObjectBaseType.IMAGE,
|
|
36
|
+
GameObjectBaseType.RECTANGLE,
|
|
37
|
+
GameObjectBaseType.PATH,
|
|
38
|
+
GameObjectBaseType.CIRCLE,
|
|
39
|
+
GameObjectBaseType.POLYGON,
|
|
40
|
+
GameObjectBaseType.TEXT,
|
|
41
|
+
GameObjectBaseType.TRIANGLE,
|
|
42
|
+
GameObjectBaseType.COMPONENT,
|
|
43
|
+
GameObjectBaseType.ANIM_FRAMES,
|
|
44
|
+
GameObjectBaseType.STAR,
|
|
45
|
+
GameObjectBaseType.LOTTIE,
|
|
46
46
|
];
|
|
47
47
|
// 不能当蒙板的元素,可以被蒙板
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
export const maskEnabledArray = [
|
|
49
|
+
GameObjectBaseType.GROUP,
|
|
50
|
+
GameObjectBaseType.PARTICLES,
|
|
51
51
|
];
|
|
52
52
|
// 自动忽略蒙板的元素
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
export const maskIgnoreArray = [
|
|
54
|
+
GameObjectBaseType.ANIMATION,
|
|
55
|
+
GameObjectBaseType.AUDIO,
|
|
56
56
|
// GameObjectBaseType.GROUP,
|
|
57
57
|
];
|
|
58
58
|
let versionId = 0;
|
|
59
|
-
|
|
59
|
+
export const Editor2dComponentProvider = Symbol('Editor2dComponentProvider');
|
|
60
60
|
const replaceReg = (s) => s.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
61
|
-
let Editor2dDocument = class Editor2dDocument extends
|
|
61
|
+
let Editor2dDocument = class Editor2dDocument extends TreeImpl {
|
|
62
62
|
get uri() {
|
|
63
63
|
return this.options.autoSaveService.resource.uri.toString();
|
|
64
64
|
}
|
|
@@ -76,8 +76,8 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
76
76
|
this.appConfig = appConfig;
|
|
77
77
|
this.componentProvider = componentProvider;
|
|
78
78
|
this.themeService = themeService;
|
|
79
|
-
this.onContentChangedEmitter = new
|
|
80
|
-
this.onSavedEmitter = new
|
|
79
|
+
this.onContentChangedEmitter = new Emitter();
|
|
80
|
+
this.onSavedEmitter = new Emitter();
|
|
81
81
|
this.onContentChanged = this.onContentChangedEmitter.event;
|
|
82
82
|
this.onSaved = this.onSavedEmitter.event;
|
|
83
83
|
this.animationStarted = false;
|
|
@@ -94,11 +94,11 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
94
94
|
if (!this.root) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
const currentBound =
|
|
97
|
+
const currentBound = getPIXILocalBoundsByNode(this.root);
|
|
98
98
|
Object.keys(((_a = this.componentProvider) === null || _a === void 0 ? void 0 : _a.all) || {}).forEach(c => {
|
|
99
99
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
100
100
|
const item = (_a = this.componentProvider) === null || _a === void 0 ? void 0 : _a.all[c];
|
|
101
|
-
if (((_b = item === null || item === void 0 ? void 0 : item.content) === null || _b === void 0 ? void 0 : _b.displayType) ===
|
|
101
|
+
if (((_b = item === null || item === void 0 ? void 0 : item.content) === null || _b === void 0 ? void 0 : _b.displayType) === GameObjectBaseType.COMPONENT &&
|
|
102
102
|
item.stat.uri !== this.uri) {
|
|
103
103
|
const { content, stat, version } = item;
|
|
104
104
|
// 是否用过
|
|
@@ -107,8 +107,8 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
107
107
|
const { x: minX, y: minY, maxX, maxY } = currentBound;
|
|
108
108
|
const width = maxX - minX;
|
|
109
109
|
const height = maxY - minY;
|
|
110
|
-
const x =
|
|
111
|
-
const y =
|
|
110
|
+
const x = toFixedValue(-minX / width || 0, 6);
|
|
111
|
+
const y = toFixedValue(-minY / height || 0, 6);
|
|
112
112
|
if (((_d = useNode.size) === null || _d === void 0 ? void 0 : _d.width) !== width ||
|
|
113
113
|
((_e = useNode.size) === null || _e === void 0 ? void 0 : _e.height) !== height ||
|
|
114
114
|
((_f = useNode.origin) === null || _f === void 0 ? void 0 : _f.initX) !== x ||
|
|
@@ -140,7 +140,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
140
140
|
this.onSavedEmitter.fire({ document: this, contentChanges: contents, nodes, type });
|
|
141
141
|
}
|
|
142
142
|
// pixi 组件的宽高是计算的,如果是组件,更新数据将需要同步到组件中
|
|
143
|
-
if (this.appConfig.engineName === 'pixi' && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.displayType) ===
|
|
143
|
+
if (this.appConfig.engineName === 'pixi' && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.displayType) === GameObjectBaseType.COMPONENT) {
|
|
144
144
|
clearTimeout(this.syncTimeout);
|
|
145
145
|
this.syncTimeout = setTimeout(() => {
|
|
146
146
|
// console.log(node, this.document?.uri);
|
|
@@ -161,7 +161,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
161
161
|
this.fireContentChanged([], 'update', true);
|
|
162
162
|
}));
|
|
163
163
|
// 组件数据更新
|
|
164
|
-
this.toDispose.push(this.componentProvider.onComponentChanged(
|
|
164
|
+
this.toDispose.push(this.componentProvider.onComponentChanged(debounce((compUri) => {
|
|
165
165
|
if (this.uri === compUri.toString()) {
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
@@ -183,10 +183,10 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
183
183
|
var _a;
|
|
184
184
|
if (!this.root)
|
|
185
185
|
return false;
|
|
186
|
-
for (const node of new
|
|
186
|
+
for (const node of new Editor2dIterator(this.root)) {
|
|
187
187
|
if (node !== this.root
|
|
188
|
-
&& node.displayType ===
|
|
189
|
-
&& new
|
|
188
|
+
&& node.displayType === GameObjectBaseType.COMPONENT
|
|
189
|
+
&& new URI((_a = node.component) === null || _a === void 0 ? void 0 : _a.id).displayName === compUri.displayName) {
|
|
190
190
|
return true;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -196,7 +196,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
196
196
|
* 切换资源, 只有模板编辑器需要用到
|
|
197
197
|
*/
|
|
198
198
|
async changeResource(uri) {
|
|
199
|
-
const uriObj = new
|
|
199
|
+
const uriObj = new URI(uri);
|
|
200
200
|
const resource = await this.resourceProvider(uriObj);
|
|
201
201
|
this.resourceAutoSaveService.changeResource(resource);
|
|
202
202
|
this.resourceAutoSaveService.sync();
|
|
@@ -233,24 +233,24 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
233
233
|
var _a;
|
|
234
234
|
const symbols = ((_a = this.appConfig.getConfigDataBySync()) === null || _a === void 0 ? void 0 : _a.symbols) || [];
|
|
235
235
|
if (this.root && this.root.displayType === 'component') {
|
|
236
|
-
return symbols.concat(
|
|
236
|
+
return symbols.concat(GameObjectData.getComponentSymbols(this.root));
|
|
237
237
|
}
|
|
238
238
|
return symbols;
|
|
239
239
|
}
|
|
240
240
|
createDisplayNode(displayType, parent, position, index, data) {
|
|
241
241
|
let parentNode;
|
|
242
|
-
if (!parent ||
|
|
243
|
-
parentNode = this.getNode(
|
|
242
|
+
if (!parent || Editor2dNode.isRootNode(parent)) {
|
|
243
|
+
parentNode = this.getNode(Editor2dNode.ROOT_NODE_ID);
|
|
244
244
|
}
|
|
245
245
|
else {
|
|
246
|
-
parentNode =
|
|
246
|
+
parentNode = Editor2dNode.toContainerNode(parent);
|
|
247
247
|
}
|
|
248
248
|
// const lastChild = parentNode.children.slice().reverse().find(c => c.position !== undefined);
|
|
249
249
|
const attrs = this.engineService.getDisplayDefaultData(this.engineName, displayType);
|
|
250
250
|
if (attrs.position) {
|
|
251
251
|
if (!position) {
|
|
252
252
|
const pos = 100 + Math.round(Math.random() * 100);
|
|
253
|
-
position = (displayType !==
|
|
253
|
+
position = (displayType !== GameObjectBaseType.GROUP && displayType !== GameObjectBaseType.COMPONENT) ? {
|
|
254
254
|
x: pos,
|
|
255
255
|
y: pos
|
|
256
256
|
} : { x: 0, y: 0 };
|
|
@@ -266,15 +266,15 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
266
266
|
// }
|
|
267
267
|
}
|
|
268
268
|
const name = this.getUniqueName(parentNode.children || [], (data === null || data === void 0 ? void 0 : data.name) || this.engineService.getGameObjectIDERegister(this.engineName, displayType).decoration.name);
|
|
269
|
-
const node =
|
|
270
|
-
if (
|
|
269
|
+
const node = Editor2dNode.createNode(Object.assign(Object.assign(Object.assign({}, attrs), data), { name }), displayType, undefined, Object.keys(this.nodes));
|
|
270
|
+
if (maskIgnoreArray.includes(node.displayType)) {
|
|
271
271
|
node.ignoreMask = true;
|
|
272
272
|
}
|
|
273
273
|
this.addChildren(node, parentNode, index === undefined ? 0 : index);
|
|
274
274
|
return node;
|
|
275
275
|
}
|
|
276
276
|
copyNode(targetNode) {
|
|
277
|
-
if (!targetNode ||
|
|
277
|
+
if (!targetNode || Editor2dNode.isRootNode(targetNode))
|
|
278
278
|
return;
|
|
279
279
|
const parent = targetNode.parent;
|
|
280
280
|
if (!this.canbeAddAsChild(parent, targetNode.displayType))
|
|
@@ -292,7 +292,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
292
292
|
parent = parentNode.parent;
|
|
293
293
|
}
|
|
294
294
|
if (parent) {
|
|
295
|
-
const newNode =
|
|
295
|
+
const newNode = Editor2dNode.clone(nodeData, [], Object.keys(this.nodes));
|
|
296
296
|
// 单个复制删除 mask
|
|
297
297
|
newNode.follow = {};
|
|
298
298
|
delete newNode.followChild;
|
|
@@ -320,7 +320,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
320
320
|
}
|
|
321
321
|
// 加到当前节点的后边
|
|
322
322
|
children.splice(index, 0, newNode);
|
|
323
|
-
|
|
323
|
+
CompositeTreeNode.setParent(newNode, index, parent);
|
|
324
324
|
this.refresh(parent);
|
|
325
325
|
this.fireContentChanged([newNode], 'add');
|
|
326
326
|
return newNode;
|
|
@@ -346,7 +346,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
async layerChangeDialog(name = this.deleteNames.join(',')) {
|
|
349
|
-
const dialog = new
|
|
349
|
+
const dialog = new ConfirmDialog({
|
|
350
350
|
title: '警告',
|
|
351
351
|
msg: `元素${name ? `(${name})` : ''}在代码中被使用,移动或删除将会出错!`,
|
|
352
352
|
ok: '确定',
|
|
@@ -357,10 +357,10 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
357
357
|
inCodeFunc(node) {
|
|
358
358
|
var _a;
|
|
359
359
|
// 获取所有代码片段,判断是否在代码片段内被使用;
|
|
360
|
-
const uri = new
|
|
360
|
+
const uri = new URI(this.uri);
|
|
361
361
|
const id = uri.displayName.split('.')[0];
|
|
362
362
|
// const nodePath = Editor2dNode.getNodePath(node);
|
|
363
|
-
const nodePathName =
|
|
363
|
+
const nodePathName = Editor2dNode.getNodeNamePath(node);
|
|
364
364
|
const scripts = (_a = this.componentProvider) === null || _a === void 0 ? void 0 : _a.getScriptsById(id);
|
|
365
365
|
if (scripts && scripts.length) {
|
|
366
366
|
const reg = new RegExp(`select(|ByNamePath)\\((\\"|\\')(${replaceReg(node.id)}${node.name ? `|${replaceReg(node.name)}` : ''}|${replaceReg(nodePathName)})(\\"|\\')\\)`, 'i');
|
|
@@ -415,7 +415,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
415
415
|
async layerNamePathChange(nodes, targetNode) {
|
|
416
416
|
var _a;
|
|
417
417
|
const parentChange = targetNode ? nodes.filter(c => c.parent !== targetNode) : nodes;
|
|
418
|
-
const uri = new
|
|
418
|
+
const uri = new URI(this.uri);
|
|
419
419
|
const id = uri.displayName.split('.')[0];
|
|
420
420
|
// const nodePath = Editor2dNode.getNodePath(node);
|
|
421
421
|
const scripts = (_a = this.componentProvider) === null || _a === void 0 ? void 0 : _a.getScriptsById(id);
|
|
@@ -423,7 +423,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
423
423
|
let inCode = false;
|
|
424
424
|
this.deleteNames = [];
|
|
425
425
|
parentChange.forEach(c => {
|
|
426
|
-
const nodePathName =
|
|
426
|
+
const nodePathName = Editor2dNode.getNodeNamePath(c);
|
|
427
427
|
const reg = new RegExp(`selectByNamePath\\((\\"|\\')(${replaceReg(nodePathName)})(\\"|\\')\\)`, 'i');
|
|
428
428
|
const inCodeChild = scripts === null || scripts === void 0 ? void 0 : scripts.some(d => d.match(reg));
|
|
429
429
|
if (inCodeChild) {
|
|
@@ -441,14 +441,14 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
441
441
|
return true;
|
|
442
442
|
}
|
|
443
443
|
deleteNode(targetNode, silent) {
|
|
444
|
-
if (!targetNode ||
|
|
444
|
+
if (!targetNode || Editor2dNode.isRootNode(targetNode))
|
|
445
445
|
return;
|
|
446
446
|
const parent = targetNode.parent;
|
|
447
447
|
this.delNodeSetMask(targetNode);
|
|
448
448
|
this.removeNode(targetNode);
|
|
449
|
-
|
|
450
|
-
if (!
|
|
451
|
-
|
|
449
|
+
CompositeTreeNode.removeChild(parent, targetNode);
|
|
450
|
+
if (!Editor2dNode.isRootNode(parent) && parent.children.length === 0) {
|
|
451
|
+
Editor2dNode.toLeafNode(parent);
|
|
452
452
|
}
|
|
453
453
|
this.refresh(parent);
|
|
454
454
|
if (!silent) {
|
|
@@ -456,7 +456,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
async delNode(targetNode, silent, noDialog) {
|
|
459
|
-
if (!targetNode ||
|
|
459
|
+
if (!targetNode || Editor2dNode.isRootNode(targetNode))
|
|
460
460
|
return;
|
|
461
461
|
if (!silent) {
|
|
462
462
|
this.deleteNames = [];
|
|
@@ -485,7 +485,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
rename(targetNode, name) {
|
|
488
|
-
if (!name || !targetNode ||
|
|
488
|
+
if (!name || !targetNode || Editor2dNode.isRootNode(targetNode))
|
|
489
489
|
return;
|
|
490
490
|
this.updateNode(targetNode, { name });
|
|
491
491
|
}
|
|
@@ -497,7 +497,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
497
497
|
if (!parentNode.children)
|
|
498
498
|
parentNode.children = [];
|
|
499
499
|
parentNode.children.splice(index, 0, node);
|
|
500
|
-
|
|
500
|
+
CompositeTreeNode.setParent(node, index, parentNode);
|
|
501
501
|
parentNode.expanded = true;
|
|
502
502
|
this.nextMaskToNode(node);
|
|
503
503
|
this.refresh(parentNode);
|
|
@@ -507,12 +507,105 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
507
507
|
* 打开节点
|
|
508
508
|
*/
|
|
509
509
|
expandNode(node, expanded = true) {
|
|
510
|
-
if (
|
|
510
|
+
if (CompositeTreeNode.is(node)) {
|
|
511
511
|
node.expanded = expanded;
|
|
512
512
|
this.refresh(node);
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
+
updateAnimationNode(node, data) {
|
|
516
|
+
var _a, _b;
|
|
517
|
+
if (!this.timelineService) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const frames = deepClone((_a = this.timelineService.currentTimelineData) === null || _a === void 0 ? void 0 : _a.frames) || [];
|
|
521
|
+
// 获取当前图层在动画中的数据;
|
|
522
|
+
const animItem = frames.find(c => c.id === node.id);
|
|
523
|
+
if (!animItem) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
// 取出全部帧里的 key
|
|
527
|
+
const keys = Array.from(new Set(animItem.frame.value.map((item) => item.key)));
|
|
528
|
+
Object.keys(animItem.frame.current).forEach(key => {
|
|
529
|
+
if (!keys.includes(key)) {
|
|
530
|
+
const currentValue = getByKey(data, key);
|
|
531
|
+
// 更新当前帧的数据
|
|
532
|
+
animItem.frame.current[key] = currentValue !== null && currentValue !== void 0 ? currentValue : animItem.frame.current[key];
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
/**
|
|
536
|
+
* 如果是动画节点,更新数据到动画节点上
|
|
537
|
+
* 不是动画节点,更新到当前节点上
|
|
538
|
+
*/
|
|
539
|
+
keys.forEach(key => {
|
|
540
|
+
const currentValue = getByKey(data, key);
|
|
541
|
+
if (typeof currentValue === 'undefined') {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
if (toFixedValue(currentValue, 2) !== toFixedValue(animItem.frame.current[key], 2)) {
|
|
545
|
+
animItem.frame.current[key] = currentValue !== null && currentValue !== void 0 ? currentValue : animItem.frame.current[key];
|
|
546
|
+
// 判断是否有帧
|
|
547
|
+
const frame = animItem.frame.value.find((item) => item.key === key && item.time === this.timelineService.currentTime);
|
|
548
|
+
if (frame) {
|
|
549
|
+
frame.value = currentValue;
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
animItem.frame.value.push({
|
|
553
|
+
key,
|
|
554
|
+
time: this.timelineService.currentTime,
|
|
555
|
+
value: currentValue,
|
|
556
|
+
});
|
|
557
|
+
animItem.frame.value = sortFrame(animItem.frame.value);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
// 删除data里的当前帧的数据
|
|
561
|
+
const keyArr = key.split('.');
|
|
562
|
+
keyArr.reduce((v, k, i) => {
|
|
563
|
+
if (typeof v !== 'object') {
|
|
564
|
+
return undefined;
|
|
565
|
+
}
|
|
566
|
+
if (i >= keyArr.length - 1) {
|
|
567
|
+
delete v[k];
|
|
568
|
+
}
|
|
569
|
+
return v[k];
|
|
570
|
+
}, data);
|
|
571
|
+
});
|
|
572
|
+
// 属性栏更新数据会传回来 Editor2dNode; 清除不需要的数据
|
|
573
|
+
const newData = omit(data, ['nextSibling', 'previousSibling', 'parent']);
|
|
574
|
+
const nodeData = coverData(node, newData);
|
|
575
|
+
const gameObject = this.getGameObjectById(node.id);
|
|
576
|
+
if (gameObject) {
|
|
577
|
+
gameObject.data = Object.assign(Object.assign(Object.assign({}, gameObject.data), nodeData), { id: gameObject.data.id });
|
|
578
|
+
}
|
|
579
|
+
Object.assign(node, nodeData);
|
|
580
|
+
// 通过 animation 保存;
|
|
581
|
+
// node.version = (node.version || 0) + 1;
|
|
582
|
+
// this.fireContentChanged([node], 'update', false, true);
|
|
583
|
+
const animNode = this.getNodeById(this.timelineService.currentTimelineData.id);
|
|
584
|
+
if (!animNode) {
|
|
585
|
+
console.error('动画节点不存在');
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
// 告知 node 变更,时间轴里数据更新;
|
|
589
|
+
// 使用 changeTimelineData 变更数据;
|
|
590
|
+
// const nodes = frames
|
|
591
|
+
// .map(c => this.getNodeById(c.id))
|
|
592
|
+
// .filter(c => c) as Editor2dNode[];
|
|
593
|
+
// const contents = nodes.map(n => ({ text: 'treeNode' }));
|
|
594
|
+
// this.onContentChangedEmitter.fire({
|
|
595
|
+
// document: this,
|
|
596
|
+
// contentChanges: contents,
|
|
597
|
+
// nodes,
|
|
598
|
+
// type: 'update',
|
|
599
|
+
// });
|
|
600
|
+
// 更新保存 animation 数据
|
|
601
|
+
this.updateNode(animNode, {
|
|
602
|
+
animation: Object.assign(Object.assign({}, animNode.animation), { frames })
|
|
603
|
+
}, true);
|
|
604
|
+
// 更新时间轴数据;
|
|
605
|
+
(_b = this.timelineService) === null || _b === void 0 ? void 0 : _b.changeTimelineData(animNode);
|
|
606
|
+
}
|
|
515
607
|
updateNode(node, data = {}, forceUpdate = false, noSave, noFiredChanged) {
|
|
608
|
+
var _a;
|
|
516
609
|
const treeNode = typeof node === 'string' ? this.nodes[node] : this.nodes[node.id];
|
|
517
610
|
if (!treeNode)
|
|
518
611
|
return;
|
|
@@ -522,13 +615,20 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
522
615
|
// data = { ...data, name: treeNode.name };
|
|
523
616
|
// }
|
|
524
617
|
// }
|
|
618
|
+
// 动画面板更新属性,直接更新到动画节点上, 不保存;
|
|
619
|
+
if (treeNode.useAnimationId &&
|
|
620
|
+
((_a = this.timelineService) === null || _a === void 0 ? void 0 : _a.currentTimelineData) &&
|
|
621
|
+
this.timelineService.currentTimelineData.id === treeNode.useAnimationId) {
|
|
622
|
+
this.updateAnimationNode(treeNode, data);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
525
625
|
// 这里采用深度比较, 因为数据层次定义不会太多
|
|
526
626
|
if (data && data.id && data.id !== treeNode.id) {
|
|
527
627
|
alert('节点更新出错,不同节点无法互相覆盖');
|
|
528
628
|
console.error('无法覆盖同步节点数据: ', treeNode, data);
|
|
529
629
|
return;
|
|
530
630
|
}
|
|
531
|
-
const changed = forceUpdate ? true :
|
|
631
|
+
const changed = forceUpdate ? true : Compare.isDeepChanged(treeNode, data);
|
|
532
632
|
if (changed) {
|
|
533
633
|
Object.assign(treeNode, data);
|
|
534
634
|
treeNode.version = (treeNode.version || 0) + 1;
|
|
@@ -571,6 +671,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
571
671
|
return [];
|
|
572
672
|
}
|
|
573
673
|
reloadContent(content) {
|
|
674
|
+
var _a, _b;
|
|
574
675
|
let data = { version: this.version };
|
|
575
676
|
this.loading = true;
|
|
576
677
|
try {
|
|
@@ -584,7 +685,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
584
685
|
this._localVersion = data.content.version;
|
|
585
686
|
data.content.visible = false;
|
|
586
687
|
this._saveVersion = data.version || 0;
|
|
587
|
-
this.root =
|
|
688
|
+
this.root = checkDuplicateNodes(data.content);
|
|
588
689
|
}
|
|
589
690
|
else {
|
|
590
691
|
this.root = this.createRootNode();
|
|
@@ -595,6 +696,12 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
595
696
|
this.refresh();
|
|
596
697
|
// this.loadRefInfos();
|
|
597
698
|
this.fireContentChanged([], 'add', true);
|
|
699
|
+
if ((_a = this.timelineService) === null || _a === void 0 ? void 0 : _a.currentTimelineData) {
|
|
700
|
+
const animNode = this.getNodeById(this.timelineService.currentTimelineData.id);
|
|
701
|
+
if (animNode) {
|
|
702
|
+
(_b = this.timelineService) === null || _b === void 0 ? void 0 : _b.changeTimelineData(animNode);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
598
705
|
}
|
|
599
706
|
reloadEnd() {
|
|
600
707
|
if (this.loading) {
|
|
@@ -602,9 +709,9 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
602
709
|
}
|
|
603
710
|
}
|
|
604
711
|
createRootNode() {
|
|
605
|
-
const root =
|
|
606
|
-
if (root.displayType ===
|
|
607
|
-
const defaultData = this.engineService.getDisplayDefaultData(this.engineName,
|
|
712
|
+
const root = Editor2dNode.createRootNode(new URI(this.uri));
|
|
713
|
+
if (root.displayType === GameObjectBaseType.SCENE) {
|
|
714
|
+
const defaultData = this.engineService.getDisplayDefaultData(this.engineName, GameObjectBaseType.SCENE);
|
|
608
715
|
Object.assign(root, defaultData);
|
|
609
716
|
}
|
|
610
717
|
return root;
|
|
@@ -649,7 +756,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
649
756
|
const nextIsMask = nextNode && (nextNode.isMask || nextNode.mask && !nextNode.ignoreMask);
|
|
650
757
|
// 如果底下有 mask;
|
|
651
758
|
if (nextIsMask) {
|
|
652
|
-
if (!
|
|
759
|
+
if (!maskIgnoreArray.includes(node.displayType)) {
|
|
653
760
|
node.mask = nextNode.mask || nextNode.id;
|
|
654
761
|
// 底层忽略 mask 又是 mask 的情况,用底层的 id;
|
|
655
762
|
if (nextNode.ignoreMask && nextNode.isMask) {
|
|
@@ -674,7 +781,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
674
781
|
}
|
|
675
782
|
const n = node;
|
|
676
783
|
// 跳出不是 mask 实列
|
|
677
|
-
if (!
|
|
784
|
+
if (!maskShowArray.concat(maskEnabledArray).includes(n.displayType)) {
|
|
678
785
|
return;
|
|
679
786
|
}
|
|
680
787
|
// this.updateNode(n, { mask: id });
|
|
@@ -693,7 +800,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
693
800
|
const prevNode = node.previousSibling;
|
|
694
801
|
if (prevNode &&
|
|
695
802
|
!n.ignoreMask &&
|
|
696
|
-
|
|
803
|
+
maskShowArray.concat(maskEnabledArray).includes(prevNode.displayType)) {
|
|
697
804
|
// 清除时遇到 mask 图层,改成 mask 图层再附值;
|
|
698
805
|
this.setPrevNodeMask(node.previousSibling, n.isMask && typeof id === 'undefined' ? n.id : id);
|
|
699
806
|
}
|
|
@@ -751,7 +858,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
751
858
|
let group;
|
|
752
859
|
const equalParent = nodes.every(n => n.parent === parent);
|
|
753
860
|
const l = (parent === null || parent === void 0 ? void 0 : parent.children.length) === nodes.length;
|
|
754
|
-
if (equalParent && l && (parent === null || parent === void 0 ? void 0 : parent.displayType) ===
|
|
861
|
+
if (equalParent && l && (parent === null || parent === void 0 ? void 0 : parent.displayType) === GameObjectBaseType.GROUP) {
|
|
755
862
|
group = parent;
|
|
756
863
|
}
|
|
757
864
|
group = group || await this.combineNodes(nodes);
|
|
@@ -841,7 +948,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
841
948
|
*/
|
|
842
949
|
moveUpMore(nodes) {
|
|
843
950
|
nodes = nodes.length > 1
|
|
844
|
-
? nodes.slice().sort((n1, n2) =>
|
|
951
|
+
? nodes.slice().sort((n1, n2) => CompositeTreeNode.indexOf(n1.parent, n1) - CompositeTreeNode.indexOf(n2.parent, n2))
|
|
845
952
|
: nodes;
|
|
846
953
|
nodes.forEach(n => this.moveUp(n));
|
|
847
954
|
}
|
|
@@ -850,7 +957,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
850
957
|
*/
|
|
851
958
|
moveDownMore(nodes) {
|
|
852
959
|
nodes = nodes.length > 1
|
|
853
|
-
? nodes.slice().sort((n1, n2) =>
|
|
960
|
+
? nodes.slice().sort((n1, n2) => CompositeTreeNode.indexOf(n2.parent, n2) - CompositeTreeNode.indexOf(n1.parent, n1))
|
|
854
961
|
: nodes;
|
|
855
962
|
nodes.forEach(n => this.moveDown(n));
|
|
856
963
|
}
|
|
@@ -868,11 +975,11 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
868
975
|
* @param toAfter - 是否加到目标节点的后边,默认前面
|
|
869
976
|
*/
|
|
870
977
|
async moveToNode(node, targetNode, toAfter) {
|
|
871
|
-
if (
|
|
978
|
+
if (Editor2dNode.isRootNode(targetNode) || TreeNode.equals(node, targetNode))
|
|
872
979
|
return;
|
|
873
980
|
// 判断是否有被 selectByPath 选择;
|
|
874
|
-
if (
|
|
875
|
-
|
|
981
|
+
if (Editor2dNode.getNodePath(node.parent) !==
|
|
982
|
+
Editor2dNode.getNodePath(targetNode.parent)) {
|
|
876
983
|
const del = await this.layerNamePathChange([node], targetNode);
|
|
877
984
|
if (!del) {
|
|
878
985
|
return;
|
|
@@ -963,8 +1070,26 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
963
1070
|
}
|
|
964
1071
|
return nodes;
|
|
965
1072
|
}
|
|
966
|
-
getNodeById(nodeId) {
|
|
967
|
-
|
|
1073
|
+
getNodeById(nodeId, noMerge) {
|
|
1074
|
+
var _a, _b;
|
|
1075
|
+
const node = this.nodes[nodeId];
|
|
1076
|
+
// 动画编辑,这里的 node 数据不会改变,还是没打开的数据;需要合并数据;
|
|
1077
|
+
// 动画数据在 animation 里变更附值;不会改前 document 的 node 数据;
|
|
1078
|
+
if (!noMerge && (node === null || node === void 0 ? void 0 : node.useAnimationId) &&
|
|
1079
|
+
((_b = (_a = this.timelineService) === null || _a === void 0 ? void 0 : _a.currentTimelineData) === null || _b === void 0 ? void 0 : _b.id) === node.useAnimationId) {
|
|
1080
|
+
const animNode = this.nodes[this.timelineService.currentTimelineData.id];
|
|
1081
|
+
if (animNode) {
|
|
1082
|
+
const current = animNode.animation.frames.find((c) => c.id === node.id);
|
|
1083
|
+
if (current) {
|
|
1084
|
+
const newNode = this.cloneNodeData(node);
|
|
1085
|
+
Object.keys(current.frame.current || {}).forEach(key => {
|
|
1086
|
+
setByKey(newNode, key, current.frame.current[key]);
|
|
1087
|
+
});
|
|
1088
|
+
return newNode;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
return node;
|
|
968
1093
|
}
|
|
969
1094
|
getNodeIcon(node) {
|
|
970
1095
|
if (node.tags && node.tags.length > 0) {
|
|
@@ -989,7 +1114,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
989
1114
|
return '';
|
|
990
1115
|
}
|
|
991
1116
|
getSelectedNodesWithoutRoot() {
|
|
992
|
-
return this.getSelectedNodes().filter(n => !
|
|
1117
|
+
return this.getSelectedNodes().filter(n => !Editor2dNode.isRootNode(n));
|
|
993
1118
|
}
|
|
994
1119
|
isContainNode(parent, id) {
|
|
995
1120
|
let target = this.nodes[id];
|
|
@@ -1014,8 +1139,8 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1014
1139
|
if (nodes.length > 0) {
|
|
1015
1140
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1016
1141
|
const parent = nodes[0].parent;
|
|
1017
|
-
const index =
|
|
1018
|
-
const group = this.createDisplayNode(
|
|
1142
|
+
const index = CompositeTreeNode.indexOf(parent, nodes[0]);
|
|
1143
|
+
const group = this.createDisplayNode(GameObjectBaseType.GROUP, parent, undefined, index);
|
|
1019
1144
|
await this.moveToNodesAsChildren(nodes, group, true);
|
|
1020
1145
|
return group;
|
|
1021
1146
|
}
|
|
@@ -1032,7 +1157,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1032
1157
|
}
|
|
1033
1158
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1034
1159
|
const parentNode = node.parent;
|
|
1035
|
-
const curIndex =
|
|
1160
|
+
const curIndex = CompositeTreeNode.indexOf(parentNode, node);
|
|
1036
1161
|
node.children.slice().reverse().forEach((n) => {
|
|
1037
1162
|
this.addChildren(n, parentNode, curIndex);
|
|
1038
1163
|
});
|
|
@@ -1049,7 +1174,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1049
1174
|
var _a;
|
|
1050
1175
|
if (childNode && childNode.parent === targetNode)
|
|
1051
1176
|
return true;
|
|
1052
|
-
const isRootNode =
|
|
1177
|
+
const isRootNode = Editor2dNode.isRootNode(targetNode);
|
|
1053
1178
|
const nodeDeco = this.engineService.getGameObjectDecoration(this.engineName, targetNode.displayType);
|
|
1054
1179
|
const childDeco = this.engineService.getGameObjectDecoration(this.engineName, childDisplayType);
|
|
1055
1180
|
const childTypes = typeof nodeDeco.childTypes === 'function' ? nodeDeco.childTypes(targetNode) : (nodeDeco.childTypes || []);
|
|
@@ -1085,17 +1210,18 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1085
1210
|
setAnimationStarted(b) {
|
|
1086
1211
|
this.animationStarted = b;
|
|
1087
1212
|
}
|
|
1088
|
-
startRecordAnimation(
|
|
1213
|
+
startRecordAnimation(timelineService, onNodeChange) {
|
|
1089
1214
|
// this.animationStarted = true;
|
|
1090
1215
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1091
1216
|
const getNodesToChildrenById = (n, id) => n.children && n.children.some((c) => c.id === id || getNodesToChildrenById(c, id));
|
|
1092
|
-
this.
|
|
1217
|
+
this.timelineService = timelineService;
|
|
1218
|
+
this.animationIds = timelineService.getAnimationIds();
|
|
1093
1219
|
// 缓存移到 timeline 里处理
|
|
1094
1220
|
/* const cache: Editor2dNode[] = this.animationIds
|
|
1095
1221
|
.map(id => this.getNodeById(id)).filter(n => !!n)
|
|
1096
1222
|
.map(node => this.cloneNodeData(node as Editor2dNode)); */
|
|
1097
1223
|
const toDispose = this.onContentChanged(e => {
|
|
1098
|
-
this.animationIds =
|
|
1224
|
+
this.animationIds = timelineService.getAnimationIds();
|
|
1099
1225
|
// TODO 删除动画元件后,动画面板清空数据
|
|
1100
1226
|
if (e.nodes) {
|
|
1101
1227
|
const nodes = e.nodes.filter((n) =>
|
|
@@ -1151,7 +1277,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1151
1277
|
refresh(raw) {
|
|
1152
1278
|
if (!raw)
|
|
1153
1279
|
return super.refresh();
|
|
1154
|
-
const deferred = new
|
|
1280
|
+
const deferred = new PromiseDeferred();
|
|
1155
1281
|
if (this.refreshingNodes.has(raw)) {
|
|
1156
1282
|
const cache = this.refreshingNodes.get(raw);
|
|
1157
1283
|
cache.deferred.resolve(undefined);
|
|
@@ -1169,7 +1295,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1169
1295
|
return deferred.promise;
|
|
1170
1296
|
}
|
|
1171
1297
|
cloneNodeData(node) {
|
|
1172
|
-
return
|
|
1298
|
+
return deepClone(omit(node, ['parent', 'previousSibling', 'nextSibling', 'selected', 'canvasHide', 'version']));
|
|
1173
1299
|
}
|
|
1174
1300
|
get version() {
|
|
1175
1301
|
return this._localVersion;
|
|
@@ -1219,7 +1345,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1219
1345
|
if (!this.root)
|
|
1220
1346
|
return [];
|
|
1221
1347
|
const nodes = [];
|
|
1222
|
-
for (const node of new
|
|
1348
|
+
for (const node of new Editor2dIterator(this.root)) {
|
|
1223
1349
|
if (node !== this.root && (!types || types.includes(node.displayType))) {
|
|
1224
1350
|
nodes.push(node);
|
|
1225
1351
|
}
|
|
@@ -1230,7 +1356,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1230
1356
|
const node = this.nodes[nodeId];
|
|
1231
1357
|
if (!node)
|
|
1232
1358
|
return '';
|
|
1233
|
-
const objectId =
|
|
1359
|
+
const objectId = Editor2dNode.getNodePath(node);
|
|
1234
1360
|
return objectId;
|
|
1235
1361
|
}
|
|
1236
1362
|
/**
|
|
@@ -1283,7 +1409,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1283
1409
|
if (node.follow) {
|
|
1284
1410
|
const { open, target, type } = node.follow;
|
|
1285
1411
|
if (open && target && node.position) {
|
|
1286
|
-
this.message.warn(`元素开启了跟随,${(type === null || type === void 0 ? void 0 : type.map(c =>
|
|
1412
|
+
this.message.warn(`元素开启了跟随,${(type === null || type === void 0 ? void 0 : type.map(c => followKeyType[c]).join(',')) || 'x'} 被锁定`, { timeout: 2000 });
|
|
1287
1413
|
const p = this.getFollowPosition(node);
|
|
1288
1414
|
p.forEach(c => {
|
|
1289
1415
|
if (c.type === 'x' || c.type === 'y') {
|
|
@@ -1324,7 +1450,7 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1324
1450
|
if (open && target && node.position) {
|
|
1325
1451
|
const targetNode = this.getNodeById(target);
|
|
1326
1452
|
if (targetNode && targetNode.position) {
|
|
1327
|
-
const t =
|
|
1453
|
+
const t = getFollowValue(node.follow, targetNode);
|
|
1328
1454
|
return t;
|
|
1329
1455
|
}
|
|
1330
1456
|
}
|
|
@@ -1356,35 +1482,24 @@ let Editor2dDocument = class Editor2dDocument extends tree_1.TreeImpl {
|
|
|
1356
1482
|
}
|
|
1357
1483
|
});
|
|
1358
1484
|
}
|
|
1359
|
-
/**
|
|
1360
|
-
* 资源重新加载
|
|
1361
|
-
*/
|
|
1362
|
-
async reloadAssets(assets) {
|
|
1363
|
-
if (!assets.length) {
|
|
1364
|
-
return;
|
|
1365
|
-
}
|
|
1366
|
-
const game = this.engineService.getGameWidgetByUri(this.uri);
|
|
1367
|
-
const scene = game === null || game === void 0 ? void 0 : game.getCurrentScene();
|
|
1368
|
-
await (scene === null || scene === void 0 ? void 0 : scene.refresh(assets));
|
|
1369
|
-
}
|
|
1370
1485
|
};
|
|
1371
1486
|
Editor2dDocument = __decorate([
|
|
1372
|
-
|
|
1373
|
-
__param(0,
|
|
1374
|
-
__param(1,
|
|
1375
|
-
__param(2,
|
|
1376
|
-
__param(3,
|
|
1377
|
-
__param(4,
|
|
1378
|
-
__param(5,
|
|
1379
|
-
__param(6,
|
|
1380
|
-
__param(7,
|
|
1381
|
-
__param(7,
|
|
1382
|
-
__param(8,
|
|
1383
|
-
__param(8,
|
|
1384
|
-
__metadata("design:paramtypes", [
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1487
|
+
injectable(),
|
|
1488
|
+
__param(0, inject(MessageService)),
|
|
1489
|
+
__param(1, inject(Editor2dModelOptions)),
|
|
1490
|
+
__param(2, inject(ResourceProvider)),
|
|
1491
|
+
__param(3, inject(ResourceAutoSaveService)),
|
|
1492
|
+
__param(4, inject(WorkspaceResourceService)),
|
|
1493
|
+
__param(5, inject(RenderEngineIDEService)),
|
|
1494
|
+
__param(6, inject(AppConfigService)),
|
|
1495
|
+
__param(7, inject(Editor2dComponentProvider)),
|
|
1496
|
+
__param(7, optional()),
|
|
1497
|
+
__param(8, inject(ThemeService)),
|
|
1498
|
+
__param(8, optional()),
|
|
1499
|
+
__metadata("design:paramtypes", [MessageService, Object, Function, ResourceAutoSaveService,
|
|
1500
|
+
WorkspaceResourceService,
|
|
1501
|
+
RenderEngineIDEService,
|
|
1502
|
+
AppConfigService, Object, ThemeService])
|
|
1388
1503
|
], Editor2dDocument);
|
|
1389
|
-
|
|
1504
|
+
export { Editor2dDocument };
|
|
1390
1505
|
//# sourceMappingURL=editor2d-document.js.map
|