diff --git a/client/src/components/Level.tsx b/client/src/components/Level.tsx index 254f4ef..7f4437b 100644 --- a/client/src/components/Level.tsx +++ b/client/src/components/Level.tsx @@ -61,6 +61,17 @@ function Level() { const levelId = parseInt(params.levelId) const worldId = params.worldId + useLoadWorldFiles(worldId) + + if (levelId == 0) { + return + } else { + return + } +} + + +function PlayableLevel({worldId, levelId}) { const codeviewRef = useRef(null) const introductionPanelRef = useRef(null) @@ -115,8 +126,6 @@ function Level() { const gameInfo = useGetGameInfoQuery() - useLoadWorldFiles(worldId) - const level = useLoadLevelQuery({world: worldId, level: levelId}) const dispatch = useAppDispatch() @@ -134,33 +143,8 @@ function Level() { const [inventoryDoc, setInventoryDoc] = useState<{name: string, type: string}>(null) - // TODO: This is a hack for having an introduction (i.e. level 0) - // for each world. - if (levelId == 0) { - return <> -
- -
-
- - - {gameInfo.data?.worlds.nodes[worldId].introduction} - - -
-
-
- {levelId >= gameInfo.data?.worldSize[worldId] ? - : - } -
-
- - } - const levelTitle = <>{levelId && `Level ${levelId}`}{level?.data?.title && `: ${level?.data?.title}`} + return <>
@@ -215,8 +199,32 @@ function Level() { export default Level +function Introduction({worldId}) { + const gameInfo = useGetGameInfoQuery() + + return <> +
+ +
+
+ + + {gameInfo.data?.worlds.nodes[worldId].introduction} + + +
+
+ {0 == gameInfo.data?.worldSize[worldId] ? + : + } +
+
+ +} -function LevelAppBar ({isLoading, levelId, worldId, levelTitle}) { +function LevelAppBar({isLoading, levelId, worldId, levelTitle}) { const gameInfo = useGetGameInfoQuery() return