From e39774e4bcb9a775ef42ddb2cbeecb9313786560 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Thu, 29 Aug 2024 17:27:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A9=BE=E9=A9=B6=E5=8F=B0=E6=89=8B=E6=9F=840?= =?UTF-8?q?=E4=BD=8D=E8=8C=83=E5=9B=B4=E6=89=A9=E5=A4=A7=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=E5=86=85=E8=87=AA=E5=8A=A8=E5=90=B8=E9=99=84?= =?UTF-8?q?=E5=88=B00=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/tccHandle/TccHandle.ts | 10 +++++++++- src/stores/tcc-store.ts | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/graphics/tccHandle/TccHandle.ts b/src/graphics/tccHandle/TccHandle.ts index 9a9ee93..03330fd 100644 --- a/src/graphics/tccHandle/TccHandle.ts +++ b/src/graphics/tccHandle/TccHandle.ts @@ -9,6 +9,7 @@ import Tcc_Handle_JSON from './tcc-handle-data.json'; import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js'; +export const zeroOffset = 9; interface TccHandleTextures { tccHandle: Texture; handleBackground: Texture; @@ -54,7 +55,14 @@ export class TccHandle extends JlGraphic { return this.getStates(); } doRepaint(): void { - this._tccHandle.y = -(this.state.gear * 144) / 100; + const pos = -(this.state.gear * (144 - zeroOffset)) / 100; + if (pos > 0) { + this._tccHandle.y = pos + zeroOffset; + } else if (pos < 0) { + this._tccHandle.y = pos - zeroOffset; + } else { + this._tccHandle.y = 0; + } this._tccHandle.texture = this.tccHandleTextures.tccHandle; } } diff --git a/src/stores/tcc-store.ts b/src/stores/tcc-store.ts index 9bbbab9..3b85023 100644 --- a/src/stores/tcc-store.ts +++ b/src/stores/tcc-store.ts @@ -5,7 +5,7 @@ import { useLineStore } from './line-store'; import { tccOperation } from 'src/api/Simulation'; import { errorNotify } from 'src/utils/CommonNotify'; import { request } from 'src/protos/request'; -import { TccHandle } from 'src/graphics/tccHandle/TccHandle'; +import { TccHandle, zeroOffset } from 'src/graphics/tccHandle/TccHandle'; import { TccKey } from 'src/graphics/tccKey/TccKey'; import { IGraphicApp } from 'jl-graphic'; @@ -47,8 +47,19 @@ export const useTccStore = defineStore('tcc', { .getScene(`tcc${this.tccId}`) .queryStore.queryById(this.tccHandleId); if (!simulationId) return; + let transFormHandleVal = 0; + if ( + tccHandle._tccHandle.y >= -zeroOffset && + tccHandle._tccHandle.y <= zeroOffset + ) { + tccHandle._tccHandle.y = 0; + } else if (tccHandle._tccHandle.y < -zeroOffset) { + transFormHandleVal = tccHandle._tccHandle.y + zeroOffset; + } else { + transFormHandleVal = tccHandle._tccHandle.y - zeroOffset; + } const handleVal = Number( - (-(tccHandle._tccHandle.y / 144) * 100).toFixed() + (-(transFormHandleVal / (144 - zeroOffset)) * 100).toFixed() ); tccOperation({ simulationId,