From 6cc703a16e43c6850e92e59fc7d6aa9d0268becf Mon Sep 17 00:00:00 2001 From: Sendou Date: Wed, 24 Jul 2019 01:15:09 +0300 Subject: [PATCH] Map planner almost works --- react-ui/src/App.js | 4 +- react-ui/src/components/Misc/MainMenu.js | 72 ++++++++----- react-ui/src/components/Tools/MapPlanner.js | 110 +++++++++++++------- 3 files changed, 117 insertions(+), 69 deletions(-) diff --git a/react-ui/src/App.js b/react-ui/src/App.js index afd755703..f8ced606b 100644 --- a/react-ui/src/App.js +++ b/react-ui/src/App.js @@ -64,7 +64,9 @@ const App = () => { } /> - + } /> } /> } /> diff --git a/react-ui/src/components/Misc/MainMenu.js b/react-ui/src/components/Misc/MainMenu.js index bd1ad7c1c..3d90208d7 100644 --- a/react-ui/src/components/Misc/MainMenu.js +++ b/react-ui/src/components/Misc/MainMenu.js @@ -64,37 +64,53 @@ const MainMenu = withRouter(({ history, menuSelection, setMenuSelection }) => { active={menuSelection === 'home'} onClick={() => { history.push('/') }} /> - + + { history.push('/maps') }} - /> - { - history.push('/rotation') - setMenuSelection('rotations') - }} - /> - { - history.push('/builds') - setMenuSelection('builds') - }} - /> - { history.push('/xleaderboard') }} - /> - { history.push('/xsearch') }} - /> + /> + { + history.push('/rotation') + setMenuSelection('rotations') + }} + /> + { + history.push('/builds') + setMenuSelection('builds') + }} + /> + { + history.push('/plans') + setMenuSelection('plans') + }} + /> + + + + + { history.push('/xleaderboard') }} + /> + { history.push('/xsearch') }} + /> + + { +const MapPlanner = ({ setMenuSelection }) => { let sketch = null const [tool, setTool] = useState(Tools.Pencil) const [color, setColor] = useState('#f44336') const [weapon, setWeapon] = useState('') const [canUndo, setCanUndo] = useState(false) const [canRedo, setCanRedo] = useState(false) + const [text, setText] = useState('') const tools = [ { key: 1, text: 'Pencil', value: Tools.Pencil, icon: 'pencil' }, { key: 2, text: 'Line', value: Tools.Line, icon: 'window minimize outline' }, @@ -26,6 +27,17 @@ const MapPlanner = () => { setTool(Tools.Select) } + const addTextToSketch = () => { + sketch.addText(text, + { + fill: color, + fontFamily: "lato", + stroke: '#000000', + strokeWidth: 3, + paintFirst: "stroke" }) + setTool(Tools.Select) + } + const undo = () => { sketch.undo() setCanUndo(sketch.canUndo()) @@ -38,9 +50,8 @@ const MapPlanner = () => { setCanRedo(sketch.canRedo()) } - const download = () => { - let image = sketch.toDataURL("image/jpeg") - document.write('') + const removeSelected = () => { + sketch.removeSelected() } const onSketchChange = () => { @@ -53,58 +64,77 @@ const MapPlanner = () => { useEffect(() => { if (!sketch) return + setMenuSelection('plans') sketch.setBackgroundFromDataUrl('https://cdn.gamer-network.net/2017/usgamer/splatoon-2-humpback-pump-track.jpg') }, [sketch]) return (
-

Make your plans!

+

Make your plans!

(in the final version you can choose any map as the background)
(sketch = c)} - lineColor={color} - lineWidth={5} - width={1280} - height={720} - /*width={ - this.state.controlledSize ? this.state.sketchWidth : null - } - height={ - this.state.controlledSize ? this.state.sketchHeight : null - }*/ - /*defaultValue={dataJson}*/ - /*value={controlledValue}*/ - /*forceValue*/ - onChange={onSketchChange} - tool={tool} - /> + name="sketch" + className="canvas-area" + ref={c => (sketch = c)} + lineColor={color} + lineWidth={5} + width={1280} + height={720} + /*width={ + this.state.controlledSize ? this.state.sketchWidth : null + } + height={ + this.state.controlledSize ? this.state.sketchHeight : null + }*/ + /*defaultValue={dataJson}*/ + /*value={controlledValue}*/ + /*forceValue*/ + onChange={onSketchChange} + tool={tool} + />
- +
-

Tools

- setTool(value)} - options={tools} - selection - value={tool} - /> -
- setColor(newColor.hex)} - /> -
+ + + setColor(newColor.hex)} + /> + + +

Tools

+ setTool(value)} + options={tools} + selection + value={tool} + /> +
+ +

Add text

+ setText(e.target.value)} + /> +
+
+
+

Choose a weapon to add

-
+