diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 498f292..dcbaaae 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -4,8 +4,14 @@ import { IscsFan } from 'src/graphics/iscs-fan/IscsFan'; import { IscsFanDraw } from 'src/graphics/iscs-fan/IscsFanDrawAssistant'; import { Link } from 'src/graphics/link/Link'; import { LinkDraw } from 'src/graphics/link/LinkDrawAssistant'; +import { Rect } from 'src/graphics/rect/Rect'; +import { RectDraw } from 'src/graphics/rect/RectDrawAssistant'; import { Platform } from 'src/graphics/platform/Platform'; import { PlatformDraw } from 'src/graphics/platform/PlatformDrawAssistant'; +import { Station } from 'src/graphics/station/Station'; +import { Train } from 'src/graphics/train/Train'; +import { StationDraw } from 'src/graphics/station/StationDrawAssistant'; +import { TrainDraw } from 'src/graphics/train/TrainDrawAssistant'; import { CombinationKey, GraphicApp, @@ -18,7 +24,10 @@ import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; import { IscsFanData } from './graphics/IscsFanInteraction'; import { LinkData } from './graphics/LinkInteraction'; +import { RectData } from './graphics/RectInteraction'; import { PlatformData } from './graphics/PlatformInteraction'; +import { StationData } from './graphics/StationInteraction'; +import { TrainData } from './graphics/TrainInteraction'; import { graphicData } from 'src/protos/stationLayoutGraphics'; export function fromStoragePoint(p: graphicData.Point): Point { @@ -94,12 +103,21 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { new LinkDraw(app, () => { return new LinkData(); }), + new RectDraw(app, () => { + return new RectData(); + }), new IscsFanDraw(app, () => { return new IscsFanData(); }), new PlatformDraw(app, () => { return new PlatformData(); }), + new StationDraw(app, () => { + return new StationData(); + }), + new TrainDraw(app, () => { + return new TrainData(); + }), ], }); @@ -129,6 +147,14 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { }, }) ); + app.addKeyboardListener( + new KeyListener({ + value: 'KeyR', + onPress: () => { + app.interactionPlugin(Rect.Type).resume(); + }, + }) + ); app.addKeyboardListener( new KeyListener({ value: 'KeyF', @@ -145,6 +171,22 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { }, }) ); + app.addKeyboardListener( + new KeyListener({ + value: 'KeyO', + onPress: () => { + app.interactionPlugin(Station.Type).resume(); + }, + }) + ); + app.addKeyboardListener( + new KeyListener({ + value: 'KeyT', + onPress: () => { + app.interactionPlugin(Train.Type).resume(); + }, + }) + ); app.addKeyboardListener( new KeyListener({ value: '1', @@ -183,12 +225,21 @@ export function saveDrawDatas(app: JlDrawApp) { if (Link.Type === g.type) { const linkData = (g as Link).saveData(); storage.links.push((linkData as LinkData).data); + } else if (Rect.Type === g.type) { + const rectData = (g as Rect).saveData(); + storage.Rects.push((rectData as RectData).data); } else if (IscsFan.Type === g.type) { const IscsFanData = (g as IscsFan).saveData(); storage.iscsFans.push((IscsFanData as IscsFanData).data); } else if (Platform.Type === g.type) { const platformData = (g as Platform).saveData(); storage.Platforms.push((platformData as PlatformData).data); + } else if (Station.Type === g.type) { + const stationData = (g as Station).saveData(); + storage.stations.push((stationData as StationData).data); + } else if (Train.Type === g.type) { + const trainData = (g as Train).saveData(); + storage.train.push((trainData as TrainData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -210,12 +261,21 @@ export function loadDrawDatas(app: GraphicApp) { storage.links.forEach((link) => { datas.push(new LinkData(link)); }); + storage.Rects.forEach((rect) => { + datas.push(new RectData(rect)); + }); storage.iscsFans.forEach((fan) => { datas.push(new IscsFanData(fan)); }); storage.Platforms.forEach((platform) => { datas.push(new PlatformData(platform)); }); + storage.stations.forEach((station) => { + datas.push(new StationData(station)); + }); + storage.train.forEach((train) => { + datas.push(new TrainData(train)); + }); app.loadGraphic(datas); } else { app.loadGraphic([]);