ibp盘入口调整

This commit is contained in:
Yuan 2023-11-06 17:07:07 +08:00
parent 5e08c9250b
commit f39f2f41f7
3 changed files with 28 additions and 34 deletions

View File

@ -17,6 +17,9 @@ import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
import { graphicData } from 'src/protos/stationLayoutGraphics';
import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase';
import { state } from 'src/protos/device_state';
import { useIbpStore } from 'src/stores/ibp-store';
import { Station } from 'src/graphics/station/Station';
import { Platform } from 'src/graphics/platform/Platform';
export class SpksSwitchData extends GraphicDataBase implements ISpksSwitchData {
constructor(data?: graphicData.SpksSwitch) {
@ -205,6 +208,17 @@ export class SpksSwitchOperationInteraction extends GraphicInteractionPlugin<Spk
onLeftClick(e: FederatedMouseEvent) {
const target = e.target as DisplayObject;
const spksSwitch = target.getGraphic() as SpksSwitch;
this.app.updateSelected(spksSwitch);
const stand = this.app.queryStore.queryById<Platform>(
spksSwitch.datas.refStand
);
const station = this.app.queryStore.queryById<Station>(
stand.datas.refStation
);
useIbpStore().setIbpParam(
station.datas.code,
station.datas.refIbpMapCode,
station.datas.id
);
}
}

View File

@ -139,23 +139,10 @@ export class StationState extends GraphicStateBase implements IStationState {
}
}
const openIbpMenuItem: MenuItemOptions = {
name: '打开IBP',
};
const StationOperateMenu: ContextMenu = ContextMenu.init({
name: '车站操作菜单',
groups: [
{
items: [openIbpMenuItem],
},
],
});
export class StationOperateInteraction extends GraphicInteractionPlugin<Station> {
static Name = 'station_operate_menu';
constructor(app: IGraphicScene) {
super(StationOperateInteraction.Name, app);
app.registerMenu(StationOperateMenu);
}
static init(app: IGraphicScene) {
return new StationOperateInteraction(app);
@ -169,31 +156,15 @@ export class StationOperateInteraction extends GraphicInteractionPlugin<Station>
g.eventMode = 'static';
g.cursor = 'pointer';
g.selectable = true;
g.on('_rightclick', this.onContextMenu, this);
g.on('_leftclick', this.onLeftClick, this);
}
unbind(g: Station): void {
g.selectable = false;
g.eventMode = 'none';
g.off('_rightclick', this.onContextMenu, this);
g.off('_leftclick', this.onLeftClick, this);
}
onLeftClick() {
useLineStore().stateProCountIncrease();
}
onContextMenu(e: FederatedMouseEvent) {
const target = e.target as DisplayObject;
const station = target.getGraphic() as Station;
this.app.updateSelected(station);
openIbpMenuItem.handler = () => {
useIbpStore().setIbpParam(
station.datas.code,
station.datas.refIbpMapCode,
station.datas.id
);
};
StationOperateMenu.open(e.global);
}
}

View File

@ -39,6 +39,7 @@ const esbButtonConsts = {
bodyCircleRadius: 5,
bodyCircleColor: 0xffffff,
bodyColor: 0x000000,
pressedColor: 0xff0000,
};
export class EsbButton extends JlGraphic {
static Type = 'esbButton';
@ -71,14 +72,21 @@ export class EsbButton extends JlGraphic {
codeGraph.anchor.set(0.5);
codeGraph.position.set(-30, 0);
this.circleBody.clear();
this.circleBody.beginFill(esbButtonConsts.bodyCircleColor, 1);
this.circleBody.beginFill(
this.state.down
? esbButtonConsts.pressedColor
: esbButtonConsts.bodyCircleColor,
1
);
this.circleBody.drawCircle(0, 0, esbButtonConsts.bodyCircleRadius);
this.circleBody.endFill();
this.rectBody.clear();
this.rectBody.beginFill(esbButtonConsts.bodyColor, 0);
this.rectBody.lineStyle(
esbButtonConsts.bodyRectLineWidth,
esbButtonConsts.bodyRectLineColor
this.state.down
? esbButtonConsts.pressedColor
: esbButtonConsts.bodyRectLineColor
);
this.rectBody.drawRect(
-esbButtonConsts.bodyRectWidth / 2,
@ -93,11 +101,12 @@ export class EsbButton extends JlGraphic {
: -esbButtonConsts.bodyRectHeight / 2;
this.lineBody.lineStyle(
esbButtonConsts.bodyLineWidth,
esbButtonConsts.bodyLineColor
this.state.down
? esbButtonConsts.pressedColor
: esbButtonConsts.bodyLineColor
);
this.lineBody.moveTo(-esbButtonConsts.bodyRectWidth / 2, lineY);
this.lineBody.lineTo(esbButtonConsts.bodyRectWidth / 2, lineY);
this.alpha = this.state.down ? 0.5 : 1;
}
}