diff --git a/brush/src/components/Map/OAMLayer/index.js b/brush/src/components/Map/OAMLayer/index.js index 5e98b5a..2bfd39c 100644 --- a/brush/src/components/Map/OAMLayer/index.js +++ b/brush/src/components/Map/OAMLayer/index.js @@ -3,20 +3,27 @@ import PropTypes from 'prop-types' import { range } from 'ramda' import PointOam from '../Point/PointOam' -const OAMLayer = ({ setSelectedPointInfos, totalStages, vision }) => { +const OAMLayer = ({ + setSelectedPointInfos, + totalStages, + updateOAMDiffMap, + vision, +}) => { const { oam } = vision const oamList = oam .map(oamEntry => oamEntry.data) - .map(oamData => + .map((oamData, oamIndex) => range(1, totalStages + 1).map((i) => { const x = oamData[`xStage${i}`] const y = oamData[`yStage${i}`] return ( { OAMLayer.propTypes = { setSelectedPointInfos: PropTypes.func, totalStages: PropTypes.number.isRequired, + updateOAMDiffMap: PropTypes.func, vision: PropTypes.shape({ oam: PropTypes.arrayOf(PropTypes.shape({ data: PropTypes.object.isRequired, @@ -45,6 +53,7 @@ OAMLayer.propTypes = { OAMLayer.defaultProps = { setSelectedPointInfos: () => {}, + updateOAMDiffMap: () => {}, } export default OAMLayer diff --git a/brush/src/components/Map/Point/PointOam.js b/brush/src/components/Map/Point/PointOam.js index d792d55..eff7662 100644 --- a/brush/src/components/Map/Point/PointOam.js +++ b/brush/src/components/Map/Point/PointOam.js @@ -21,6 +21,8 @@ const oamIdToColor = { const PointOam = ({ oamId, + oamIndex, + onFinishDragAndDrop, showPointInfosHandle, stage, x, @@ -35,11 +37,17 @@ const PointOam = ({ y, }) + const saveNewOAMPosition = (newX, newY) => { + onFinishDragAndDrop(oamIndex, `xStage${stage}`, newX) + onFinishDragAndDrop(oamIndex, `yStage${stage}`, newY) + } + return ( {}, showPointInfosHandle: () => {}, } diff --git a/brush/src/components/Map/Point/index.js b/brush/src/components/Map/Point/index.js index 23be89f..11ad461 100644 --- a/brush/src/components/Map/Point/index.js +++ b/brush/src/components/Map/Point/index.js @@ -9,6 +9,7 @@ const Point = ({ color, draggable, hasStroke, + onFinishDragAndDropHandle, onHoverHandle, scale, size, @@ -25,7 +26,10 @@ const Point = ({ const hoc = draggable ? withDraggable( + onFinishDragAndDropHandle, scale, + rawX, + rawY, setRawX, setRawY ) diff --git a/brush/src/components/Map/Point/withDraggable.js b/brush/src/components/Map/Point/withDraggable.js index c6f3004..6ea93a8 100644 --- a/brush/src/components/Map/Point/withDraggable.js +++ b/brush/src/components/Map/Point/withDraggable.js @@ -2,7 +2,10 @@ import { useState } from 'react' import getScaledCoordinates, { SIZE } from './getScaledCoordinates' const withDraggable = ( + onFinishDragAndDropHandle, scale, + x, + y, setX, setY ) => (Point) => { @@ -34,6 +37,7 @@ const withDraggable = ( setY(newY) }, mouseupoutside: () => { + onFinishDragAndDropHandle(x, y) setDragging(false) }, }, diff --git a/brush/src/components/Map/index.js b/brush/src/components/Map/index.js index 6c6111c..187a58d 100644 --- a/brush/src/components/Map/index.js +++ b/brush/src/components/Map/index.js @@ -21,6 +21,7 @@ const Map = ({ }) => { const { getTilemapPoint, + updateOAMDiffMap, updateTilemapPoint, vision, } = useContext(VisionContext) @@ -79,6 +80,7 @@ const Map = ({ width={width * 4} /> {optShowOAM && { - const newMemoryROM = saveVision(romBufferMemory, world, index, tilemap) +const romDownload = (romBufferMemory, world, index, tilemap, oamDiffMap) => { + const newMemoryROM = saveVision( + romBufferMemory, + world, + index, + tilemap, + oamDiffMap + ) const blob = new Blob([newMemoryROM]) @@ -24,6 +30,7 @@ const SaveButton = () => { const { romBufferMemory } = useContext(ROMContext) const { vision: { + oamDiffMap, state, tilemap, }, @@ -34,7 +41,13 @@ const SaveButton = () => { return (