@gedit/editor-2d 0.1.31 → 0.1.38
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/lib/browser/editor2d-model-provider.d.ts +1 -0
- package/lib/browser/editor2d-model-provider.d.ts.map +1 -1
- package/lib/browser/editor2d-model-provider.js +1 -0
- package/lib/browser/editor2d-model-provider.js.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.d.ts.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.js +1 -0
- package/lib/browser/editor2d-ref-provider-contribution.js.map +1 -1
- package/lib/browser/model/editor2d-document.d.ts +11 -6
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +54 -20
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d.d.ts +3 -0
- package/lib/browser/model/editor2d.d.ts.map +1 -1
- package/lib/browser/model/editor2d.js +5 -0
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts +14 -1
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +72 -30
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/entities/editor2d-entity.d.ts +0 -1
- package/lib/browser/playground/entities/editor2d-entity.d.ts.map +1 -1
- package/lib/browser/playground/entities/editor2d-entity.js +5 -6
- package/lib/browser/playground/entities/editor2d-entity.js.map +1 -1
- package/lib/browser/playground/playground-context.d.ts +5 -3
- package/lib/browser/playground/playground-context.d.ts.map +1 -1
- package/lib/browser/playground/playground-context.js +11 -2
- 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 +24 -26
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/playground/selection-entity-manager.d.ts +4 -2
- package/lib/browser/playground/selection-entity-manager.d.ts.map +1 -1
- package/lib/browser/playground/selection-entity-manager.js +21 -24
- package/lib/browser/playground/selection-entity-manager.js.map +1 -1
- package/package.json +7 -7
- package/src/browser/editor2d-model-provider.ts +1 -0
- package/src/browser/editor2d-ref-provider-contribution.ts +1 -0
- package/src/browser/model/editor2d-document.ts +63 -14
- package/src/browser/model/editor2d.ts +7 -1
- package/src/browser/playground/canvas-layer.ts +81 -33
- package/src/browser/playground/entities/editor2d-entity.ts +5 -7
- package/src/browser/playground/playground-context.ts +9 -2
- package/src/browser/playground/playground-contribution.ts +24 -26
- package/src/browser/playground/selection-entity-manager.ts +20 -24
- package/src/.DS_Store +0 -0
- package/src/browser/.DS_Store +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-entity-manager.js","sourceRoot":"","sources":["../../../src/browser/playground/selection-entity-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kCAA0D;AAC1D,8DAA4D;AAC5D,sCAAyD;AACzD,gDAK2B;AAE3B,oCAAwC;AAGxC;;GAEG;AACH;IAEE,gCACY,aAA4B,EAC5B,OAA4B,EAC5B,WAA+C;QAH3D,iBAeC;QAdW,kBAAa,GAAb,aAAa,CAAe;QAC5B,YAAO,GAAP,OAAO,CAAqB;QAC5B,gBAAW,GAAX,WAAW,CAAoC;QAJjD,sBAAiB,GAAgC,IAAI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"selection-entity-manager.js","sourceRoot":"","sources":["../../../src/browser/playground/selection-entity-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kCAA0D;AAC1D,8DAA4D;AAC5D,sCAAyD;AACzD,gDAK2B;AAE3B,oCAAwC;AAGxC;;GAEG;AACH;IAEE,gCACY,aAA4B,EAC5B,OAA4B,EAC5B,WAA+C;QAH3D,iBAeC;QAdW,kBAAa,GAAb,aAAa,CAAe;QAC5B,YAAO,GAAP,OAAO,CAAqB;QAC5B,gBAAW,GAAX,WAAW,CAAoC;QAJjD,sBAAiB,GAAgC,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AC,iBAAiB,CAAC,MAAM,EAAE,CAAA,gBAAA,4BAAE;gBAAjD,IAAM,MAAM,WAAA;gBACf,IAAI,MAAM,CAAC,SAAS,EAAE;oBACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;iBACrC;aACF;;;;;;;;;QACD,OAAO,gBAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IACD,yCAAQ,GAAR,UAAS,IAA8B;QACrC,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAkC,CAAC,CAAC;IAChE,CAAC;IACH,6BAAC;AAAD,CAAC,AAxJD,IAwJC;AAxJY,wDAAsB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gedit/editor-2d",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/browser/index",
|
|
6
6
|
"typings": "lib/browser/index.d.ts",
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@gedit/app-config": "^0.1.
|
|
13
|
-
"@gedit/editor": "^0.1.
|
|
14
|
-
"@gedit/playground": "^0.1.
|
|
15
|
-
"@gedit/render-engine-ide": "^0.1.
|
|
16
|
-
"@gedit/workspace-2d": "^0.1.
|
|
12
|
+
"@gedit/app-config": "^0.1.37",
|
|
13
|
+
"@gedit/editor": "^0.1.37",
|
|
14
|
+
"@gedit/playground": "^0.1.37",
|
|
15
|
+
"@gedit/render-engine-ide": "^0.1.37",
|
|
16
|
+
"@gedit/workspace-2d": "^0.1.37",
|
|
17
17
|
"json-stringify-pretty-compact": "^2.0.0"
|
|
18
18
|
},
|
|
19
19
|
"geditExtensions": [
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"nyc": {
|
|
35
35
|
"extends": "../../configs/nyc.json"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "1ec58b0dd56849d324e85057f54957a9e2d9c8ed"
|
|
38
38
|
}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { inject, injectable } from 'inversify';
|
|
2
2
|
import { EditorDocument, EditorDocumentChangeEvent } from '@gedit/editor';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Compare,
|
|
5
|
+
Disposable,
|
|
6
|
+
Emitter,
|
|
7
|
+
Event,
|
|
8
|
+
MaybePromise,
|
|
9
|
+
omit,
|
|
10
|
+
mapValues,
|
|
11
|
+
PromiseDeferred,
|
|
12
|
+
SizeSchema
|
|
13
|
+
} from '@gedit/utils';
|
|
4
14
|
import { Editor2dContainerNode, Editor2dContent, Editor2dModelOptions, Editor2dNode, } from './editor2d';
|
|
5
|
-
import { GameObjectBaseType, GameObjectType } from '@gedit/render-engine';
|
|
15
|
+
import { GameConfig, GameObjectBaseType, GameObjectType } from '@gedit/render-engine';
|
|
6
16
|
import { RenderEngineIDEService, GameObjectDecoration } from '@gedit/render-engine-ide';
|
|
7
17
|
import { CompositeTreeNode, ExpandableTreeNode, Tree, TreeImpl, TreeNode } from '@gedit/tree';
|
|
8
18
|
import { ResourceAutoSaveService } from '@gedit/resource/lib/browser';
|
|
@@ -14,6 +24,11 @@ import { AppConfigService } from '@gedit/app-config';
|
|
|
14
24
|
import { Editor2dIterator } from './editor2d-iterator';
|
|
15
25
|
|
|
16
26
|
let versionId = 0;
|
|
27
|
+
interface GameSceneSizeConfig {
|
|
28
|
+
width?: number // 场景宽
|
|
29
|
+
height?: number // 场景高
|
|
30
|
+
autoSize?: boolean
|
|
31
|
+
}
|
|
17
32
|
|
|
18
33
|
@injectable()
|
|
19
34
|
export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNode> implements Tree<Editor2dNode, Editor2dContainerNode>, EditorDocument {
|
|
@@ -26,7 +41,7 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
26
41
|
protected animationIds: string[] = []; // 当前正在录制的动画节点
|
|
27
42
|
private _localVersion: number = versionId++;
|
|
28
43
|
protected errors: ResourceRefError[] = [];
|
|
29
|
-
protected componentContents: { [key: string]:
|
|
44
|
+
protected componentContents: { [key: string]: Editor2dNode } = {};
|
|
30
45
|
public firstLoaded = false;
|
|
31
46
|
|
|
32
47
|
get uri(): string {
|
|
@@ -53,16 +68,20 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
53
68
|
this.toDispose.push(this.resourceService.onRefsChange(async () => {
|
|
54
69
|
await this.loadRefInfos();
|
|
55
70
|
}));
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
this.loadRefInfos().then(() => {
|
|
72
|
+
// 同步数据
|
|
73
|
+
this.resourceAutoSaveService.sync();
|
|
74
|
+
});
|
|
58
75
|
}
|
|
59
76
|
|
|
60
77
|
/**
|
|
61
78
|
* 获取依赖的组件的内容
|
|
62
79
|
* @param compPath
|
|
80
|
+
* @param parentNode
|
|
63
81
|
*/
|
|
64
|
-
getComponentContent(compPath: string):
|
|
65
|
-
|
|
82
|
+
getComponentContent(compPath: string, parentNode: Editor2dNode): Editor2dNode[] | undefined {
|
|
83
|
+
const comp = this.componentContents[compPath];
|
|
84
|
+
if (comp && comp.children) return comp.children.map(c => ({ ...c, parent: parentNode })) as Editor2dNode[];
|
|
66
85
|
}
|
|
67
86
|
createDisplayNode<E extends Editor2dNode = Editor2dNode>(displayType: GameObjectType, parent?: Editor2dNode, position?: PositionSchema, index?: number): E {
|
|
68
87
|
let parentNode: Editor2dContainerNode;
|
|
@@ -88,7 +107,7 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
88
107
|
this.engineService.getGameObjectIDERegister(this.engineName, displayType).decoration.name,
|
|
89
108
|
displayType);
|
|
90
109
|
const node = Editor2dNode.createNode({ ...attrs, name }, displayType);
|
|
91
|
-
this.addChildren(node, parentNode, index === undefined ?
|
|
110
|
+
this.addChildren(node, parentNode, index === undefined ? 0 : index);
|
|
92
111
|
return node as E;
|
|
93
112
|
}
|
|
94
113
|
copyNode(targetNode?: Editor2dNode): Editor2dNode | undefined {
|
|
@@ -152,7 +171,7 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
152
171
|
this.refresh(node as Editor2dContainerNode);
|
|
153
172
|
}
|
|
154
173
|
}
|
|
155
|
-
updateNode(node: Editor2dNode | string, data: Partial<Editor2dNode> = {}, forceUpdate: boolean = false, noSave?: boolean,
|
|
174
|
+
updateNode(node: Editor2dNode | string, data: Partial<Editor2dNode> = {}, forceUpdate: boolean = false, noSave?: boolean, noFiredChanged?: boolean): void {
|
|
156
175
|
const treeNode = typeof node === 'string' ? this.nodes[node] : node;
|
|
157
176
|
if (!treeNode) return;
|
|
158
177
|
// if (data.name) {
|
|
@@ -167,7 +186,7 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
167
186
|
Object.assign(treeNode, data);
|
|
168
187
|
treeNode.version = (treeNode.version || 0) + 1;
|
|
169
188
|
this.refresh(treeNode as Editor2dContainerNode);
|
|
170
|
-
this.fireContentChanged([treeNode], 'update', noSave,
|
|
189
|
+
this.fireContentChanged([treeNode], 'update', noSave, noFiredChanged);
|
|
171
190
|
}
|
|
172
191
|
}
|
|
173
192
|
|
|
@@ -225,11 +244,11 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
225
244
|
}
|
|
226
245
|
return root;
|
|
227
246
|
}
|
|
228
|
-
protected fireContentChanged = (nodes: Editor2dNode[], type: 'add' | 'delete' | 'update', noSave?: boolean,
|
|
247
|
+
protected fireContentChanged = (nodes: Editor2dNode[], type: 'add' | 'delete' | 'update', noSave?: boolean, noFiredChanged?: boolean): void => {
|
|
229
248
|
// TODO 这里修改目前还是全量的,需要优化
|
|
230
249
|
const contents = nodes.map(n => ({ text: 'treeNode' }));
|
|
231
250
|
this._localVersion = ++versionId;
|
|
232
|
-
if (!
|
|
251
|
+
if (!noFiredChanged) {
|
|
233
252
|
this.onContentChangedEmitter.fire({ document: this, contentChanges: contents, nodes, type });
|
|
234
253
|
}
|
|
235
254
|
if (!noSave) {
|
|
@@ -551,8 +570,22 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
551
570
|
* @protected
|
|
552
571
|
*/
|
|
553
572
|
protected async loadRefInfos(): Promise<void> {
|
|
554
|
-
|
|
555
|
-
|
|
573
|
+
const componentContents = await this.resourceService.getDependenciesContent<Editor2dContent>(this.uri, u => !!u.match(/\.comp/));
|
|
574
|
+
// TODO 模板模式暂时不做资源依赖检测
|
|
575
|
+
if (!this.options.isTemplate) {
|
|
576
|
+
this.errors = await this.resourceService.checkRefsErrors(this.uri);
|
|
577
|
+
}
|
|
578
|
+
const normalize = (node: Editor2dNode, version?: number, parent?: Editor2dNode) => {
|
|
579
|
+
if (parent) {
|
|
580
|
+
node.parent = parent as Editor2dContainerNode;
|
|
581
|
+
}
|
|
582
|
+
if (version !== undefined) {
|
|
583
|
+
node.version = version;
|
|
584
|
+
}
|
|
585
|
+
node.children = node.children ? node.children.map(c => normalize(c as Editor2dNode, version, node)) : undefined;
|
|
586
|
+
return node;
|
|
587
|
+
};
|
|
588
|
+
this.componentContents = mapValues<Editor2dNode>(componentContents, (value: Editor2dContent) => value.content ? normalize(value.content!, value.version) : undefined);
|
|
556
589
|
await this.refresh();
|
|
557
590
|
this.fireContentChanged([], 'add', true);
|
|
558
591
|
}
|
|
@@ -578,4 +611,20 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
578
611
|
}
|
|
579
612
|
return nodes;
|
|
580
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* 获取画布的宽高
|
|
616
|
+
*/
|
|
617
|
+
getSceneSize(): SizeSchema | undefined {
|
|
618
|
+
const appConfig = this.appConfig.getConfigDataBySync();
|
|
619
|
+
const root = this.root;
|
|
620
|
+
if (!root || !appConfig) return undefined;
|
|
621
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
622
|
+
const sizeConfig = (root as any)[GameObjectBaseType.SCENE] as GameSceneSizeConfig | undefined;
|
|
623
|
+
const config = GameConfig.toAutoSize(appConfig);
|
|
624
|
+
const isAuto = sizeConfig?.autoSize;
|
|
625
|
+
return {
|
|
626
|
+
width: isAuto ? config.width : sizeConfig?.width || config.width,
|
|
627
|
+
height: isAuto ? config.height : sizeConfig?.height || config.height
|
|
628
|
+
};
|
|
629
|
+
}
|
|
581
630
|
}
|
|
@@ -8,6 +8,7 @@ import { IDragEvent } from '@phosphor/dragdrop';
|
|
|
8
8
|
import { Resource } from '@gedit/resource';
|
|
9
9
|
import { WorkspaceResourceService } from '@gedit/workspace-2d';
|
|
10
10
|
import { PlaygroundConfig } from '@gedit/playground';
|
|
11
|
+
import { GameWidgetIDE } from '@gedit/render-engine-ide';
|
|
11
12
|
|
|
12
13
|
const stringify = require('json-stringify-pretty-compact');
|
|
13
14
|
|
|
@@ -115,6 +116,9 @@ export namespace Editor2dNode {
|
|
|
115
116
|
}
|
|
116
117
|
return node as Editor2dNode;
|
|
117
118
|
}
|
|
119
|
+
export function isTemplateNode(node: Editor2dNode): boolean {
|
|
120
|
+
return !!node.template?.enabled;
|
|
121
|
+
}
|
|
118
122
|
export function is(node: Object | undefined): node is Editor2dNode {
|
|
119
123
|
return !!node && 'displayType' in node;
|
|
120
124
|
}
|
|
@@ -230,13 +234,15 @@ export interface Editor2dModelOptions extends ResourceAutoSaveOptions {
|
|
|
230
234
|
autoSaveService: ResourceAutoSaveService
|
|
231
235
|
isTemplate?: boolean // 是否为模板编辑器
|
|
232
236
|
playgroundConfig?: PlaygroundConfig
|
|
237
|
+
// 画布数据更新触发, 用于生成缩略图
|
|
238
|
+
onCanvasDataChanged?(canvas: GameWidgetIDE): void
|
|
233
239
|
}
|
|
234
240
|
|
|
235
241
|
export async function getEditor2dModelOpts(resource: Resource, resourceService: WorkspaceResourceService, encoding: string = 'utf8'): Promise<Editor2dModelOptions> {
|
|
236
242
|
const options: ResourceAutoSaveOptions = {
|
|
237
243
|
encoding,
|
|
238
244
|
resource,
|
|
239
|
-
saveAsString: e => Editor2dContent.parseToString({
|
|
245
|
+
saveAsString: e => Editor2dContent.parseToString({version: e.document.version, content: e.document.root})
|
|
240
246
|
};
|
|
241
247
|
const autoSaveService = await resourceService.createAutoSaveResource(options);
|
|
242
248
|
return {
|
|
@@ -5,20 +5,28 @@ import { PlaygroundContext2d } from './playground-context';
|
|
|
5
5
|
import { Editor2dDocument, Editor2dNode } from '../model';
|
|
6
6
|
import { GameObject } from '@gedit/render-engine';
|
|
7
7
|
import { GameSceneIDE, GameWidgetIDE } from '@gedit/render-engine-ide';
|
|
8
|
-
import { Disposable } from '@gedit/utils';
|
|
8
|
+
import { Disposable, iterToArray } from '@gedit/utils';
|
|
9
|
+
import { Rectangle } from '@gedit/math';
|
|
9
10
|
import { SelectionEntityManager } from './selection-entity-manager';
|
|
10
11
|
import { AppConfigData, toAutoSize } from '@gedit/app-config/lib/common';
|
|
11
12
|
|
|
12
13
|
const CANVAS_MIN_WIDTH = 1500;
|
|
13
14
|
const CANVAS_MIN_HEIGHT = 1500;
|
|
14
|
-
const WAIT_TO_DISPOSE_TIME =
|
|
15
|
+
const WAIT_TO_DISPOSE_TIME = 60000; // 延迟删除, 这样tab在频繁切换时候不会有延迟
|
|
15
16
|
const SCENE_KEY = 'boot';
|
|
16
17
|
|
|
18
|
+
interface GameObjectState {
|
|
19
|
+
selectable: boolean,
|
|
20
|
+
adsorbable: boolean,
|
|
21
|
+
isInside: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
18
25
|
@entity(DocumentEntity) documentEntity: DocumentEntity;
|
|
19
26
|
node = domUtils.createDivWithClass('gedit-canvas-layer');
|
|
20
27
|
protected gameObjectCache: Map<string, GameObject> = new Map();
|
|
21
28
|
protected gameObjectTextureMap: Map<string, string> = new Map();
|
|
29
|
+
protected gameObjectStateMap: Map<string, GameObjectState> = new Map();
|
|
22
30
|
protected nodeVersionCache: Map<string, string> = new Map();
|
|
23
31
|
protected lastRenderKeys: string[] = [];
|
|
24
32
|
protected scene?: HTMLElement;
|
|
@@ -46,6 +54,7 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
46
54
|
this.context.syncToSelectionTree(this.selectionEntityManager);
|
|
47
55
|
}, -2),
|
|
48
56
|
]);
|
|
57
|
+
// this.entityManager.getEntity<RulerConfigEntity>(RulerConfigEntity)?.customizeOriginClick(this.config.scrollPageBoundsToCenter.bind(this));
|
|
49
58
|
this.config.loading = true;
|
|
50
59
|
}
|
|
51
60
|
|
|
@@ -127,14 +136,26 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
127
136
|
this.lastRenderKeys = renderKeys;
|
|
128
137
|
}
|
|
129
138
|
|
|
130
|
-
updateGameObject(scene: GameSceneIDE, document: Editor2dDocument, node: Editor2dNode, depth: number, renderKeys: string[]): number {
|
|
139
|
+
updateGameObject(scene: GameSceneIDE, document: Editor2dDocument, node: Editor2dNode, depth: number, renderKeys: string[], isInside: boolean = false): number {
|
|
131
140
|
const nodePath = Editor2dNode.getNodePath(node);
|
|
132
|
-
|
|
141
|
+
let children = (node.children as Editor2dNode[] || []).slice().reverse();
|
|
133
142
|
const parentId = node.parent ? Editor2dNode.getNodePath(node.parent) : undefined;
|
|
143
|
+
const deco = this.context.renderEngine.getGameObjectDecoration(document.engineName, node.displayType);
|
|
144
|
+
const compId = !Editor2dNode.isRootNode(node) && deco.getComponentId ? deco.getComponentId(node) : undefined;
|
|
145
|
+
let adsorbable = true; // 是否可被吸附
|
|
146
|
+
const selectable = !isInside && (!this.context.options.isTemplate || Editor2dNode.isTemplateNode(node)); // 是否可被选中
|
|
147
|
+
let childInside = false;
|
|
148
|
+
if (compId) {
|
|
149
|
+
children = (document.getComponentContent(compId, node) || []).slice().reverse();
|
|
150
|
+
// 内部节点
|
|
151
|
+
childInside = true;
|
|
152
|
+
// 拥有内部节点的父节点无法被吸附
|
|
153
|
+
adsorbable = false;
|
|
154
|
+
}
|
|
134
155
|
// 子节点先创建
|
|
135
156
|
if (children && children.length > 0) {
|
|
136
157
|
for (const child of children.values()) {
|
|
137
|
-
depth = this.updateGameObject(scene, document, child, depth, renderKeys);
|
|
158
|
+
depth = this.updateGameObject(scene, document, child, depth, renderKeys, childInside || isInside);
|
|
138
159
|
}
|
|
139
160
|
}
|
|
140
161
|
const gameObjectCache = this.gameObjectCache;
|
|
@@ -142,6 +163,7 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
142
163
|
let gameObject = gameObjectCache.get(nodePath);
|
|
143
164
|
let firstCreate = false;
|
|
144
165
|
const newVersion = currentDepth + (node.version || 0) + ':' + this.documentEntity.config.configVersion;
|
|
166
|
+
// 内部节点无法选中
|
|
145
167
|
if (!gameObject) {
|
|
146
168
|
const gameObjectChildren = children ? children.map(c => gameObjectCache.get(Editor2dNode.getNodePath(c))!) : [];
|
|
147
169
|
try {
|
|
@@ -158,28 +180,34 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
158
180
|
gameObjectCache.set(nodePath, gameObject);
|
|
159
181
|
scene.onGameObjectDispose(gameObject, () => {
|
|
160
182
|
this.gameObjectCache.delete(nodePath);
|
|
183
|
+
this.gameObjectStateMap.delete(nodePath);
|
|
161
184
|
this.gameObjectTextureMap.delete(nodePath);
|
|
162
185
|
this.nodeVersionCache.delete(nodePath);
|
|
163
186
|
this.selectionEntityManager.removeEntity(nodePath);
|
|
164
187
|
});
|
|
165
188
|
scene.onGameObjectUpdate(gameObject, () => {
|
|
166
|
-
this.selectionEntityManager.updateEntity(nodePath, gameObject
|
|
189
|
+
this.selectionEntityManager.updateEntity(nodePath, gameObject!, selectable, adsorbable);
|
|
167
190
|
// TODO 父节点更新则通知子节点更新, 用于刷新transform
|
|
168
191
|
gameObject!.children.forEach(c => {
|
|
169
|
-
this.
|
|
192
|
+
const state = this.gameObjectStateMap.get(c.id)!;
|
|
193
|
+
this.selectionEntityManager.updateEntity(c.id as string, c, state.selectable, state.adsorbable);
|
|
170
194
|
});
|
|
195
|
+
this.context.onCanvasDataChanged(this.renderWidget);
|
|
171
196
|
});
|
|
172
197
|
scene.onGameObjectCreate(gameObject, () => {
|
|
173
198
|
this.nodeVersionCache.set(nodePath, newVersion);
|
|
199
|
+
this.gameObjectStateMap.set(nodePath, {selectable, adsorbable, isInside});
|
|
174
200
|
// clear error
|
|
175
201
|
document.updateNode(node, {error: undefined});
|
|
176
|
-
this.selectionEntityManager.updateEntity(nodePath, gameObject
|
|
202
|
+
this.selectionEntityManager.updateEntity(nodePath, gameObject!, selectable, adsorbable);
|
|
203
|
+
// 根节点创建完成则代表加载完成
|
|
204
|
+
this.updateLoadingPercent(Editor2dNode.isRootNode(node));
|
|
177
205
|
});
|
|
178
206
|
scene.onGameObjectError(gameObject, error => {
|
|
179
207
|
document.updateNode(node, {error});
|
|
180
208
|
});
|
|
181
209
|
// 创建选择器
|
|
182
|
-
this.selectionEntityManager.createEntity(nodePath, node, gameObject);
|
|
210
|
+
this.selectionEntityManager.createEntity(nodePath, node, gameObject, selectable, adsorbable);
|
|
183
211
|
firstCreate = true;
|
|
184
212
|
}
|
|
185
213
|
if (gameObject && gameObject.getTextureId) {
|
|
@@ -189,7 +217,7 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
189
217
|
// 素材更新则销毁重新创建
|
|
190
218
|
if (oldTexture !== newTexture) {
|
|
191
219
|
gameObject.dispose();
|
|
192
|
-
return this.updateGameObject(scene, document, node, currentDepth, renderKeys);
|
|
220
|
+
return this.updateGameObject(scene, document, node, currentDepth, renderKeys, isInside);
|
|
193
221
|
}
|
|
194
222
|
}
|
|
195
223
|
const update = () => {
|
|
@@ -207,39 +235,66 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
207
235
|
}
|
|
208
236
|
renderKeys.push(nodePath);
|
|
209
237
|
depth++;
|
|
210
|
-
// 加载组件内容
|
|
211
|
-
// if (gameObject.id !== 'root' && gameObject.getContentId) {
|
|
212
|
-
// const contentId = gameObject.getContentId() || '';
|
|
213
|
-
// const content = contentId ? document.getComponentContent(contentId) : undefined;
|
|
214
|
-
// if (content && content.content && content.content.children) {
|
|
215
|
-
// // TODO 忽略循环依赖的组件
|
|
216
|
-
// // @ts-ignore
|
|
217
|
-
// content.content.children.forEach(childNode => {
|
|
218
|
-
// depth = this.updateGameObject(scene, document, { ...childNode, parent: node as Editor2dContainerNode }, depth, renderKeys);
|
|
219
|
-
// });
|
|
220
|
-
// }
|
|
221
|
-
// }
|
|
222
238
|
return depth;
|
|
223
239
|
}
|
|
240
|
+
|
|
224
241
|
get document(): Editor2dDocument | undefined {
|
|
225
242
|
return this.documentEntity.config.document;
|
|
226
243
|
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 加载完成
|
|
247
|
+
*/
|
|
248
|
+
updateLoadingPercent(allLoaded: boolean): void {
|
|
249
|
+
if (this.config.loading) {
|
|
250
|
+
const allCount = this.document?.length || 0;
|
|
251
|
+
const currentCount = iterToArray<GameObjectState>(this.gameObjectStateMap.values()).filter(v => !v.isInside).length;
|
|
252
|
+
if (allLoaded || allCount === currentCount || allCount === 0) {
|
|
253
|
+
this.config.loading = false;
|
|
254
|
+
this.tryToResizeToCenter();
|
|
255
|
+
this.node.classList.add('ready');
|
|
256
|
+
this.context.onCanvasDataChanged(this.renderWidget);
|
|
257
|
+
} else {
|
|
258
|
+
this.config.updateConfig({
|
|
259
|
+
loadingHTML: `${Math.round(currentCount / allCount * 100)}%`
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
227
265
|
onZoom(scale: number): void {
|
|
228
266
|
domUtils.setStyle(this.node, {
|
|
229
267
|
transform: `scale(${scale})`
|
|
230
268
|
});
|
|
231
269
|
}
|
|
232
|
-
|
|
233
|
-
|
|
270
|
+
private currentRectangle: Rectangle | undefined;
|
|
271
|
+
tryToResizeToCenter(): void {
|
|
272
|
+
const size = this.document?.getSceneSize();
|
|
273
|
+
if (!size || this.config.loading) return;
|
|
274
|
+
const newRect = new Rectangle(0, 0, size.width, size.height);
|
|
275
|
+
if (!this.currentRectangle || !this.currentRectangle.isEqual(newRect)) {
|
|
276
|
+
this.currentRectangle = newRect;
|
|
277
|
+
this.config.setPageBounds(newRect);
|
|
278
|
+
this.config.scrollPageBoundsToCenter(true, 10, !this.context.options.isTemplate);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
draw(): void {
|
|
283
|
+
const {document, appConfig, visible = false} = this.documentEntity.config;
|
|
234
284
|
if (!this.libLoaded && !this.libLoading) {
|
|
235
285
|
this.libLoading = true;
|
|
236
286
|
this.startLoadLibs();
|
|
237
287
|
return;
|
|
238
288
|
}
|
|
239
|
-
|
|
289
|
+
const size = document?.getSceneSize();
|
|
290
|
+
if (!document || !appConfig || !this.libLoaded || !size) return;
|
|
240
291
|
this.toggleVisible(document, appConfig, visible);
|
|
241
292
|
if (!this.renderWidget || !this.booted) return;
|
|
242
|
-
const scene = this.renderWidget.switchScene(SCENE_KEY);
|
|
293
|
+
const scene = this.renderWidget.switchScene(SCENE_KEY, size);
|
|
294
|
+
/**
|
|
295
|
+
* 尝试触发居中
|
|
296
|
+
*/
|
|
297
|
+
this.tryToResizeToCenter();
|
|
243
298
|
/**
|
|
244
299
|
* 更新canvas数据
|
|
245
300
|
*/
|
|
@@ -257,12 +312,5 @@ export class CanvasLayer extends Layer<PlaygroundContext2d> {
|
|
|
257
312
|
*/
|
|
258
313
|
const enlargeBounds = this.selectionEntityManager.getEntityEnlargeBounds(CANVAS_MIN_WIDTH, CANVAS_MIN_HEIGHT);
|
|
259
314
|
this.renderWidget.updateCanvasBounds(enlargeBounds);
|
|
260
|
-
/**
|
|
261
|
-
* 第一次加载
|
|
262
|
-
*/
|
|
263
|
-
if (this.config.loading) {
|
|
264
|
-
this.config.loading = false;
|
|
265
|
-
this.node.classList.add('ready');
|
|
266
|
-
}
|
|
267
315
|
}
|
|
268
316
|
}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { SelectableEntity } from '@gedit/playground/lib/browser';
|
|
2
2
|
import { Editor2dNode } from '../../model';
|
|
3
3
|
import { GameObject, GameObjectSelectionData } from '@gedit/render-engine-ide';
|
|
4
|
-
import { Compare } from '@gedit/utils';
|
|
4
|
+
// import { Compare } from '@gedit/utils';
|
|
5
5
|
|
|
6
6
|
export class Editor2dEntity extends SelectableEntity {
|
|
7
7
|
static type = 'Editor2dEntity';
|
|
8
8
|
node: Editor2dNode;
|
|
9
9
|
gameObject: GameObject;
|
|
10
10
|
ignoreTransformChanged = true;
|
|
11
|
-
private data?: GameObjectSelectionData;
|
|
11
|
+
// private data?: GameObjectSelectionData;
|
|
12
12
|
update(data: GameObjectSelectionData | undefined): void {
|
|
13
13
|
if (data) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.transform.fireChanged();
|
|
18
|
-
}
|
|
14
|
+
this.transform.update(data);
|
|
15
|
+
// this.data = data;
|
|
16
|
+
// this.transform.fireChanged();
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inject, injectable } from 'inversify';
|
|
2
|
-
import { RenderEngineIDEService } from '@gedit/render-engine-ide';
|
|
2
|
+
import { GameWidgetIDE, RenderEngineIDEService } from '@gedit/render-engine-ide';
|
|
3
3
|
import { SelectableTreeNode, TreeSelection } from '@gedit/tree';
|
|
4
4
|
import { AppConfigService } from '@gedit/app-config';
|
|
5
5
|
import { debounce, URI } from '@gedit/utils';
|
|
@@ -8,7 +8,7 @@ import type { SelectionEntityManager } from './selection-entity-manager';
|
|
|
8
8
|
import { Playground, Selectable } from '@gedit/playground';
|
|
9
9
|
import { Editor2dDocument } from '../model/editor2d-document';
|
|
10
10
|
import { Editor2dSelection } from '../model/editor2d-selection';
|
|
11
|
-
import { Editor2dNode } from '../model/editor2d';
|
|
11
|
+
import { Editor2dModelOptions, Editor2dNode } from '../model/editor2d';
|
|
12
12
|
import { SelectionService } from '@gedit/application-common';
|
|
13
13
|
import SelectionType = TreeSelection.SelectionType;
|
|
14
14
|
|
|
@@ -24,9 +24,16 @@ export class PlaygroundContext2d {
|
|
|
24
24
|
@inject(Editor2dSelection) readonly selection: Editor2dSelection,
|
|
25
25
|
@inject(SelectionService) readonly selectionService: SelectionService,
|
|
26
26
|
@inject(AppConfigService) readonly appConfig: AppConfigService,
|
|
27
|
+
@inject(Editor2dModelOptions) readonly options: Editor2dModelOptions
|
|
27
28
|
) {
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
// 画布数据更新
|
|
32
|
+
onCanvasDataChanged(widget?: GameWidgetIDE): void {
|
|
33
|
+
if (widget && this.options.onCanvasDataChanged) {
|
|
34
|
+
this.options.onCanvasDataChanged(widget);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
30
37
|
/**
|
|
31
38
|
* 刷新 tree selection
|
|
32
39
|
*/
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
PlaygroundContribution,
|
|
5
5
|
PlaygroundRegistry,
|
|
6
6
|
RulerConfigEntity,
|
|
7
|
-
Snapline,
|
|
8
7
|
SnaplineConfigEntity,
|
|
9
8
|
ToolbarConfigEntity
|
|
10
9
|
} from '@gedit/playground';
|
|
@@ -37,6 +36,9 @@ export class PlaygroundContribution2d implements PlaygroundContribution {
|
|
|
37
36
|
percentageInfoVisible: false,
|
|
38
37
|
});
|
|
39
38
|
}
|
|
39
|
+
playground.getConfigEntity<SnaplineConfigEntity>(SnaplineConfigEntity).updateConfig({
|
|
40
|
+
originlineVisible: false, // 隐藏原点
|
|
41
|
+
});
|
|
40
42
|
playground.toDispose.push(
|
|
41
43
|
// TODO 放在这里处理会增加复杂度
|
|
42
44
|
this.appConfig.onConfigChange(data => {
|
|
@@ -48,32 +50,28 @@ export class PlaygroundContribution2d implements PlaygroundContribution {
|
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
updateAppConfigData(data: AppConfigData, playground: Playground): void {
|
|
51
|
-
const snaplineEntity = playground.getConfigEntity<SnaplineConfigEntity>(SnaplineConfigEntity);
|
|
53
|
+
// const snaplineEntity = playground.getConfigEntity<SnaplineConfigEntity>(SnaplineConfigEntity);
|
|
52
54
|
// 更新分辨率
|
|
53
|
-
playground.
|
|
54
|
-
if (!this.modelOpts.isTemplate) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
snaplineEntity.updateConfig({
|
|
74
|
-
originlineVisible: false, // 隐藏原点
|
|
75
|
-
});
|
|
76
|
-
}
|
|
55
|
+
playground.config.updateConfig({ resolution: data.resolution });
|
|
56
|
+
// if (!this.modelOpts.isTemplate) {
|
|
57
|
+
// const lines: Snapline[] = [];
|
|
58
|
+
// lines.push({
|
|
59
|
+
// color: '#ccc',
|
|
60
|
+
// start: {x: data.width, y: data.height},
|
|
61
|
+
// vertical: true,
|
|
62
|
+
// strokeWidth: 1,
|
|
63
|
+
// });
|
|
64
|
+
// lines.push({
|
|
65
|
+
// color: '#ccc',
|
|
66
|
+
// start: {x: data.width, y: data.height},
|
|
67
|
+
// horizontal: true,
|
|
68
|
+
// strokeWidth: 1,
|
|
69
|
+
// });
|
|
70
|
+
// snaplineEntity.updateConfig({
|
|
71
|
+
// lines,
|
|
72
|
+
// originlineVisible: false,
|
|
73
|
+
// });
|
|
74
|
+
// }
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
|