diff --git a/src/skilltree/skillTreeEditor.js b/src/skilltree/skillTreeEditor.js index 77aa1e9..8addab5 100644 --- a/src/skilltree/skillTreeEditor.js +++ b/src/skilltree/skillTreeEditor.js @@ -1,7 +1,11 @@ import { SkillTree } from "./skillTree"; import { useEffect, useState } from "react"; +import { SkillTreeSelector } from "./skillTreeSelector"; function SkillTreeEditor(p) { + + const ADJUSTMENT = [-32,-32] + const [lineColor,setLineColor] = useState("#000000") const [lineWidth,setLineWidth] = useState(3) const [dimensionX,setDimensionX] = useState(6) @@ -11,18 +15,41 @@ function SkillTreeEditor(p) { const [gridPaddingX,setGridPaddingX] = useState(10) const [gridPaddingY,setGridPaddingY] = useState(10) const [renderedInputs,setRenderedInputs] = useState([]) + const [skillLines,setSkillLines] = useState([ + "□ □ ", //─ □ + "└□─┘□□", //│ ├┤┼ + " │ ││", // + " │ □│", //┌ ┐ ┬ + " □─□┼□", //└ ┘ ┴ + " □ "]) useEffect(()=>{ var controls = [] for (var x=0;x) + var padX = x!==0?gridPaddingX*x:0 + var padY = y!==0?gridPaddingY*y:0 + controls.push({ + var string = [...skillLines] + var stringLine = string[y].split('') + stringLine[x] = char + string[y] = stringLine.join('') + setSkillLines(string) + } + } ADJUSTMENT={ADJUSTMENT} x={x} y={y} gridSizeX={gridSizeX} gridSizeY={gridSizeY} padX={padX} padY={padY}/>) } } - },[dimensionX,dimensionY,gridSizeX,gridSizeY,gridPaddingX,gridPaddingY]) + setRenderedInputs(controls) + },[skillLines,dimensionX,dimensionY,gridSizeX,gridSizeY,gridPaddingX,gridPaddingY]) return <> - {setLineColor(f.currentTarget.value)}}/> +
+ + {renderedInputs.map((control)=>control)} + {setLineColor(f.currentTarget.value)}}/> {setLineWidth(f.currentTarget.value)}}/> {setDimensionX(f.currentTarget.value)}}/> {setDimensionY(f.currentTarget.value)}}/> @@ -30,15 +57,8 @@ function SkillTreeEditor(p) { {setGridSizeY(f.currentTarget.value)}}/> {setGridPaddingX(f.currentTarget.value)}}/> {setGridPaddingY(f.currentTarget.value)}}/> - + +
} diff --git a/src/skilltree/skillTreeSelector.js b/src/skilltree/skillTreeSelector.js new file mode 100644 index 0000000..5c44edf --- /dev/null +++ b/src/skilltree/skillTreeSelector.js @@ -0,0 +1,19 @@ +import { useEffect, useState } from 'react' + +function SkillTreeSelector(p) { + + const [char,setChar] = useState(p.defaultValue) + + useEffect(()=>{ + p.callback(char,Number(p.x),Number(p.y)) + },[char]) + + return + +} + +export {SkillTreeSelector} \ No newline at end of file