This commit is contained in:
joylink_zhaoerwei 2024-01-12 16:43:07 +08:00
parent ed9be45c6a
commit 849c7ffb62
11 changed files with 66 additions and 73 deletions

View File

@ -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<PlatformTemplate, IPlatformData> {
export declare class PlatformDraw<S extends GraphicState> extends GraphicDrawAssistant<PlatformTemplate<S>, IPlatformData> {
platformGraphic: JlPlatform;
constructor(app: IDrawApp, template: PlatformTemplate, icon: string);
constructor(app: IDrawApp, template: PlatformTemplate<S>, icon: string);
bind(): void;
onLeftDown(e: FederatedPointerEvent): void;
redraw(p: Point): void;

View File

@ -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<JlPlatform> {
export declare class PlatformTemplate<S extends GraphicState> extends JlGraphicTemplate<JlPlatform> {
hasdoor?: boolean;
direction?: string;
styleType: StyleType;
constructor(dataTemplate: IPlatformData, stateTemplate: ITHPlatformState | IGPPlatformState, styleType: StyleType);
constructor(dataTemplate: IPlatformData, stateTemplate: S, styleType: StyleType);
new(): JlPlatform;
}

View File

@ -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;
}
}

View File

@ -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<StationTemplate, IStationData> {
export declare class StationDraw<S extends GraphicState> extends GraphicDrawAssistant<StationTemplate<S>, IStationData> {
codeGraph: JlStation;
constructor(app: IDrawApp, template: StationTemplate, icon: string);
constructor(app: IDrawApp, template: StationTemplate<S>, icon: string);
bind(): void;
onLeftDown(e: FederatedPointerEvent): void;
redraw(p: Point): void;

View File

@ -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<JlStation> {
export declare class StationTemplate<S extends GraphicState> extends JlGraphicTemplate<JlStation> {
hasControl?: boolean;
styleType: StyleType;
constructor(dataTemplate: IStationData, stateTemplate: ITHStationState | IGPStationState, styleType: StyleType);
constructor(dataTemplate: IStationData, stateTemplate: S, styleType: StyleType);
new(): JlStation;
}

View File

@ -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;
}
}

View File

@ -11,7 +11,6 @@ import {
Rectangle,
Color,
Point,
IPointData,
} from 'pixi.js';
import {
CodeConstsConfig,

View File

@ -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<S extends GraphicState> extends GraphicDrawAssistant<
PlatformTemplate<S>,
IPlatformData
> {
platformGraphic: JlPlatform;
constructor(app: IDrawApp, template: PlatformTemplate, icon: string) {
constructor(app: IDrawApp, template: PlatformTemplate<S>, 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) {

View File

@ -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<JlPlatform> {
export class PlatformTemplate<
S extends GraphicState,
> extends JlGraphicTemplate<JlPlatform> {
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<JlPlatform> {
}
}
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;
}
}

View File

@ -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<S extends GraphicState> extends GraphicDrawAssistant<
StationTemplate<S>,
IStationData
> {
codeGraph: JlStation;
constructor(app: IDrawApp, template: StationTemplate, icon: string) {
constructor(app: IDrawApp, template: StationTemplate<S>, 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) {

View File

@ -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<JlStation> {
export class StationTemplate<
S extends GraphicState,
> extends JlGraphicTemplate<JlStation> {
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<JlStation> {
}
}
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;
}
}