|
|
@ -7,9 +7,11 @@ function SkillTreeEditor(p) { |
|
|
|
|
|
|
|
|
|
|
|
const ADJUSTMENT = [-32,-32] |
|
|
|
const ADJUSTMENT = [-32,-32] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [firstLoad,setFirstLoad] = useState(true) |
|
|
|
|
|
|
|
|
|
|
|
const [classList,setClassList] = useState({}) |
|
|
|
const [classList,setClassList] = useState({}) |
|
|
|
const [skillTreeData,setSkillTreeData] = useState({}) |
|
|
|
const [skillTreeData,setSkillTreeData] = useState({}) |
|
|
|
const [cl,setCl] = useState(0) |
|
|
|
const [cl,setCl] = useState(-1) |
|
|
|
const [lineColor,setLineColor] = useState("#000000") |
|
|
|
const [lineColor,setLineColor] = useState("#000000") |
|
|
|
const [lineWidth,setLineWidth] = useState(3) |
|
|
|
const [lineWidth,setLineWidth] = useState(3) |
|
|
|
const [dimensionX,setDimensionX] = useState(6) |
|
|
|
const [dimensionX,setDimensionX] = useState(6) |
|
|
@ -25,7 +27,7 @@ function SkillTreeEditor(p) { |
|
|
|
const [loading,setLoading] = useState(false) |
|
|
|
const [loading,setLoading] = useState(false) |
|
|
|
|
|
|
|
|
|
|
|
function GetSkills(x,y) { |
|
|
|
function GetSkills(x,y) { |
|
|
|
var filtered = skillData.filter((skill)=>Number(skill[0])===x&&Number(skill[1])===y) |
|
|
|
var filtered = skillData.filter((skill)=>Number(skill.split(",")[0])===Number(x)&&Number(skill.split(",")[1])===Number(y)) |
|
|
|
if (filtered.length>0) { |
|
|
|
if (filtered.length>0) { |
|
|
|
return filtered[0] |
|
|
|
return filtered[0] |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -35,12 +37,29 @@ function SkillTreeEditor(p) { |
|
|
|
|
|
|
|
|
|
|
|
function SaveSkillTrees() { |
|
|
|
function SaveSkillTrees() { |
|
|
|
axios.post(p.BACKENDURL+"/saveskilltree",{ |
|
|
|
axios.post(p.BACKENDURL+"/saveskilltree",{ |
|
|
|
|
|
|
|
pass:p.password, |
|
|
|
|
|
|
|
data:skillLines.slice(0,dimensionY).map((str)=>str.slice(0,dimensionX)).join(','), |
|
|
|
|
|
|
|
skill_data:skillData.join(';'), |
|
|
|
|
|
|
|
line_color:lineColor, |
|
|
|
|
|
|
|
line_width:lineWidth, |
|
|
|
|
|
|
|
gridsizex:gridSizeX, |
|
|
|
|
|
|
|
gridsizey:gridSizeY, |
|
|
|
|
|
|
|
gridpaddingx:gridPaddingX, |
|
|
|
|
|
|
|
gridpaddingy:gridPaddingY, |
|
|
|
|
|
|
|
class_id:cl |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then((data)=>{ |
|
|
|
.then((data)=>{ |
|
|
|
|
|
|
|
if (data.data==="OK!") { |
|
|
|
|
|
|
|
setMessage(<span style={{color:"green"}}>{"Successfully saved skill tree for "+p.GetData("class",undefined,undefined,true)[cl].name+"!"}</span>) |
|
|
|
|
|
|
|
p.setUpdate(true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch((err)=>{ |
|
|
|
|
|
|
|
setMessage(<span style={{color:"red"}}>{err.message}</span>) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
.then(()=>{ |
|
|
|
setLoading(false) |
|
|
|
setLoading(false) |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
useEffect(()=>{ |
|
|
@ -50,6 +69,7 @@ function SkillTreeEditor(p) { |
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
useEffect(()=>{ |
|
|
|
var keys = Object.keys(skillTreeData) |
|
|
|
var keys = Object.keys(skillTreeData) |
|
|
|
|
|
|
|
var found = false |
|
|
|
for (var id of keys) { |
|
|
|
for (var id of keys) { |
|
|
|
//console.log(cl+"/"+skillTreeData[id].class_id)
|
|
|
|
//console.log(cl+"/"+skillTreeData[id].class_id)
|
|
|
|
if (Number(skillTreeData[id].class_id)===Number(cl)) { |
|
|
|
if (Number(skillTreeData[id].class_id)===Number(cl)) { |
|
|
@ -65,12 +85,22 @@ function SkillTreeEditor(p) { |
|
|
|
setGridSizeY(skillTreeData[id].gridsizey) |
|
|
|
setGridSizeY(skillTreeData[id].gridsizey) |
|
|
|
setGridPaddingX(skillTreeData[id].gridpaddingx) |
|
|
|
setGridPaddingX(skillTreeData[id].gridpaddingx) |
|
|
|
setGridPaddingY(skillTreeData[id].gridpaddingy) |
|
|
|
setGridPaddingY(skillTreeData[id].gridpaddingy) |
|
|
|
|
|
|
|
found=true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!found) { |
|
|
|
|
|
|
|
setSkillLines([]) |
|
|
|
|
|
|
|
setSkillData([]) |
|
|
|
|
|
|
|
setDimensionX(6) |
|
|
|
|
|
|
|
setDimensionY(6) |
|
|
|
|
|
|
|
} |
|
|
|
},[skillTreeData,cl]) |
|
|
|
},[skillTreeData,cl]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
useEffect(()=>{ |
|
|
|
|
|
|
|
if (firstLoad) { |
|
|
|
setCl(Object.keys(classList)[0]) |
|
|
|
setCl(Object.keys(classList)[0]) |
|
|
|
|
|
|
|
setFirstLoad(false) |
|
|
|
|
|
|
|
} |
|
|
|
},[classList]) |
|
|
|
},[classList]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
useEffect(()=>{ |
|
|
@ -127,27 +157,34 @@ function SkillTreeEditor(p) { |
|
|
|
|
|
|
|
|
|
|
|
return <> |
|
|
|
return <> |
|
|
|
{loading?<img src={process.env.PUBLIC_URL+"/spinner.gif"} alt=""/>:<> |
|
|
|
{loading?<img src={process.env.PUBLIC_URL+"/spinner.gif"} alt=""/>:<> |
|
|
|
|
|
|
|
<h2>{message}</h2> |
|
|
|
<label for="classSelect">Class Select:</label><select id="classSelect" value={cl} onChange={(f)=>{setCl(f.currentTarget.value)}}> |
|
|
|
<label for="classSelect">Class Select:</label><select id="classSelect" value={cl} onChange={(f)=>{setCl(f.currentTarget.value)}}> |
|
|
|
|
|
|
|
<option value=""></option> |
|
|
|
{Object.keys(classList).map((c)=><option value={c}>{c+" - "+classList[c].name}</option>)} |
|
|
|
{Object.keys(classList).map((c)=><option value={c}>{c+" - "+classList[c].name}</option>)} |
|
|
|
</select> |
|
|
|
</select> |
|
|
|
<br/><button onClick={()=>{ |
|
|
|
<br/> |
|
|
|
|
|
|
|
<br/> |
|
|
|
|
|
|
|
{p.GetData("class",undefined,undefined,true)[cl]?.name&&<button onClick={()=>{ |
|
|
|
setLoading(true) |
|
|
|
setLoading(true) |
|
|
|
SaveSkillTrees() |
|
|
|
SaveSkillTrees() |
|
|
|
}}>{"Save "+p.GetData("class",undefined,undefined,true)[cl].name+" Skill Tree"}</button> |
|
|
|
}}>{"Save "+p.GetData("class",undefined,undefined,true)[cl]?.name+" Skill Tree"}</button>} |
|
|
|
<div style={{width:"800px",position:"relative",left:"300px"}}> |
|
|
|
<div style={{width:"800px",position:"relative",left:"300px"}}> |
|
|
|
<SkillTree strokeStyle={lineColor} lineWidth={lineWidth} lineDash={[]} |
|
|
|
<SkillTree strokeStyle={lineColor} lineWidth={lineWidth} lineDash={[]} |
|
|
|
gridDimensionsX={dimensionX} gridDimensionsY={dimensionY} gridSizeX={gridSizeX} gridSizeY={gridSizeY} gridPaddingX={gridPaddingX} gridPaddingY={gridPaddingY} |
|
|
|
gridDimensionsX={dimensionX} gridDimensionsY={dimensionY} gridSizeX={gridSizeX} gridSizeY={gridSizeY} gridPaddingX={gridPaddingX} gridPaddingY={gridPaddingY} |
|
|
|
skillLines={skillLines} |
|
|
|
skillLines={skillLines} |
|
|
|
/> |
|
|
|
/> |
|
|
|
{renderedInputs.map((control)=>control)} |
|
|
|
{renderedInputs.map((control)=>control)} |
|
|
|
<label for="lineColor">Line Color:</label><input type="color" id="lineColor" value={lineColor} onChange={(f)=>{setLineColor(f.currentTarget.value)}}/> |
|
|
|
<br/> |
|
|
|
<label for="lineWidth">Line Width:</label><input type="number" id="lineWidth" value={lineWidth} onChange={(f)=>{setLineWidth(f.currentTarget.value)}}/> |
|
|
|
<hr/> |
|
|
|
<label for="gridSizeX">Grid Size X:</label><input type="number" id="gridSizeX" value={dimensionX} onChange={(f)=>{setDimensionX(f.currentTarget.value)}}/> |
|
|
|
<br/> |
|
|
|
<label for="gridSizeY">Grid Size Y:</label><input type="number" id="gridSizeY" value={dimensionY} onChange={(f)=>{setDimensionY(f.currentTarget.value)}}/> |
|
|
|
<label for="lineColor">Line Color:</label><input type="color" id="lineColor" value={lineColor} onChange={(f)=>{setLineColor(f.currentTarget.value)}}/><br/> |
|
|
|
<label for="boxSizeX">Box Size X:</label><input type="number" id="boxSizeX" value={gridSizeX} onChange={(f)=>{setGridSizeX(f.currentTarget.value)}}/> |
|
|
|
<label for="lineWidth">Line Width:</label><input type="number" id="lineWidth" value={lineWidth} onChange={(f)=>{setLineWidth(f.currentTarget.value)}}/><br/> |
|
|
|
<label for="boxSizeY">Box Size Y:</label><input type="number" id="boxSizeY" value={gridSizeY} onChange={(f)=>{setGridSizeY(f.currentTarget.value)}}/> |
|
|
|
<label for="gridSizeX">Grid Size X:</label><input type="number" id="gridSizeX" value={dimensionX} onChange={(f)=>{setDimensionX(f.currentTarget.value)}}/><br/> |
|
|
|
<label for="gridPaddingX">Grid Padding X:</label><input type="number" id="gridPaddingX" value={gridPaddingX} onChange={(f)=>{setGridPaddingX(f.currentTarget.value)}}/> |
|
|
|
<label for="gridSizeY">Grid Size Y:</label><input type="number" id="gridSizeY" value={dimensionY} onChange={(f)=>{setDimensionY(f.currentTarget.value)}}/><br/> |
|
|
|
<label for="gridPaddingY">Grid Padding Y:</label><input type="number" id="gridPaddingY" value={gridPaddingY} onChange={(f)=>{setGridPaddingY(f.currentTarget.value)}}/> |
|
|
|
<label for="boxSizeX">Box Size X:</label><input type="number" id="boxSizeX" value={gridSizeX} onChange={(f)=>{setGridSizeX(f.currentTarget.value)}}/><br/> |
|
|
|
|
|
|
|
<label for="boxSizeY">Box Size Y:</label><input type="number" id="boxSizeY" value={gridSizeY} onChange={(f)=>{setGridSizeY(f.currentTarget.value)}}/><br/> |
|
|
|
|
|
|
|
<label for="gridPaddingX">Grid Padding X:</label><input type="number" id="gridPaddingX" value={gridPaddingX} onChange={(f)=>{setGridPaddingX(f.currentTarget.value)}}/><br/> |
|
|
|
|
|
|
|
<label for="gridPaddingY">Grid Padding Y:</label><input type="number" id="gridPaddingY" value={gridPaddingY} onChange={(f)=>{setGridPaddingY(f.currentTarget.value)}}/><br/> |
|
|
|
|
|
|
|
|
|
|
|
</div></>} |
|
|
|
</div></>} |
|
|
|
</> |
|
|
|
</> |
|
|
|