diff --git a/debug.log b/debug.log index de4e5cb..d2b7f64 100644 --- a/debug.log +++ b/debug.log @@ -9,3 +9,5 @@ [0108/092244.401:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3) [0108/100658.746:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3) [0109/083452.962:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3) +[0111/084621.230:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3) +[0111/102545.331:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3) diff --git a/src/app/working-area/model/axArrowConnector.ts b/src/app/working-area/model/axArrowConnector.ts index 6ed0dd9..936b651 100644 --- a/src/app/working-area/model/axArrowConnector.ts +++ b/src/app/working-area/model/axArrowConnector.ts @@ -127,6 +127,16 @@ export class AxArrowConnector extends AxShape { this.text.visible = value; } } + /** + * + * @param scale 缁樺埗杈规 + */ + public drawBorder(scale: number) { + let visible = this.pointSprites[0].visible; + this.setPointVisiable(false); + super.drawBorder(scale); + this.setPointVisiable(visible); + } /** * 鍒锋柊褰㈢姸 */ diff --git a/src/app/working-area/model/axLegend.ts b/src/app/working-area/model/axLegend.ts index 55f4d8f..154362f 100644 --- a/src/app/working-area/model/axLegend.ts +++ b/src/app/working-area/model/axLegend.ts @@ -10,6 +10,14 @@ export class AxLegend extends AxShape { // 鏁版嵁 public shapeMap: Map = new Map(); pen: Graphics = new Graphics(); + // up: Sprite = new Sprite(this.pointTexture); + // down: Sprite= new Sprite(this.pointTexture); + // left: Sprite= new Sprite(this.pointTexture); + // right: Sprite= new Sprite(this.pointTexture); + upLeft: Sprite= new Sprite(this.pointTexture); + upRight: Sprite= new Sprite(this.pointTexture); + downLeft: Sprite= new Sprite(this.pointTexture); + downRight: Sprite= new Sprite(this.pointTexture); /** * */ @@ -102,6 +110,120 @@ export class AxLegend extends AxShape { } this.addChild(this.pen); this.angle = -this.workingArea.backgroundImage.angle; + // 娣诲姞border + this.addChild(this.border); + // 娣诲姞鎺у埗鐐 + this.addChild(this.upLeft); + this.upLeft.anchor.set(0.5); + this.upLeft.interactive = true; + this.upLeft.visible = false; + var posX = 0; + var w = this.width; + this.upLeft + .on('pointerdown', event => { + event.stopPropagation(); + event.currentTarget.data = event.data; + event.currentTarget.alpha = 0.5; + event.currentTarget.dragging = true; + + event.currentTarget.dragPoint = event.data.getLocalPosition(event.currentTarget.parent); + + var gPos = this.upLeft.getGlobalPosition(new Point(this.downRight.x, this.downRight.y)); + var temp1 = this.workingArea.backgroundImage.toLocal(gPos); + this.pivot.set(this.downRight.x, this.downRight.y); + this.position.set(temp1.x,temp1.y); + + }) + .on('pointerup', event => { + if (event.currentTarget.dragging) { + event.currentTarget.alpha = 1; + event.currentTarget.dragging = false; + event.currentTarget.data = null; + } + }) + .on('pointerupoutside', event => { + if (event.currentTarget.dragging) { + event.currentTarget.alpha = 1; + event.currentTarget.dragging = false; + event.currentTarget.data = null; + } + }) + .on('pointermove', event => { + if (event.currentTarget.dragging) { + const newPosition = event.currentTarget.data.getLocalPosition(event.currentTarget.parent); + // event.currentTarget.x = newPosition.x; + // event.currentTarget.y = newPosition.y; + var width = -(newPosition.x - event.currentTarget.dragPoint.x) + var height = -(newPosition.y - event.currentTarget.dragPoint.y); + if (width > 0) { + this.scale.x += 0.01; + this.scale.y += 0.01; + } else { + this.scale.x -= 0.01; + this.scale.y -= 0.01; + } + } + }) + .on('rightclick', event => { + this.border.visible = false; + }) + .on('pointerover', event => { + event.stopPropagation(); + }) + .on('pointerout', event => { + event.stopPropagation(); + }); + this.addChild(this.upRight); + this.upRight.anchor.set(0.5); + this.upRight.interactive = true; + this.upRight.visible = false; + this.addChild(this.downLeft); + this.downLeft.anchor.set(0.5); + this.downLeft.interactive = true; + this.downLeft.visible = false; + this.addChild(this.downRight); + this.downRight.anchor.set(0.5); + this.downRight.interactive = true; + this.downRight.visible = false; + } + /** + * 璁剧疆鐐规樉绀虹姸鎬 + * @param value 鏄剧ず鐘舵 + */ + public setPointVisiable(value: boolean) { + let rect = this.getLocalBounds(); + this.upLeft.x = rect.left; + this.upLeft.y = rect.top; + this.upRight.x = rect.right; + this.upRight.y = rect.top; + this.downLeft.x = rect.left; + this.downLeft.y = rect.bottom; + this.downRight.x = rect.right; + this.downRight.y = rect.bottom; + this.upLeft.visible = value; + this.upRight.visible = value; + this.downLeft.visible = value; + this.downRight.visible = value; + } + /** + * + * @param scale 缁樺埗杈规 + */ + public drawBorder(scale: number) { + let visible = this.upLeft.visible; + this.setPointVisiable(false); + + super.drawBorder(scale); + let rect = this.getLocalBounds(); + this.upLeft.x = rect.left; + this.upLeft.y = rect.top; + this.upRight.x = rect.right; + this.upRight.y = rect.top; + this.downLeft.x = rect.left; + this.downLeft.y = rect.bottom; + this.downRight.x = rect.right; + this.downRight.y = rect.bottom; + this.setPointVisiable(visible); } } diff --git a/src/app/working-area/model/axShape.ts b/src/app/working-area/model/axShape.ts index 7e784b3..96f6a1e 100644 --- a/src/app/working-area/model/axShape.ts +++ b/src/app/working-area/model/axShape.ts @@ -101,18 +101,7 @@ export class AxShape extends Container { public setItemScale(scale: number) { } - /** - * 鏄剧ず杈规 - */ - public showBorder() { - if (this.assetData.FixedSize) { - this.drawBorder(1); - } - else { - this.drawBorder(1/this.workingArea.backgroundImage.scale.x); - } - this.border.visible = true; - } + /** * 闅愯棌杈规 */ @@ -158,6 +147,7 @@ export class AxShape extends Container { this.border.lineTo(p4.x, p4.y); this.border.closePath(); this.border.endFill(); + this.border.visible = true; } // 鐢昏櫄绾 drawDash(target, x1, y1, x2, y2,dashLength = 5, spaceLength = 1) { diff --git a/src/app/working-area/model/messageSystem.ts b/src/app/working-area/model/messageSystem.ts new file mode 100644 index 0000000..322eef4 --- /dev/null +++ b/src/app/working-area/model/messageSystem.ts @@ -0,0 +1,37 @@ +class MyEvent extends CustomEvent { + public static readonly CMD: string = "EVENT_NAME"; + public constructor($type: string , $data: T ) { + super( $type , { detail: $data, bubbles: true, cancelable: true, composed: true }); + } +} + +class MyDispatch extends EventTarget { + private static _instance: MyDispatch; + public static get Instance(): MyDispatch { + if (!MyDispatch._instance) MyDispatch._instance = new MyDispatch(); + return MyDispatch._instance; + } + public send($data: T, $type: string = MyEvent.CMD): void { + const $event: CustomEvent = new MyEvent($type, $data); + this.dispatchEvent($event); + } +} + +class Test { + + public constructor() { + MyDispatch.Instance.addEventListener(MyEvent.CMD, this.onEvent as EventListener); + } + private onEvent($e: MyEvent): void { + console.log(`target ${$e.target}`); + console.log(`name: ${$e.detail._name} , occupation: ${$e.detail._occupation}`); + } +} + +interface ITest { + _name: string; + _occupation: string; +} + +let $test: Test = new Test(); +MyDispatch.Instance.send({ _name: `Aonaufly`, _occupation: `it` }); diff --git a/src/app/working-area/model/multipointIcon.ts b/src/app/working-area/model/multipointIcon.ts index a996b5f..55ac71a 100644 --- a/src/app/working-area/model/multipointIcon.ts +++ b/src/app/working-area/model/multipointIcon.ts @@ -189,6 +189,16 @@ export class MultipointIcon extends AxShape { item.visible = value; }); } + /** + * + * @param scale 缁樺埗杈规 + */ + public drawBorder(scale: number) { + let visible = this.pointsGraphics[0].visible; + this.setPointVisiable(false); + super.drawBorder(scale); + this.setPointVisiable(visible); + } // 璁剧疆鍚嶇О public setNameVisible(value: boolean, mode: GameMode) { if (this.assetData.GameMode === mode) { diff --git a/src/app/working-area/model/polygonIcon.ts b/src/app/working-area/model/polygonIcon.ts index 2494748..0186a11 100644 --- a/src/app/working-area/model/polygonIcon.ts +++ b/src/app/working-area/model/polygonIcon.ts @@ -155,6 +155,16 @@ export class PolygonIcon extends AxShape { item.visible = value; }); } + /** + * + * @param scale 缁樺埗杈规 + */ + public drawBorder(scale: number) { + let visible = this.pointsGraphics[0].visible; + this.setPointVisiable(false); + super.drawBorder(scale); + this.setPointVisiable(visible); + } // 璁剧疆缂╂斁 public setItemScale(scale: number) { // this.text.scale.set(scale); diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index a53fb3d..4efee1b 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -341,7 +341,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 閫変腑浜嬩欢 */ this.on('select', (axShape:AxShape)=> { - axShape.showBorder(); + axShape.drawBorder(1/this.backgroundImage.scale.x); axShape.setPointVisiable(this.allowEdit); }); /**