import React, { useEffect,useState,useRef } from 'react';
import Tooltip from 'react-simple-tooltip' //Mess with all tooltip props here: https://cedricdelpoux.github.io/react-simple-tooltip/
/**
* Hook that alerts clicks outside of the passed ref
*/
function useOutsideAlerter(ref,setEdit) {
useEffect(() => {
/**
* Alert if clicked on outside of element
*/
function handleClickOutside(event) {
if (ref.current && !ref.current.contains(event.target)) {
setEdit(false)
}
}
// Bind the event listener
document.addEventListener("mousedown", handleClickOutside);
return () => {
// Unbind the event listener on clean up
document.removeEventListener("mousedown", handleClickOutside);
};
}, [ref,setEdit]);
}
function EditBox(p) {
useEffect(()=>{
var timer1 = setTimeout(()=>{
document.getElementById("editBoxInput").focus()
document.getElementById("editBoxInput").select()
},100)
return () => {
clearTimeout(timer1);
};
})
return {
if (e.key==="Enter") {p.setEdit(false)}
else if (e.key==="Escape") {p.setEdit(false)}
}} maxLength={p.maxlength?p.maxlength:20} onBlur={()=>{p.setEdit(false)}} value={p.value} onChange={(f)=>{f.currentTarget.value.length>0?p.setName(f.currentTarget.value):p.setName(p.originalName)}}>
}
function EditBoxInput(p) {
const [edit,setEdit] = useState(false)
useEffect(()=>{
if (p.callback) {
p.callback()
}
},[edit,p])
return <>
{setEdit(true)}}>
{edit?
:<>{p.prefix}{p.data}>}
>
}
function ExpandTooltip(p) {
return {p.mouseOverText}
}
function TestPanel(p) {
const [bpGraphMax,setbpGraphMax] = useState(1000)
const [hpGraphMax,sethpGraphMax] = useState(1000)
const [ppGraphMax,setppGraphMax] = useState(1000)
const [atkGraphMax,setatkGraphMax] = useState(1000)
const [defGraphMax,setdefGraphMax] = useState(1000)
const [author,setauthor] = useState("Player")
const [buildName,setbuildName] = useState("Character")
const [className,setclassName] = useState("Hunter")
const [subclassName,setsubclassName] = useState("Force")
const [level,setLevel] = useState(1)
const [secondaryLevel,setsecondaryLevel] = useState(1)
function Class(p) {
const CLASSES = p.GetData("class")
const class_obj = CLASSES[p.name]
return class_obj?<>{class_obj.name}>:<>>
}
function ClassSelector(p){
const CLASSES = p.GetData("class")
const wrapperRef = useRef(null);
useOutsideAlerter(wrapperRef,p.setEdit);
return
Class Selector
{Object.keys(CLASSES).map((cl,i)=>{
return
})}
}
function EditableClass(p){
const [edit,setEdit] = useState(false)
return <>{setEdit(!edit)}}>
{edit&&}
>
}
useEffect(()=>{
if (p.bp>1000) {
setbpGraphMax(3000)
sethpGraphMax(3000)
setppGraphMax(3000)
setatkGraphMax(3000)
setdefGraphMax(3000)
} else {
setbpGraphMax(1000)
sethpGraphMax(1000)
setppGraphMax(1000)
setatkGraphMax(1000)
setdefGraphMax(1000)
}
},[p.bp])
//console.log(p.GetData("class",p.className,"icon"))
return ( //Futasuke is a genius
)
}
export default TestPanel;