Browse Source

[新增] 设置名称显示状态

develop
徐振升 4 years ago
parent
commit
636970e8be
  1. 16
      doc_workingArea/readme.md
  2. 73
      src/app/working-area/working-area.component.ts

16
doc_workingArea/readme.md

@ -63,13 +63,17 @@ this.workingArea.refresh();
调用该函数后,如果共享数据中的{选择楼层数据}{建筑数据}Version是1.0,则数据会被修改为2.0数据,但并没有修改共享数据中isChange=true(待定) 调用该函数后,如果共享数据中的{选择楼层数据}{建筑数据}Version是1.0,则数据会被修改为2.0数据,但并没有修改共享数据中isChange=true(待定)
### TODO ### 设置名称显示/隐藏
* 创建后新增共享数据 ```tsx
/**
* 移动时修改共享数据 * 设置名称显示
* @param value true 显示 false 隐藏
* @param mode BasicInformation = 0 基本信息 Assignment想定作业 = 1 想定作业
*/
this.workingArea.setNameVisible(true, 0);
this.workingArea.setNameVisible(false, 0);
```
* 删除时删除共享数据
* 调整点位置时修改共享数据

73
src/app/working-area/working-area.component.ts

@ -60,7 +60,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
// console.log('按下了' + event.keyCode); // console.log('按下了' + event.keyCode);
if (event.keyCode === 17) { if (event.keyCode === 17) {
this.selection.isMultiselection = true; this.selection.isMultiselection = true;
this.refresh(); // this.setNameVisible(true, 0);
} }
}); });
this.eventManager.addGlobalEventListener('window', 'keyup', (event: any) => { this.eventManager.addGlobalEventListener('window', 'keyup', (event: any) => {
@ -187,6 +187,22 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
// console.log(this.currentClickPoint.position); // console.log(this.currentClickPoint.position);
}); });
} }
/**
*
* @param value true false
* @param mode BasicInformation = 0 Assignment想定作业 = 1
*/
public setNameVisible(value: boolean, mode: GameMode): void {
this.backgroundImage.children.forEach(item => {
if (item instanceof SinglePointIcon) {
item.setNameVisible(value, mode);
} else if (item instanceof MultipointIcon) {
item.setNameVisible(value, mode);
} else if (item instanceof PolygonIcon) {
item.setNameVisible(value, mode);
}
});
}
/** /**
* *
*/ */
@ -732,7 +748,13 @@ export class SinglePointIcon extends PIXI.Container {
this.addChild(this.text); this.addChild(this.text);
this.addChild(singlePointIcon); this.addChild(singlePointIcon);
} }
// 设置名称
public setNameVisible(value: boolean, mode: GameMode) {
if (this.assetData.GameMode === mode) {
this.text.visible = value;
}
}
} }
/** /**
* 线 * 线
@ -741,6 +763,9 @@ export class MultipointIcon extends PIXI.Container {
public pointsData: PIXI.Point[]; public pointsData: PIXI.Point[];
public pointsGraphics: PIXI.Graphics[] = []; public pointsGraphics: PIXI.Graphics[] = [];
public iconsTilingSprite: PIXI.TilingSprite[] = []; public iconsTilingSprite: PIXI.TilingSprite[] = [];
private text = new PIXI.Text(this.assetData.Name, {
fontFamily: 'Arial', fontSize: 18, fill: 0xffffff, align: 'center'
});
/** /**
* *
* @param texture * @param texture
@ -772,12 +797,12 @@ export class MultipointIcon extends PIXI.Container {
this.addChild(icon); this.addChild(icon);
if (i === 0) { if (i === 0) {
// 名称 // 名称
const text = new PIXI.Text(this.assetData.Name, { // this.text = new PIXI.Text(this.assetData.Name, {
fontFamily: 'Arial', fontSize: 18, fill: 0xffffff, align: 'center' // fontFamily: 'Arial', fontSize: 18, fill: 0xffffff, align: 'center'
}); // });
text.anchor.set(0.5); this.text.anchor.set(0.5);
text.y -= this.assetData.Height; this.text.y -= this.assetData.Height;
icon.addChild(text); icon.addChild(this.text);
} }
} }
// 画点 // 画点
@ -923,6 +948,12 @@ export class MultipointIcon extends PIXI.Container {
item.visible = value; item.visible = value;
}); });
} }
// 设置名称
public setNameVisible(value: boolean, mode: GameMode) {
if (this.assetData.GameMode === mode) {
this.text.visible = value;
}
}
} }
/** /**
* *
@ -932,6 +963,9 @@ export class PolygonIcon extends PIXI.Container {
public pointsGraphics: PIXI.Graphics[] = []; public pointsGraphics: PIXI.Graphics[] = [];
public polygonGraphics: PIXI.Graphics = new PIXI.Graphics(); public polygonGraphics: PIXI.Graphics = new PIXI.Graphics();
public polygonLineGraphics: PIXI.Graphics = new PIXI.Graphics(); public polygonLineGraphics: PIXI.Graphics = new PIXI.Graphics();
private text = new PIXI.Text(this.assetData.Name, {
fontFamily: 'Arial', fontSize: 18, fill: 0xffffff, align: 'center'
});
/** /**
* *
* @param points * @param points
@ -968,12 +1002,12 @@ export class PolygonIcon extends PIXI.Container {
this.polygonLineGraphics.closePath(); this.polygonLineGraphics.closePath();
this.addChild(this.polygonLineGraphics); this.addChild(this.polygonLineGraphics);
// 名称 // 名称
const text = new PIXI.Text(this.assetData.Name, { // const text = new PIXI.Text(this.assetData.Name, {
fontFamily: 'Arial', fontSize: 18, fill: 0xffffff, align: 'center' // fontFamily: 'Arial', fontSize: 18, fill: 0xffffff, align: 'center'
}); // });
text.anchor.set(0.5); this.text.anchor.set(0.5);
text.y -= this.assetData.Height; this.text.y -= this.assetData.Height;
this.polygonLineGraphics.addChild(text); this.polygonLineGraphics.addChild(this.text);
// 添加圆点事件 // 添加圆点事件
this.pointsGraphics.forEach((item, index, array) => { this.pointsGraphics.forEach((item, index, array) => {
item.interactive = true; item.interactive = true;
@ -1078,6 +1112,17 @@ export class PolygonIcon extends PIXI.Container {
}); });
return points; return points;
} }
/**
*
* @param value true/false /
* @param mode BasicInformation = 0
* Assignment想定作业 = 1
*/
public setNameVisible(value: boolean, mode: GameMode) {
if (this.assetData.GameMode === mode) {
this.text.visible = value;
}
}
} }
export class Line extends PIXI.Container { export class Line extends PIXI.Container {

Loading…
Cancel
Save