pslButton状态调整
This commit is contained in:
parent
0451397be2
commit
9e0f9296ae
@ -63,7 +63,6 @@ export class PslButtonData extends GraphicDataBase implements IPslButtonData {
|
|||||||
return pb_1.Message.equals(this.data, other.data);
|
return pb_1.Message.equals(this.data, other.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//GraphicStateBase
|
|
||||||
export class PslButtonState
|
export class PslButtonState
|
||||||
extends GraphicStateBase
|
extends GraphicStateBase
|
||||||
implements IPslButtonState
|
implements IPslButtonState
|
||||||
@ -127,7 +126,6 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
|
|||||||
// g.off('mousedown', this.onMouseDown, this);
|
// g.off('mousedown', this.onMouseDown, this);
|
||||||
g.on('mouseup', this.onMouseUp, this);
|
g.on('mouseup', this.onMouseUp, this);
|
||||||
}
|
}
|
||||||
//FederatedMouseEvent
|
|
||||||
// onMouseDown(e: FederatedMouseEvent) {
|
// onMouseDown(e: FederatedMouseEvent) {
|
||||||
// const simulationId = useLineStore().simulationId;
|
// const simulationId = useLineStore().simulationId;
|
||||||
// const mapId = useLineStore().mapId;
|
// const mapId = useLineStore().mapId;
|
||||||
|
@ -23,7 +23,7 @@ import { PslLightDraw } from 'src/graphics/pslLight/pslLightDrawAssistant';
|
|||||||
import { PslKey, PslKeyTemplate } from 'src/graphics/pslKey/pslKey';
|
import { PslKey, PslKeyTemplate } from 'src/graphics/pslKey/pslKey';
|
||||||
import { PslKeyData } from './graphics/PslKeyInteraction';
|
import { PslKeyData } from './graphics/PslKeyInteraction';
|
||||||
import { PslButton, PslButtonTemplate } from 'src/graphics/pslButton/pslButton';
|
import { PslButton, PslButtonTemplate } from 'src/graphics/pslButton/pslButton';
|
||||||
import { PslButtonData } from './graphics/PslButtonInteraction';
|
import { PslButtonData, PslButtonState } from './graphics/PslButtonInteraction';
|
||||||
import { PslLight, PslLightTemplate } from 'src/graphics/pslLight/pslLight';
|
import { PslLight, PslLightTemplate } from 'src/graphics/pslLight/pslLight';
|
||||||
import { PslLightData } from './graphics/PslLightInteraction';
|
import { PslLightData } from './graphics/PslLightInteraction';
|
||||||
import {
|
import {
|
||||||
@ -75,7 +75,10 @@ export function initPslDrawApp(): IDrawApp {
|
|||||||
const app = drawApp;
|
const app = drawApp;
|
||||||
//根据草稿图类型加载绘图工具
|
//根据草稿图类型加载绘图工具
|
||||||
new PslKeyDraw(app, new PslKeyTemplate(new PslKeyData()));
|
new PslKeyDraw(app, new PslKeyTemplate(new PslKeyData()));
|
||||||
new PslButtonDraw(app, new PslButtonTemplate(new PslButtonData()));
|
new PslButtonDraw(
|
||||||
|
app,
|
||||||
|
new PslButtonTemplate(new PslButtonData(), new PslButtonState())
|
||||||
|
);
|
||||||
new PslLightDraw(app, new PslLightTemplate(new PslLightData()));
|
new PslLightDraw(app, new PslLightTemplate(new PslLightData()));
|
||||||
new TextContentDraw(app, new TextContentTemplate(new PslTextData()));
|
new TextContentDraw(app, new TextContentTemplate(new PslTextData()));
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ export function initPslScene(lineApp: IGraphicApp, sceneName: string) {
|
|||||||
});
|
});
|
||||||
const graphicTemplate = [
|
const graphicTemplate = [
|
||||||
new PslKeyTemplate(new PslKeyData()),
|
new PslKeyTemplate(new PslKeyData()),
|
||||||
new PslButtonTemplate(new PslButtonData()),
|
new PslButtonTemplate(new PslButtonData(), new PslButtonState()),
|
||||||
new PslLightTemplate(new PslLightData()),
|
new PslLightTemplate(new PslLightData()),
|
||||||
new TextContentTemplate(new PslTextData()),
|
new TextContentTemplate(new PslTextData()),
|
||||||
];
|
];
|
||||||
@ -67,15 +67,14 @@ function handleSubscribe(pslScene: IGraphicScene) {
|
|||||||
messageConverter: (message: Uint8Array) => {
|
messageConverter: (message: Uint8Array) => {
|
||||||
// console.log('收到消息', message);
|
// console.log('收到消息', message);
|
||||||
const states: GraphicState[] = [];
|
const states: GraphicState[] = [];
|
||||||
// const storage = state.PushedDevicesStatus.deserialize(message);
|
const storage = state.PushedDevicesStatus.deserialize(message);
|
||||||
// if (storage.all) {
|
if (storage.all) {
|
||||||
// storage.allStatus.buttonState.forEach((item) => {
|
// storage.allStatus.buttonState.forEach((item) => {
|
||||||
// // 道岔
|
// if (item.id) {
|
||||||
// if (item.id) {
|
// states.push(new PslButtonState(item));
|
||||||
// states.push(new PslButtonState(item));
|
// }
|
||||||
// }
|
// });
|
||||||
// });
|
}
|
||||||
// }
|
|
||||||
// console.log(states, 'states');
|
// console.log(states, 'states');
|
||||||
return states;
|
return states;
|
||||||
},
|
},
|
||||||
|
@ -50,27 +50,38 @@ export class PslButton extends JlGraphic {
|
|||||||
get datas(): IPslButtonData {
|
get datas(): IPslButtonData {
|
||||||
return this.getDatas<IPslButtonData>();
|
return this.getDatas<IPslButtonData>();
|
||||||
}
|
}
|
||||||
|
get states(): IPslButtonState {
|
||||||
|
return this.getStates<IPslButtonState>();
|
||||||
|
}
|
||||||
doRepaint(): void {
|
doRepaint(): void {
|
||||||
this._pslButton.rotation = 0;
|
this._pslButton.rotation = 0;
|
||||||
if (this.datas.buttonColor === pslGraphicData.PslElementColor.green) {
|
if (this.datas.buttonColor === pslGraphicData.PslElementColor.green) {
|
||||||
this._pslButton.texture = this.pslButtonTextures.greenBtn;
|
if (this.states.down) {
|
||||||
|
this._pslButton.texture = this.pslButtonTextures.greenBtnPress;
|
||||||
|
} else {
|
||||||
|
this._pslButton.texture = this.pslButtonTextures.greenBtn;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this._pslButton.texture = this.pslButtonTextures.redBtn;
|
if (this.states.down) {
|
||||||
|
this._pslButton.texture = this.pslButtonTextures.redBtnPress;
|
||||||
|
} else {
|
||||||
|
this._pslButton.texture = this.pslButtonTextures.redBtn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PslButtonTemplate extends JlGraphicTemplate<PslButton> {
|
export class PslButtonTemplate extends JlGraphicTemplate<PslButton> {
|
||||||
pslButtonTextures?: PslButtonTextures;
|
pslButtonTextures?: PslButtonTextures;
|
||||||
constructor(dataTemplate: IPslButtonData) {
|
constructor(dataTemplate: IPslButtonData, stateTemplate: IPslButtonState) {
|
||||||
super(PslButton.Type, { dataTemplate });
|
super(PslButton.Type, { dataTemplate, stateTemplate });
|
||||||
this.loadAssets();
|
this.loadAssets();
|
||||||
}
|
}
|
||||||
new(): PslButton {
|
new(): PslButton {
|
||||||
if (this.pslButtonTextures) {
|
if (this.pslButtonTextures) {
|
||||||
const g = new PslButton(this.pslButtonTextures);
|
const g = new PslButton(this.pslButtonTextures);
|
||||||
g.loadData(this.datas);
|
g.loadData(this.datas);
|
||||||
// g.loadState(this.states);
|
g.loadState(this.states);
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
throw new Error('资源未加载/加载失败');
|
throw new Error('资源未加载/加载失败');
|
||||||
|
Loading…
Reference in New Issue
Block a user