| | |
| | | import * as Tool from './tool'; |
| | | import { NotificationProvider, useNotification } from './Notification'; |
| | | import Device from "./Device"; |
| | | import * as Http from './http'; |
| | | |
| | | let player; |
| | | |
| | |
| | | setMapContainer(player.mapContainer); |
| | | Tool.setApp(player.app); |
| | | Tool.setMapContainer(player.mapContainer); |
| | | Http.setNotify(notify); |
| | | |
| | | await Http.fetchMapData(0); |
| | | |
| | | } |
| | | initialize(); |
| | |
| | | const height = contentRef.current.offsetHeight; |
| | | |
| | | player.resize(width, height); |
| | | if (mode === MapMode.MOVABLE_MODE) { |
| | | console.log('aa'); |
| | | player.showGridLines(); |
| | | } |
| | | }; |
| | | handleResize(); |
| | | window.addEventListener('resize', handleResize); |
| | |
| | | switch (mode) { |
| | | case MapMode.OBSERVER_MODE: |
| | | setDeviceVisible(false); |
| | | player.hideGridLines(); |
| | | |
| | | player.activateMapMultiSelect((selectedSprites, restartFn) => { |
| | | console.log(selectedSprites); |
| | | }); |
| | | |
| | | break |
| | | case MapMode.MOVABLE_MODE: |
| | | player.showGridLines(); |
| | | |
| | | player.activateMapMultiSelect((selectedSprites, restartFn) => { |
| | | Tool.spriteListBeMovable(selectedSprites, () => { |
| | | restartFn(); |
| | | }); |
| | | }); |
| | | break |
| | | case MapMode.SETTINGS_MODE: |
| | | player.hideGridLines(); |
| | | setDeviceVisible(false); |
| | | |
| | | player.activateMapMultiSelect((selectedSprites, restartFn) => { |
| | | console.log(selectedSprites); |
| | | }); |
| | | break |
| | | default: |
| | | break |
| | |
| | | }, [mode]); |
| | | |
| | | const onDrop = (sprite, type, x, y) => { |
| | | console.log(sprite, type, x, y); |
| | | |
| | | const { mapX, mapY } = Tool.getRealPosition(x, y); |
| | | sprite.x = mapX; |
| | | sprite.y = mapY; |
| | | |
| | | // Utils.initSprite(sprite, type); |
| | | // mapContainer.addChild(sprite); |
| | | // Utils.beMovable(sprite); |
| | | Tool.initSprite(sprite, type); |
| | | mapContainer.addChild(sprite); |
| | | Tool.beMovable(sprite); |
| | | }; |
| | | |
| | | const actions = [ |
| | |
| | | sx={{ mr: 1 }} |
| | | onClick={() => setDeviceVisible(!deviceVisible)} |
| | | > |
| | | 添加模型 |
| | | {translate('page.map.devices.title')} |
| | | </Button> |
| | | </> |
| | | )} |