From 849c7ffb6233664e3ccda6331b5395086ada4818 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 12 Jan 2024 16:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/PlatformDrawAssistant.d.ts | 6 ++-- .../Platform/common/PlatformTemplate.d.ts | 8 ++---- .../Platform/common/PlatformTemplate.js | 16 +++++------ .../Station/common/StationDrawAssistant.d.ts | 6 ++-- .../Station/common/StationTemplate.d.ts | 8 ++---- .../Station/common/StationTemplate.js | 16 +++++------ src/packages/Platform/common/JlPlatform.ts | 1 - .../Platform/common/PlatformDrawAssistant.ts | 11 +++----- .../Platform/common/PlatformTemplate.ts | 28 ++++++++++--------- .../Station/common/StationDrawAssistant.ts | 11 +++----- .../Station/common/StationTemplate.ts | 28 ++++++++++--------- 11 files changed, 66 insertions(+), 73 deletions(-) diff --git a/components/packages/Platform/common/PlatformDrawAssistant.d.ts b/components/packages/Platform/common/PlatformDrawAssistant.d.ts index 837a1c8..1171d7e 100644 --- a/components/packages/Platform/common/PlatformDrawAssistant.d.ts +++ b/components/packages/Platform/common/PlatformDrawAssistant.d.ts @@ -1,11 +1,11 @@ import { FederatedPointerEvent, Point } from 'pixi.js'; -import { GraphicDrawAssistant, IDrawApp } from 'jl-graphic'; +import { GraphicDrawAssistant, GraphicState, IDrawApp } from 'jl-graphic'; import { JlPlatform } from './JlPlatform'; import { PlatformTemplate } from './PlatformTemplate'; import { IPlatformData } from './PlatformConfig'; -export declare class PlatformDraw extends GraphicDrawAssistant { +export declare class PlatformDraw extends GraphicDrawAssistant, IPlatformData> { platformGraphic: JlPlatform; - constructor(app: IDrawApp, template: PlatformTemplate, icon: string); + constructor(app: IDrawApp, template: PlatformTemplate, icon: string); bind(): void; onLeftDown(e: FederatedPointerEvent): void; redraw(p: Point): void; diff --git a/components/packages/Platform/common/PlatformTemplate.d.ts b/components/packages/Platform/common/PlatformTemplate.d.ts index a083894..49e367a 100644 --- a/components/packages/Platform/common/PlatformTemplate.d.ts +++ b/components/packages/Platform/common/PlatformTemplate.d.ts @@ -1,13 +1,11 @@ -import { JlGraphicTemplate } from 'jl-graphic'; +import { GraphicState, JlGraphicTemplate } from 'jl-graphic'; import { JlPlatform } from './JlPlatform'; import { IPlatformData } from './PlatformConfig'; -import { ITHPlatformState } from '../THPlatform'; -import { IGPPlatformState } from '../GPPlatform'; import { StyleType } from 'common/common'; -export declare class PlatformTemplate extends JlGraphicTemplate { +export declare class PlatformTemplate extends JlGraphicTemplate { hasdoor?: boolean; direction?: string; styleType: StyleType; - constructor(dataTemplate: IPlatformData, stateTemplate: ITHPlatformState | IGPPlatformState, styleType: StyleType); + constructor(dataTemplate: IPlatformData, stateTemplate: S, styleType: StyleType); new(): JlPlatform; } diff --git a/components/packages/Platform/common/PlatformTemplate.js b/components/packages/Platform/common/PlatformTemplate.js index 67e8f66..df6697e 100644 --- a/components/packages/Platform/common/PlatformTemplate.js +++ b/components/packages/Platform/common/PlatformTemplate.js @@ -19,18 +19,18 @@ class PlatformTemplate extends JlGraphicTemplate { } } new() { + let platform; switch (this.styleType) { case StyleType.GP: - const GP = new GPPlatform(); - GP.loadData(this.datas); - GP.loadState(this.states); - return GP; + platform = new GPPlatform(); + break; default: - const TH = new THPlatform(); - TH.loadData(this.datas); - TH.loadState(this.states); - return TH; + platform = new THPlatform(); + break; } + platform.loadData(this.datas); + platform.loadState(this.states); + return platform; } } diff --git a/components/packages/Station/common/StationDrawAssistant.d.ts b/components/packages/Station/common/StationDrawAssistant.d.ts index 72fcdb1..68fda72 100644 --- a/components/packages/Station/common/StationDrawAssistant.d.ts +++ b/components/packages/Station/common/StationDrawAssistant.d.ts @@ -1,11 +1,11 @@ import { FederatedPointerEvent, Point } from 'pixi.js'; -import { GraphicDrawAssistant, GraphicInteractionPlugin, IDrawApp, JlGraphic } from 'jl-graphic'; +import { GraphicDrawAssistant, GraphicInteractionPlugin, GraphicState, IDrawApp, JlGraphic } from 'jl-graphic'; import { JlStation } from './JlStation'; import { IStationData } from './StationConfig'; import { StationTemplate } from './StationTemplate'; -export declare class StationDraw extends GraphicDrawAssistant { +export declare class StationDraw extends GraphicDrawAssistant, IStationData> { codeGraph: JlStation; - constructor(app: IDrawApp, template: StationTemplate, icon: string); + constructor(app: IDrawApp, template: StationTemplate, icon: string); bind(): void; onLeftDown(e: FederatedPointerEvent): void; redraw(p: Point): void; diff --git a/components/packages/Station/common/StationTemplate.d.ts b/components/packages/Station/common/StationTemplate.d.ts index 5594f8a..cc6abd0 100644 --- a/components/packages/Station/common/StationTemplate.d.ts +++ b/components/packages/Station/common/StationTemplate.d.ts @@ -1,12 +1,10 @@ -import { JlGraphicTemplate } from 'jl-graphic'; +import { GraphicState, JlGraphicTemplate } from 'jl-graphic'; import { JlStation } from './JlStation'; import { IStationData } from './StationConfig'; -import { ITHStationState } from '../THStation'; -import { IGPStationState } from '../GPStation'; import { StyleType } from 'common/common'; -export declare class StationTemplate extends JlGraphicTemplate { +export declare class StationTemplate extends JlGraphicTemplate { hasControl?: boolean; styleType: StyleType; - constructor(dataTemplate: IStationData, stateTemplate: ITHStationState | IGPStationState, styleType: StyleType); + constructor(dataTemplate: IStationData, stateTemplate: S, styleType: StyleType); new(): JlStation; } diff --git a/components/packages/Station/common/StationTemplate.js b/components/packages/Station/common/StationTemplate.js index 3077126..a5c4127 100644 --- a/components/packages/Station/common/StationTemplate.js +++ b/components/packages/Station/common/StationTemplate.js @@ -20,18 +20,18 @@ class StationTemplate extends JlGraphicTemplate { } } new() { + let station; switch (this.styleType) { case StyleType.GP: - const GP = new GPStation(); - GP.loadData(this.datas); - GP.loadState(this.states); - return GP; + station = new GPStation(); + break; default: - const TH = new THStation(); - TH.loadData(this.datas); - TH.loadState(this.states); - return TH; + station = new THStation(); + break; } + station.loadData(this.datas); + station.loadState(this.states); + return station; } } diff --git a/src/packages/Platform/common/JlPlatform.ts b/src/packages/Platform/common/JlPlatform.ts index 3366745..6d9b227 100644 --- a/src/packages/Platform/common/JlPlatform.ts +++ b/src/packages/Platform/common/JlPlatform.ts @@ -11,7 +11,6 @@ import { Rectangle, Color, Point, - IPointData, } from 'pixi.js'; import { CodeConstsConfig, diff --git a/src/packages/Platform/common/PlatformDrawAssistant.ts b/src/packages/Platform/common/PlatformDrawAssistant.ts index b7618c5..423de35 100644 --- a/src/packages/Platform/common/PlatformDrawAssistant.ts +++ b/src/packages/Platform/common/PlatformDrawAssistant.ts @@ -4,6 +4,7 @@ import { AbsorbablePosition, GraphicDrawAssistant, GraphicInteractionPlugin, + GraphicState, IDrawApp, JlGraphic, } from 'jl-graphic'; @@ -13,33 +14,29 @@ import { PlatformTemplate } from './PlatformTemplate'; import { StyleType } from 'common/common'; import { IPlatformData } from './PlatformConfig'; -export class PlatformDraw extends GraphicDrawAssistant< - PlatformTemplate, +export class PlatformDraw extends GraphicDrawAssistant< + PlatformTemplate, IPlatformData > { platformGraphic: JlPlatform; - constructor(app: IDrawApp, template: PlatformTemplate, icon: string) { + constructor(app: IDrawApp, template: PlatformTemplate, icon: string) { super(app, template, icon, '站台Platform'); this.platformGraphic = this.graphicTemplate.new(); this.container.addChild(this.platformGraphic); PlatformInteraction.init(app); } - bind(): void { super.bind(); this.platformGraphic.loadData(this.graphicTemplate.datas); this.platformGraphic.doRepaint(); } - onLeftDown(e: FederatedPointerEvent): void { this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); this.createAndStore(true); } - redraw(p: Point): void { this.container.position.copyFrom(p); } - prepareData(data: IPlatformData): boolean { const template = this.graphicTemplate; switch (template.styleType) { diff --git a/src/packages/Platform/common/PlatformTemplate.ts b/src/packages/Platform/common/PlatformTemplate.ts index bc1e96a..1dc1c30 100644 --- a/src/packages/Platform/common/PlatformTemplate.ts +++ b/src/packages/Platform/common/PlatformTemplate.ts @@ -1,17 +1,19 @@ -import { JlGraphicTemplate } from 'jl-graphic'; +import { GraphicState, JlGraphicTemplate } from 'jl-graphic'; import { JlPlatform } from './JlPlatform'; import { IPlatformData } from './PlatformConfig'; -import { ITHPlatformState, THPlatform } from '../THPlatform'; -import { GPPlatform, IGPPlatformState } from '../GPPlatform'; +import { THPlatform } from '../THPlatform'; +import { GPPlatform } from '../GPPlatform'; import { StyleType } from 'common/common'; -export class PlatformTemplate extends JlGraphicTemplate { +export class PlatformTemplate< + S extends GraphicState, +> extends JlGraphicTemplate { hasdoor?: boolean; direction?: string; styleType: StyleType; constructor( dataTemplate: IPlatformData, - stateTemplate: ITHPlatformState | IGPPlatformState, + stateTemplate: S, styleType: StyleType, ) { super(JlPlatform.Type, { dataTemplate, stateTemplate }); @@ -24,17 +26,17 @@ export class PlatformTemplate extends JlGraphicTemplate { } } new(): JlPlatform { + let platform: JlPlatform; switch (this.styleType) { case StyleType.GP: - const GP = new GPPlatform(); - GP.loadData(this.datas); - GP.loadState(this.states); - return GP; + platform = new GPPlatform(); + break; default: - const TH = new THPlatform(); - TH.loadData(this.datas); - TH.loadState(this.states); - return TH; + platform = new THPlatform(); + break; } + platform.loadData(this.datas); + platform.loadState(this.states); + return platform; } } diff --git a/src/packages/Station/common/StationDrawAssistant.ts b/src/packages/Station/common/StationDrawAssistant.ts index 68bd697..17b186c 100644 --- a/src/packages/Station/common/StationDrawAssistant.ts +++ b/src/packages/Station/common/StationDrawAssistant.ts @@ -4,6 +4,7 @@ import { AbsorbablePosition, GraphicDrawAssistant, GraphicInteractionPlugin, + GraphicState, IDrawApp, JlGraphic, } from 'jl-graphic'; @@ -12,33 +13,29 @@ import { IStationData } from './StationConfig'; import { StationTemplate } from './StationTemplate'; import { StyleType } from 'common/common'; -export class StationDraw extends GraphicDrawAssistant< - StationTemplate, +export class StationDraw extends GraphicDrawAssistant< + StationTemplate, IStationData > { codeGraph: JlStation; - constructor(app: IDrawApp, template: StationTemplate, icon: string) { + constructor(app: IDrawApp, template: StationTemplate, icon: string) { super(app, template, icon, '车站Station'); this.codeGraph = this.graphicTemplate.new(); this.container.addChild(this.codeGraph); StationInteraction.init(app); } - bind(): void { super.bind(); this.codeGraph.loadData(this.graphicTemplate.datas); this.codeGraph.doRepaint(); } - onLeftDown(e: FederatedPointerEvent): void { this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); this.createAndStore(true); } - redraw(p: Point): void { this.container.position.copyFrom(p); } - prepareData(data: IStationData): boolean { const template = this.graphicTemplate; switch (template.styleType) { diff --git a/src/packages/Station/common/StationTemplate.ts b/src/packages/Station/common/StationTemplate.ts index 56f0e9c..57819d8 100644 --- a/src/packages/Station/common/StationTemplate.ts +++ b/src/packages/Station/common/StationTemplate.ts @@ -1,16 +1,18 @@ -import { JlGraphicTemplate } from 'jl-graphic'; +import { GraphicState, JlGraphicTemplate } from 'jl-graphic'; import { JlStation } from './JlStation'; import { IStationData } from './StationConfig'; -import { THStation, ITHStationState } from '../THStation'; -import { GPStation, IGPStationState } from '../GPStation'; +import { THStation } from '../THStation'; +import { GPStation } from '../GPStation'; import { StyleType } from 'common/common'; -export class StationTemplate extends JlGraphicTemplate { +export class StationTemplate< + S extends GraphicState, +> extends JlGraphicTemplate { hasControl?: boolean; styleType: StyleType; constructor( dataTemplate: IStationData, - stateTemplate: ITHStationState | IGPStationState, + stateTemplate: S, styleType: StyleType, ) { super(JlStation.Type, { @@ -25,17 +27,17 @@ export class StationTemplate extends JlGraphicTemplate { } } new(): JlStation { + let station: JlStation; switch (this.styleType) { case StyleType.GP: - const GP = new GPStation(); - GP.loadData(this.datas); - GP.loadState(this.states); - return GP; + station = new GPStation(); + break; default: - const TH = new THStation(); - TH.loadData(this.datas); - TH.loadState(this.states); - return TH; + station = new THStation(); + break; } + station.loadData(this.datas); + station.loadState(this.states); + return station; } }