| | |
| | | 'map.device.oper': 'Device Settings', |
| | | 'map.model.observer': 'Observer Pattern', |
| | | 'map.model.editor': 'Editor Pattern', |
| | | 'map.save': 'Save Map', |
| | | '': '', |
| | | '': '', |
| | | '': '', |
| | |
| | | {/* 3C40C6 */} |
| | | <Col span={12} style={{ backgroundColor: '#4a69bd' }}> |
| | | <Flex className={styles.flex} gap={'large'} justify={'flex-end'} align={'center'}> |
| | | <span> |
| | | {curSprite?.data?.uuid} |
| | | </span> |
| | | |
| | | {model !== MapModel.OBSERVER_MODEL && ( |
| | | <> |
| | | <Button |
| | | onClick={() => { |
| | | Utils.saveMapData(); |
| | | }} |
| | | > |
| | | <FormattedMessage id='map.save' defaultMessage='保存地图' /> |
| | | </Button> |
| | | </> |
| | | )} |
| | | |
| | | <Select |
| | | className='map-header-select' |
| | | size={'large'} |
| | |
| | | import * as PIXI from 'pixi.js'; |
| | | import * as TWEEDLE from 'tweedle.js'; |
| | | import Http from '@/utils/http'; |
| | | |
| | | let app = null; |
| | | let mapContainer = null; |
| | |
| | | } |
| | | } |
| | | |
| | | export const rotationToNum = (rotation) => { |
| | | let res = rotation * 180 / Math.PI; |
| | | if (res < 0) { |
| | | res += 360; |
| | | } else if (res > 360) { |
| | | res -= 360; |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | export const rotationParseNum = (num) => { |
| | | |
| | | } |
| | | |
| | | export const findSpriteByUuid = (uuid) => { |
| | | return mapContainer?.children?.find(child => child?.data?.uuid === uuid); |
| | | } |
| | |
| | | }) |
| | | return options; |
| | | } |
| | | |
| | | export const fetchMapData = () => { |
| | | |
| | | |
| | | } |
| | | |
| | | export const saveMapData = async () => { |
| | | if (!mapContainer) { |
| | | return; |
| | | } |
| | | |
| | | let mapItemList = []; |
| | | mapContainer?.children.forEach(child => { |
| | | if (child.data?.uuid) { |
| | | console.log(child.scale, child.rotation); |
| | | mapItemList.push({ |
| | | // data |
| | | type: child.data.type, |
| | | uuid: child.data.uuid, |
| | | no: child.data.no, |
| | | |
| | | // graph |
| | | positionX: child.position.x, |
| | | positionY: child.position.y, |
| | | scaleX: child.scale.x, |
| | | scaleY: child.scale.y, |
| | | rotation: rotationToNum(child.rotation) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | const resp = await Http.doPost('api/map/save', { itemList: mapItemList }) |
| | | console.log(resp); |
| | | } |
| | |
| | | @Data |
| | | public class MapItem { |
| | | |
| | | private String type; |
| | | |
| | | private String uuid; |
| | | |
| | | private String no; |
| | | |
| | | |
| | | private Double positionX; |
| | | |
| | | private Double positionY; |
| | | |
| | | private Double scaleX; |
| | | |
| | | private Double scaleY; |
| | | |
| | | private Double rotation; |
| | | |
| | | } |