调整列车驾驶台元素大小
This commit is contained in:
parent
7f102ad837
commit
42ff85422e
@ -3,6 +3,7 @@ import {
|
||||
ITccHandleData,
|
||||
ITccHandleState,
|
||||
TccHandle,
|
||||
tccHandleHeight,
|
||||
zeroOffset,
|
||||
} from 'src/graphics/tccHandle/TccHandle';
|
||||
import { tccGraphicData } from 'src/protos/tccGraphics';
|
||||
@ -138,15 +139,15 @@ export class TccHandleInteraction extends GraphicInteractionPlugin<TccHandle> {
|
||||
if (
|
||||
this.isMouseDown &&
|
||||
useTccStore().canvasMouseDown &&
|
||||
tccHandle._tccHandle.y > -145 &&
|
||||
tccHandle._tccHandle.y < 145
|
||||
tccHandle._tccHandle.y > -tccHandleHeight - 1 &&
|
||||
tccHandle._tccHandle.y < tccHandleHeight + 1
|
||||
) {
|
||||
tccHandle._tccHandle.y =
|
||||
this.mouseDownTccHandleBeginPos + e.clientY - this.mouseDownBeginPos;
|
||||
if (tccHandle._tccHandle.y >= 145) {
|
||||
tccHandle._tccHandle.y = 144;
|
||||
} else if (tccHandle._tccHandle.y <= -145) {
|
||||
tccHandle._tccHandle.y = -144;
|
||||
if (tccHandle._tccHandle.y >= tccHandleHeight + 1) {
|
||||
tccHandle._tccHandle.y = tccHandleHeight;
|
||||
} else if (tccHandle._tccHandle.y <= -tccHandleHeight - 1) {
|
||||
tccHandle._tccHandle.y = -tccHandleHeight;
|
||||
}
|
||||
let transFormHandleVal = 0;
|
||||
if (
|
||||
@ -160,7 +161,7 @@ export class TccHandleInteraction extends GraphicInteractionPlugin<TccHandle> {
|
||||
transFormHandleVal = tccHandle._tccHandle.y - zeroOffset;
|
||||
}
|
||||
tccHandle._stateVal = Number(
|
||||
(-(transFormHandleVal / (144 - zeroOffset)) * 100).toFixed()
|
||||
(-(transFormHandleVal / (tccHandleHeight - zeroOffset)) * 100).toFixed()
|
||||
);
|
||||
tccHandle.labelGraphic.text = Math.abs(tccHandle._stateVal) + '%';
|
||||
tccHandle.labelGraphic.y = tccHandle._tccHandle.y;
|
||||
|
@ -40,6 +40,7 @@ export class TccButton extends JlGraphic {
|
||||
this._tccButton = new Sprite();
|
||||
this._tccButton.texture = this.tccButtonTextures.redBtn;
|
||||
this._tccButton.anchor.set(0.5);
|
||||
this._tccButton.scale.set(0.7);
|
||||
this.addChild(this._tccButton);
|
||||
}
|
||||
get code(): string {
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
JlGraphic,
|
||||
} from 'jl-graphic';
|
||||
import { ITccButtonData, TccButton, TccButtonTemplate } from './TccButton';
|
||||
import { TccLight } from '../tccLight/TccLight';
|
||||
|
||||
export class TccButtonDraw extends GraphicDrawAssistant<
|
||||
TccButtonTemplate,
|
||||
@ -66,6 +67,7 @@ function buildAbsorbablePositions(tccButton: TccButton): AbsorbablePosition[] {
|
||||
const tccButtons = tccButton.queryStore.queryByType<TccButton>(
|
||||
TccButton.Type
|
||||
);
|
||||
const tccLights = tccButton.queryStore.queryByType<TccLight>(TccLight.Type);
|
||||
const canvas = tccButton.getCanvas();
|
||||
tccButtons.forEach((item) => {
|
||||
if (item.id === tccButton.id) {
|
||||
@ -82,6 +84,18 @@ function buildAbsorbablePositions(tccButton: TccButton): AbsorbablePosition[] {
|
||||
aps.push(ala);
|
||||
aps.push(alb);
|
||||
});
|
||||
tccLights.forEach((item) => {
|
||||
const ala = new AbsorbableLine(
|
||||
new Point(item.x, 0),
|
||||
new Point(item.x, canvas.height)
|
||||
);
|
||||
const alb = new AbsorbableLine(
|
||||
new Point(0, item.y),
|
||||
new Point(canvas.width, item.y)
|
||||
);
|
||||
aps.push(ala);
|
||||
aps.push(alb);
|
||||
});
|
||||
|
||||
return aps;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import Tcc_Handle_JSON from './tcc-handle-data.json';
|
||||
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
|
||||
|
||||
export const zeroOffset = 9;
|
||||
export const tccHandleHeight = 100;
|
||||
interface TccHandleTextures {
|
||||
tccHandle: Texture;
|
||||
handleBackground: Texture;
|
||||
@ -41,10 +42,12 @@ export class TccHandle extends JlGraphic {
|
||||
this._tccHandle = new Sprite();
|
||||
this._tccHandle.texture = this.tccHandleTextures.tccHandle;
|
||||
this._tccHandle.anchor.set(0.5);
|
||||
this._tccHandle.scale.set(0.7);
|
||||
this._tccHandleBackground = new Sprite();
|
||||
this._tccHandleBackground.texture = this.tccHandleTextures.handleBackground;
|
||||
this._tccHandleBackground.anchor.set(0.5);
|
||||
this._tccHandleBackground.position.x = -20;
|
||||
this._tccHandleBackground.scale.set(0.7);
|
||||
this._tccHandleBackground.position.x = -14;
|
||||
this.addChild(this._tccHandleBackground);
|
||||
this.addChild(this._tccHandle);
|
||||
this.setTextGraphic(this.labelGraphic);
|
||||
@ -61,7 +64,7 @@ export class TccHandle extends JlGraphic {
|
||||
}
|
||||
doRepaint(): void {
|
||||
if (!this.canDoRepaint) return;
|
||||
const pos = -(this.state.gear * (144 - zeroOffset)) / 100;
|
||||
const pos = -(this.state.gear * (tccHandleHeight - zeroOffset)) / 100;
|
||||
if (pos > 0) {
|
||||
this._tccHandle.y = pos + zeroOffset;
|
||||
} else if (pos < 0) {
|
||||
|
@ -40,11 +40,12 @@ export class TccKey extends JlGraphic {
|
||||
this.tccKeyTextures = tccKeyTextures;
|
||||
this._tccKey = new Sprite();
|
||||
this._tccKey.texture = this.tccKeyTextures.tccKey;
|
||||
this._tccKey.scale.set(0.125);
|
||||
this._tccKey.scale.set(0.0875);
|
||||
this._tccKey.anchor.set(0.5);
|
||||
this._tccBackground = new Sprite();
|
||||
this._tccBackground.texture = this.tccKeyTextures.tccKeyBackground;
|
||||
this._tccBackground.anchor.set(0.5);
|
||||
this._tccBackground.scale.set(0.7);
|
||||
this.addChild(this._tccBackground);
|
||||
this.addChild(this._tccKey);
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ export interface ItccLightData extends GraphicData {
|
||||
set code(v: string);
|
||||
get lightColor(): tccGraphicData.TccElementColor;
|
||||
set lightColor(v: tccGraphicData.TccElementColor);
|
||||
get activeLevel(): boolean;//有效电平
|
||||
get activeLevel(): boolean; //有效电平
|
||||
set activeLevel(v: boolean);
|
||||
get initialState(): boolean;//初始状态,与有效电平对比,如何想同,刚开始打开驾驶台的时候就是亮着的
|
||||
get initialState(): boolean; //初始状态,与有效电平对比,如何想同,刚开始打开驾驶台的时候就是亮着的
|
||||
set initialState(v: boolean);
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ export class TccLight extends JlGraphic {
|
||||
this.tccLightTextures = tccLightTextures;
|
||||
this._tccLight = new Sprite();
|
||||
this._tccLight.texture = this.tccLightTextures.greenOff;
|
||||
this._tccLight.scale.set(0.25);
|
||||
this._tccLight.scale.set(0.175);
|
||||
this._tccLight.anchor.set(0.5);
|
||||
this.addChild(this._tccLight);
|
||||
}
|
||||
|
@ -267,8 +267,8 @@ function pslHide() {
|
||||
}
|
||||
//列车驾驶台Tcc
|
||||
const tccStore = useTccStore();
|
||||
const tccCanvasWidth = ref(1000);
|
||||
const tccCanvasHeight = ref(630);
|
||||
const tccCanvasWidth = ref(1130);
|
||||
const tccCanvasHeight = ref(450);
|
||||
watch(
|
||||
() => tccStore.isTccDialogOpen,
|
||||
(val: boolean) => {
|
||||
|
Loading…
Reference in New Issue
Block a user