|
|
@ -14,28 +14,25 @@ import TitleInput from "../components/TitleInput"
|
|
|
|
import PlainCourt from "../assets/court/full_court.svg?react"
|
|
|
|
import PlainCourt from "../assets/court/full_court.svg?react"
|
|
|
|
import HalfCourt from "../assets/court/half_court.svg?react"
|
|
|
|
import HalfCourt from "../assets/court/half_court.svg?react"
|
|
|
|
|
|
|
|
|
|
|
|
import { BallPiece } from "../components/editor/BallPiece"
|
|
|
|
import {BallPiece} from "../components/editor/BallPiece"
|
|
|
|
|
|
|
|
|
|
|
|
import { Rack } from "../components/Rack"
|
|
|
|
import {Rack} from "../components/Rack"
|
|
|
|
import { PlayerPiece } from "../components/editor/PlayerPiece"
|
|
|
|
import {PlayerPiece} from "../components/editor/PlayerPiece"
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
CourtType,
|
|
|
|
CourtType, StepContent, StepInfoNode,
|
|
|
|
Tactic,
|
|
|
|
Tactic,
|
|
|
|
TacticComponent,
|
|
|
|
TacticComponent,
|
|
|
|
TacticContent,
|
|
|
|
|
|
|
|
} from "../model/tactic/Tactic"
|
|
|
|
} from "../model/tactic/Tactic"
|
|
|
|
import { fetchAPI, fetchAPIGet } from "../Fetcher"
|
|
|
|
import { fetchAPI, fetchAPIGet } from "../Fetcher"
|
|
|
|
|
|
|
|
|
|
|
|
import SavingState, {
|
|
|
|
import SavingState, {SaveState, SaveStates,} from "../components/editor/SavingState"
|
|
|
|
SaveState,
|
|
|
|
|
|
|
|
SaveStates,
|
|
|
|
|
|
|
|
} from "../components/editor/SavingState"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { BALL_TYPE } from "../model/tactic/CourtObjects"
|
|
|
|
import { BALL_TYPE } from "../model/tactic/CourtObjects"
|
|
|
|
import { CourtAction } from "../components/editor/CourtAction"
|
|
|
|
import { CourtAction } from "../components/editor/CourtAction"
|
|
|
|
import { ActionPreview, BasketCourt } from "../components/editor/BasketCourt"
|
|
|
|
import { ActionPreview, BasketCourt } from "../components/editor/BasketCourt"
|
|
|
|
import { overlaps } from "../geo/Box"
|
|
|
|
import { overlaps } from "../geo/Box"
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
dropBallOnComponent,
|
|
|
|
dropBallOnComponent,
|
|
|
|
getComponentCollided,
|
|
|
|
getComponentCollided,
|
|
|
@ -47,24 +44,14 @@ import {
|
|
|
|
removeBall,
|
|
|
|
removeBall,
|
|
|
|
updateComponent,
|
|
|
|
updateComponent,
|
|
|
|
} from "../editor/TacticContentDomains"
|
|
|
|
} from "../editor/TacticContentDomains"
|
|
|
|
import {
|
|
|
|
|
|
|
|
BallState,
|
|
|
|
import {BallState, Player, PlayerInfo, PlayerLike, PlayerTeam,} from "../model/tactic/Player"
|
|
|
|
Player,
|
|
|
|
import {RackedCourtObject, RackedPlayer} from "../editor/RackedItems"
|
|
|
|
PlayerInfo,
|
|
|
|
|
|
|
|
PlayerLike,
|
|
|
|
|
|
|
|
PlayerTeam,
|
|
|
|
|
|
|
|
} from "../model/tactic/Player"
|
|
|
|
|
|
|
|
import { RackedCourtObject, RackedPlayer } from "../editor/RackedItems"
|
|
|
|
|
|
|
|
import CourtPlayer from "../components/editor/CourtPlayer"
|
|
|
|
import CourtPlayer from "../components/editor/CourtPlayer"
|
|
|
|
import {
|
|
|
|
import {createAction, getActionKind, isActionValid, removeAction,} from "../editor/ActionsDomains"
|
|
|
|
createAction,
|
|
|
|
|
|
|
|
getActionKind,
|
|
|
|
|
|
|
|
isActionValid,
|
|
|
|
|
|
|
|
removeAction,
|
|
|
|
|
|
|
|
} from "../editor/ActionsDomains"
|
|
|
|
|
|
|
|
import ArrowAction from "../components/actions/ArrowAction"
|
|
|
|
import ArrowAction from "../components/actions/ArrowAction"
|
|
|
|
import { middlePos, Pos, ratioWithinBase } from "../geo/Pos"
|
|
|
|
import {middlePos, Pos, ratioWithinBase} from "../geo/Pos"
|
|
|
|
import { Action, ActionKind } from "../model/tactic/Action"
|
|
|
|
import {Action, ActionKind} from "../model/tactic/Action"
|
|
|
|
import BallAction from "../components/actions/BallAction"
|
|
|
|
import BallAction from "../components/actions/BallAction"
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
changePlayerBallState,
|
|
|
|
changePlayerBallState,
|
|
|
@ -75,6 +62,7 @@ import {
|
|
|
|
import { CourtBall } from "../components/editor/CourtBall"
|
|
|
|
import { CourtBall } from "../components/editor/CourtBall"
|
|
|
|
import { useNavigate, useParams } from "react-router-dom"
|
|
|
|
import { useNavigate, useParams } from "react-router-dom"
|
|
|
|
import { DEFAULT_TACTIC_NAME } from "./NewTacticPage.tsx"
|
|
|
|
import { DEFAULT_TACTIC_NAME } from "./NewTacticPage.tsx"
|
|
|
|
|
|
|
|
import StepsTree from "../components/editor/StepsTree"
|
|
|
|
|
|
|
|
|
|
|
|
const ERROR_STYLE: CSSProperties = {
|
|
|
|
const ERROR_STYLE: CSSProperties = {
|
|
|
|
borderColor: "red",
|
|
|
|
borderColor: "red",
|
|
|
@ -85,7 +73,7 @@ const GUEST_MODE_TITLE_STORAGE_KEY = "guest_mode_title"
|
|
|
|
|
|
|
|
|
|
|
|
export interface EditorViewProps {
|
|
|
|
export interface EditorViewProps {
|
|
|
|
tactic: Tactic
|
|
|
|
tactic: Tactic
|
|
|
|
onContentChange: (tactic: TacticContent) => Promise<SaveState>
|
|
|
|
onContentChange: (tactic: StepContent) => Promise<SaveState>
|
|
|
|
onNameChange: (name: string) => Promise<boolean>
|
|
|
|
onNameChange: (name: string) => Promise<boolean>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
interface TacticDto {
|
|
|
|
interface TacticDto {
|
|
|
@ -93,6 +81,7 @@ interface TacticDto {
|
|
|
|
name: string
|
|
|
|
name: string
|
|
|
|
courtType: CourtType
|
|
|
|
courtType: CourtType
|
|
|
|
content: string
|
|
|
|
content: string
|
|
|
|
|
|
|
|
root: StepInfoNode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface EditorPageProps {
|
|
|
|
interface EditorPageProps {
|
|
|
@ -107,6 +96,7 @@ export default function EditorPage({ guestMode }: EditorPageProps) {
|
|
|
|
courtType: "PLAIN",
|
|
|
|
courtType: "PLAIN",
|
|
|
|
content: '{"components": []}',
|
|
|
|
content: '{"components": []}',
|
|
|
|
name: DEFAULT_TACTIC_NAME,
|
|
|
|
name: DEFAULT_TACTIC_NAME,
|
|
|
|
|
|
|
|
root: {id: 1, children: []}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
return null
|
|
|
@ -120,9 +110,11 @@ export default function EditorPage({ guestMode }: EditorPageProps) {
|
|
|
|
|
|
|
|
|
|
|
|
async function initialize() {
|
|
|
|
async function initialize() {
|
|
|
|
const infoResponsePromise = fetchAPIGet(`tactics/${id}`)
|
|
|
|
const infoResponsePromise = fetchAPIGet(`tactics/${id}`)
|
|
|
|
|
|
|
|
const treeResponsePromise = fetchAPIGet(`tactics/${id}/tree`)
|
|
|
|
const contentResponsePromise = fetchAPIGet(`tactics/${id}/steps/1`)
|
|
|
|
const contentResponsePromise = fetchAPIGet(`tactics/${id}/steps/1`)
|
|
|
|
|
|
|
|
|
|
|
|
const infoResponse = await infoResponsePromise
|
|
|
|
const infoResponse = await infoResponsePromise
|
|
|
|
|
|
|
|
const treeResponse = await treeResponsePromise
|
|
|
|
const contentResponse = await contentResponsePromise
|
|
|
|
const contentResponse = await contentResponsePromise
|
|
|
|
|
|
|
|
|
|
|
|
if (infoResponse.status == 401 || contentResponse.status == 401) {
|
|
|
|
if (infoResponse.status == 401 || contentResponse.status == 401) {
|
|
|
@ -132,8 +124,9 @@ export default function EditorPage({ guestMode }: EditorPageProps) {
|
|
|
|
|
|
|
|
|
|
|
|
const { name, courtType } = await infoResponse.json()
|
|
|
|
const { name, courtType } = await infoResponse.json()
|
|
|
|
const content = await contentResponse.text()
|
|
|
|
const content = await contentResponse.text()
|
|
|
|
|
|
|
|
const { root } = await treeResponse.json()
|
|
|
|
|
|
|
|
|
|
|
|
setTactic({ id, name, courtType, content })
|
|
|
|
setTactic({ id, name, courtType, content, root })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
initialize()
|
|
|
|
initialize()
|
|
|
@ -143,6 +136,7 @@ export default function EditorPage({ guestMode }: EditorPageProps) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Editor
|
|
|
|
<Editor
|
|
|
|
id={id}
|
|
|
|
id={id}
|
|
|
|
|
|
|
|
rootStepNode={tactic.root}
|
|
|
|
courtType={tactic.courtType}
|
|
|
|
courtType={tactic.courtType}
|
|
|
|
content={tactic.content}
|
|
|
|
content={tactic.content}
|
|
|
|
name={tactic.name}
|
|
|
|
name={tactic.name}
|
|
|
@ -161,14 +155,15 @@ export interface EditorProps {
|
|
|
|
id: number
|
|
|
|
id: number
|
|
|
|
name: string
|
|
|
|
name: string
|
|
|
|
content: string
|
|
|
|
content: string
|
|
|
|
courtType: CourtType
|
|
|
|
courtType: CourtType,
|
|
|
|
|
|
|
|
rootStepNode: StepInfoNode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function Editor({ id, name, courtType, content }: EditorProps) {
|
|
|
|
function Editor({ id, name, courtType, content, rootStepNode }: EditorProps) {
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
|
|
|
|
|
|
|
|
const storageContent = localStorage.getItem(GUEST_MODE_CONTENT_STORAGE_KEY)
|
|
|
|
const storageContent = localStorage.getItem(GUEST_MODE_CONTENT_STORAGE_KEY)
|
|
|
|
const editorContent =
|
|
|
|
const stepContent =
|
|
|
|
isInGuestMode && storageContent != null ? storageContent : content
|
|
|
|
isInGuestMode && storageContent != null ? storageContent : content
|
|
|
|
|
|
|
|
|
|
|
|
const storageName = localStorage.getItem(GUEST_MODE_TITLE_STORAGE_KEY)
|
|
|
|
const storageName = localStorage.getItem(GUEST_MODE_TITLE_STORAGE_KEY)
|
|
|
@ -182,9 +177,13 @@ function Editor({ id, name, courtType, content }: EditorProps) {
|
|
|
|
name: editorName,
|
|
|
|
name: editorName,
|
|
|
|
id,
|
|
|
|
id,
|
|
|
|
courtType,
|
|
|
|
courtType,
|
|
|
|
content: JSON.parse(editorContent),
|
|
|
|
currentStepContent: {
|
|
|
|
|
|
|
|
stepId: 1,
|
|
|
|
|
|
|
|
...JSON.parse(stepContent)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
rootStepNode,
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onContentChange={async (content: TacticContent) => {
|
|
|
|
onContentChange={async (content: StepContent) => {
|
|
|
|
if (isInGuestMode) {
|
|
|
|
if (isInGuestMode) {
|
|
|
|
localStorage.setItem(
|
|
|
|
localStorage.setItem(
|
|
|
|
GUEST_MODE_CONTENT_STORAGE_KEY,
|
|
|
|
GUEST_MODE_CONTENT_STORAGE_KEY,
|
|
|
@ -196,6 +195,7 @@ function Editor({ id, name, courtType, content }: EditorProps) {
|
|
|
|
`tactics/${id}/steps/1`,
|
|
|
|
`tactics/${id}/steps/1`,
|
|
|
|
{ content },
|
|
|
|
{ content },
|
|
|
|
"PUT",
|
|
|
|
"PUT",
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if (response.status == 401) {
|
|
|
|
if (response.status == 401) {
|
|
|
|
navigate("/login")
|
|
|
|
navigate("/login")
|
|
|
@ -212,21 +212,39 @@ function Editor({ id, name, courtType, content }: EditorProps) {
|
|
|
|
`tactics/${id}/name`,
|
|
|
|
`tactics/${id}/name`,
|
|
|
|
{ name },
|
|
|
|
{ name },
|
|
|
|
"PUT",
|
|
|
|
"PUT",
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if (response.status == 401) {
|
|
|
|
if (response.status == 401) {
|
|
|
|
navigate("/login")
|
|
|
|
navigate("/login")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return response.ok
|
|
|
|
return response.ok
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
|
|
|
|
onStepSelected={() => {
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
stepsContentsRoot={rootStepNode}
|
|
|
|
|
|
|
|
courtType={courtType}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface EditorViewProps {
|
|
|
|
|
|
|
|
tactic: Tactic
|
|
|
|
|
|
|
|
onContentChange: (tactic: StepContent) => Promise<SaveState>
|
|
|
|
|
|
|
|
onStepSelected: (stepId: number) => void,
|
|
|
|
|
|
|
|
onNameChange: (name: string) => Promise<boolean>
|
|
|
|
|
|
|
|
stepsContentsRoot: StepInfoNode
|
|
|
|
|
|
|
|
courtType: "PLAIN" | "HALF"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function EditorView({
|
|
|
|
function EditorView({
|
|
|
|
tactic: { id, name, content: initialContent, courtType },
|
|
|
|
|
|
|
|
|
|
|
|
tactic: {id, name, currentStepContent: initialContent},
|
|
|
|
onContentChange,
|
|
|
|
onContentChange,
|
|
|
|
onNameChange,
|
|
|
|
onNameChange,
|
|
|
|
}: EditorViewProps) {
|
|
|
|
onStepSelected,
|
|
|
|
|
|
|
|
stepsContentsRoot,
|
|
|
|
|
|
|
|
courtType,
|
|
|
|
|
|
|
|
}: EditorViewProps) {
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
|
|
|
|
|
|
|
|
const [titleStyle, setTitleStyle] = useState<CSSProperties>({})
|
|
|
|
const [titleStyle, setTitleStyle] = useState<CSSProperties>({})
|
|
|
@ -244,13 +262,15 @@ function EditorView({
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const [objects, setObjects] = useState<RackedCourtObject[]>(() =>
|
|
|
|
const [objects, setObjects] = useState<RackedCourtObject[]>(() =>
|
|
|
|
isBallOnCourt(content) ? [] : [{ key: "ball" }],
|
|
|
|
isBallOnCourt(content) ? [] : [{key: "ball"}],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const [previewAction, setPreviewAction] = useState<ActionPreview | null>(
|
|
|
|
const [previewAction, setPreviewAction] = useState<ActionPreview | null>(
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [isStepsTreeVisible, setStepsTreeVisible] = useState(false)
|
|
|
|
|
|
|
|
|
|
|
|
const courtRef = useRef<HTMLDivElement>(null)
|
|
|
|
const courtRef = useRef<HTMLDivElement>(null)
|
|
|
|
|
|
|
|
|
|
|
|
const setComponents = (action: SetStateAction<TacticComponent[]>) => {
|
|
|
|
const setComponents = (action: SetStateAction<TacticComponent[]>) => {
|
|
|
@ -267,7 +287,7 @@ function EditorView({
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
setObjects(isBallOnCourt(content) ? [] : [{ key: "ball" }])
|
|
|
|
setObjects(isBallOnCourt(content) ? [] : [{key: "ball"}])
|
|
|
|
}, [setObjects, content])
|
|
|
|
}, [setObjects, content])
|
|
|
|
|
|
|
|
|
|
|
|
const insertRackedPlayer = (player: Player) => {
|
|
|
|
const insertRackedPlayer = (player: Player) => {
|
|
|
@ -280,7 +300,7 @@ function EditorView({
|
|
|
|
setter = setAllies
|
|
|
|
setter = setAllies
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (player.ballState == BallState.HOLDS_BY_PASS) {
|
|
|
|
if (player.ballState == BallState.HOLDS_BY_PASS) {
|
|
|
|
setObjects([{ key: "ball" }])
|
|
|
|
setObjects([{key: "ball"}])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setter((players) => [
|
|
|
|
setter((players) => [
|
|
|
|
...players,
|
|
|
|
...players,
|
|
|
@ -479,7 +499,7 @@ function EditorView({
|
|
|
|
setContent((content) => removeBall(content))
|
|
|
|
setContent((content) => removeBall(content))
|
|
|
|
setObjects((objects) => [
|
|
|
|
setObjects((objects) => [
|
|
|
|
...objects,
|
|
|
|
...objects,
|
|
|
|
{ key: "ball" },
|
|
|
|
{key: "ball"},
|
|
|
|
])
|
|
|
|
])
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
@ -516,7 +536,7 @@ function EditorView({
|
|
|
|
<div id="main-div">
|
|
|
|
<div id="main-div">
|
|
|
|
<div id="topbar-div">
|
|
|
|
<div id="topbar-div">
|
|
|
|
<div id="topbar-left">
|
|
|
|
<div id="topbar-left">
|
|
|
|
<SavingState state={saveState} />
|
|
|
|
<SavingState state={saveState}/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="title-input-div">
|
|
|
|
<div id="title-input-div">
|
|
|
|
<TitleInput
|
|
|
|
<TitleInput
|
|
|
@ -532,9 +552,14 @@ function EditorView({
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="topbar-right" />
|
|
|
|
<div id="topbar-right">
|
|
|
|
|
|
|
|
<button onClick={() => setStepsTreeVisible((b) => !b)}>
|
|
|
|
|
|
|
|
STEPS
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="edit-div">
|
|
|
|
<div id="editor-div">
|
|
|
|
|
|
|
|
<div id="content-div">
|
|
|
|
<div id="racks">
|
|
|
|
<div id="racks">
|
|
|
|
<PlayerRack
|
|
|
|
<PlayerRack
|
|
|
|
id={"allies"}
|
|
|
|
id={"allies"}
|
|
|
@ -583,7 +608,7 @@ function EditorView({
|
|
|
|
<div id="court-div-bounds">
|
|
|
|
<div id="court-div-bounds">
|
|
|
|
<BasketCourt
|
|
|
|
<BasketCourt
|
|
|
|
components={content.components}
|
|
|
|
components={content.components}
|
|
|
|
courtImage={<Court courtType={courtType} />}
|
|
|
|
courtImage={<Court courtType={courtType}/>}
|
|
|
|
courtRef={courtRef}
|
|
|
|
courtRef={courtRef}
|
|
|
|
previewAction={previewAction}
|
|
|
|
previewAction={previewAction}
|
|
|
|
renderComponent={renderComponent}
|
|
|
|
renderComponent={renderComponent}
|
|
|
@ -592,6 +617,69 @@ function EditorView({
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<EditorStepsTree isVisible={isStepsTreeVisible} root={stepsContentsRoot}/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface EditorStepsTreeProps {
|
|
|
|
|
|
|
|
isVisible: boolean
|
|
|
|
|
|
|
|
root: StepInfoNode
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function EditorStepsTree({isVisible, root}: EditorStepsTreeProps) {
|
|
|
|
|
|
|
|
const fakeRoot: StepInfoNode = {
|
|
|
|
|
|
|
|
id: 0,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 1,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 2,
|
|
|
|
|
|
|
|
children: []
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 3,
|
|
|
|
|
|
|
|
children: [{
|
|
|
|
|
|
|
|
id: 4,
|
|
|
|
|
|
|
|
children: []
|
|
|
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 5,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 6,
|
|
|
|
|
|
|
|
children: []
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 7,
|
|
|
|
|
|
|
|
children: []
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 8,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 9,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
id: 10,
|
|
|
|
|
|
|
|
children: []
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div id="steps-div" style={{transform: isVisible ? "translateX(0)" : "translateX(100%)"}}>
|
|
|
|
|
|
|
|
<StepsTree root={fakeRoot}/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -612,7 +700,7 @@ function PlayerRack({
|
|
|
|
setObjects,
|
|
|
|
setObjects,
|
|
|
|
courtRef,
|
|
|
|
courtRef,
|
|
|
|
setComponents,
|
|
|
|
setComponents,
|
|
|
|
}: PlayerRackProps) {
|
|
|
|
}: PlayerRackProps) {
|
|
|
|
const courtBounds = useCallback(
|
|
|
|
const courtBounds = useCallback(
|
|
|
|
() => courtRef.current!.getBoundingClientRect(),
|
|
|
|
() => courtRef.current!.getBoundingClientRect(),
|
|
|
|
[courtRef],
|
|
|
|
[courtRef],
|
|
|
@ -640,7 +728,7 @@ function PlayerRack({
|
|
|
|
[courtBounds, setComponents],
|
|
|
|
[courtBounds, setComponents],
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
render={useCallback(
|
|
|
|
render={useCallback(
|
|
|
|
({ team, key }: { team: PlayerTeam; key: string }) => (
|
|
|
|
({team, key}: { team: PlayerTeam; key: string }) => (
|
|
|
|
<PlayerPiece
|
|
|
|
<PlayerPiece
|
|
|
|
team={team}
|
|
|
|
team={team}
|
|
|
|
text={key}
|
|
|
|
text={key}
|
|
|
@ -659,8 +747,8 @@ interface CourtPlayerArrowActionProps {
|
|
|
|
player: PlayerLike
|
|
|
|
player: PlayerLike
|
|
|
|
isInvalid: boolean
|
|
|
|
isInvalid: boolean
|
|
|
|
|
|
|
|
|
|
|
|
content: TacticContent
|
|
|
|
content: StepContent
|
|
|
|
setContent: (state: SetStateAction<TacticContent>) => void
|
|
|
|
setContent: (state: SetStateAction<StepContent>) => void
|
|
|
|
setPreviewAction: (state: SetStateAction<ActionPreview | null>) => void
|
|
|
|
setPreviewAction: (state: SetStateAction<ActionPreview | null>) => void
|
|
|
|
courtRef: RefObject<HTMLDivElement>
|
|
|
|
courtRef: RefObject<HTMLDivElement>
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -674,7 +762,7 @@ function CourtPlayerArrowAction({
|
|
|
|
setContent,
|
|
|
|
setContent,
|
|
|
|
setPreviewAction,
|
|
|
|
setPreviewAction,
|
|
|
|
courtRef,
|
|
|
|
courtRef,
|
|
|
|
}: CourtPlayerArrowActionProps) {
|
|
|
|
}: CourtPlayerArrowActionProps) {
|
|
|
|
const courtBounds = useCallback(
|
|
|
|
const courtBounds = useCallback(
|
|
|
|
() => courtRef.current!.getBoundingClientRect(),
|
|
|
|
() => courtRef.current!.getBoundingClientRect(),
|
|
|
|
[courtRef],
|
|
|
|
[courtRef],
|
|
|
@ -729,7 +817,7 @@ function CourtPlayerArrowAction({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
setContent((content) => {
|
|
|
|
let { createdAction, newContent } = createAction(
|
|
|
|
let {createdAction, newContent} = createAction(
|
|
|
|
player,
|
|
|
|
player,
|
|
|
|
courtBounds(),
|
|
|
|
courtBounds(),
|
|
|
|
headRect,
|
|
|
|
headRect,
|
|
|
@ -768,7 +856,7 @@ function CourtPlayerArrowAction({
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isBallOnCourt(content: TacticContent) {
|
|
|
|
function isBallOnCourt(content: StepContent) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
content.components.findIndex(
|
|
|
|
content.components.findIndex(
|
|
|
|
(c) =>
|
|
|
|
(c) =>
|
|
|
@ -782,18 +870,18 @@ function isBallOnCourt(content: TacticContent) {
|
|
|
|
|
|
|
|
|
|
|
|
function renderCourtObject(courtObject: RackedCourtObject) {
|
|
|
|
function renderCourtObject(courtObject: RackedCourtObject) {
|
|
|
|
if (courtObject.key == "ball") {
|
|
|
|
if (courtObject.key == "ball") {
|
|
|
|
return <BallPiece />
|
|
|
|
return <BallPiece/>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new Error("unknown racked court object " + courtObject.key)
|
|
|
|
throw new Error("unknown racked court object " + courtObject.key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function Court({ courtType }: { courtType: string }) {
|
|
|
|
function Court({courtType}: { courtType: string }) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div id="court-image-div">
|
|
|
|
<div id="court-image-div">
|
|
|
|
{courtType == "PLAIN" ? (
|
|
|
|
{courtType == "PLAIN" ? (
|
|
|
|
<PlainCourt id="court-image" />
|
|
|
|
<PlainCourt id="court-image"/>
|
|
|
|
) : (
|
|
|
|
) : (
|
|
|
|
<HalfCourt id="court-image" />
|
|
|
|
<HalfCourt id="court-image"/>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|