pull/118/head
Jon Eugster 2 years ago
parent bd8c857539
commit 593ca10720

@ -47,13 +47,11 @@ function Level() {
const params = useParams() const params = useParams()
const levelId = parseInt(params.levelId) const levelId = parseInt(params.levelId)
const worldId = params.worldId const worldId = params.worldId
useLoadWorldFiles(worldId) useLoadWorldFiles(worldId)
return <WorldLevelIdContext.Provider value={{worldId, levelId}}> return <WorldLevelIdContext.Provider value={{worldId, levelId}}>
{levelId == 0 ? <Introduction /> : <PlayableLevel />} {levelId == 0 ? <Introduction /> : <PlayableLevel />}
</WorldLevelIdContext.Provider> </WorldLevelIdContext.Provider>
} }
function ChatPanel({lastLevel}) { function ChatPanel({lastLevel}) {
@ -105,7 +103,6 @@ function ChatPanel({lastLevel}) {
console.debug(`help: ${Array.from(tmp.values())}`) console.debug(`help: ${Array.from(tmp.values())}`)
} }
useEffect(() => { useEffect(() => {
// TODO: For some reason this is always called twice // TODO: For some reason this is always called twice
console.debug('scroll chat') console.debug('scroll chat')
@ -129,7 +126,6 @@ function ChatPanel({lastLevel}) {
// // chatRef.current!.scrollTo(0,0) // // chatRef.current!.scrollTo(0,0)
// }, [gameId, worldId, levelId]) // }, [gameId, worldId, levelId])
return <div className="chat-panel"> return <div className="chat-panel">
<div ref={chatRef} className="chat"> <div ref={chatRef} className="chat">
{level?.data?.introduction && {level?.data?.introduction &&
@ -196,6 +192,15 @@ function PlayableLevel() {
const codeviewRef = useRef<HTMLDivElement>(null) const codeviewRef = useRef<HTMLDivElement>(null)
const gameId = React.useContext(GameIdContext) const gameId = React.useContext(GameIdContext)
const {worldId, levelId} = useContext(WorldLevelIdContext) const {worldId, levelId} = useContext(WorldLevelIdContext)
const {mobile} = React.useContext(MobileContext)
const difficulty = useSelector(selectDifficulty(gameId))
const initialCode = useAppSelector(selectCode(gameId, worldId, levelId))
const initialSelections = useAppSelector(selectSelections(gameId, worldId, levelId))
const inventory: Array<String> = useSelector(selectInventory(gameId))
const gameInfo = useGetGameInfoQuery({game: gameId})
const level = useLoadLevelQuery({game: gameId, world: worldId, level: levelId})
// The state variables for the `ProofContext` // The state variables for the `ProofContext`
const [proof, setProof] = useState<Array<ProofStep>>([]) const [proof, setProof] = useState<Array<ProofStep>>([])
@ -204,18 +209,11 @@ function PlayableLevel() {
const [deletedChat, setDeletedChat] = useState<Array<GameHint>>([]) const [deletedChat, setDeletedChat] = useState<Array<GameHint>>([])
// A set of row numbers where help is displayed // A set of row numbers where help is displayed
const [showHelp, setShowHelp] = useState<Set<number>>(new Set()) const [showHelp, setShowHelp] = useState<Set<number>>(new Set())
const initialCode = useAppSelector(selectCode(gameId, worldId, levelId)) // Only for mobile layout
const initialSelections = useAppSelector(selectSelections(gameId, worldId, levelId))
/** Only for mobile layout */
const [pageNumber, setPageNumber] = useState(0) const [pageNumber, setPageNumber] = useState(0)
const {mobile} = React.useContext(MobileContext)
const [commandLineMode, setCommandLineMode] = useState(true) const [commandLineMode, setCommandLineMode] = useState(true)
const [commandLineInput, setCommandLineInput] = useState("") const [commandLineInput, setCommandLineInput] = useState("")
const difficulty = useSelector(selectDifficulty(gameId))
const inventory: Array<String> = useSelector(selectInventory(gameId))
const gameInfo = useGetGameInfoQuery({game: gameId})
const lastLevel = levelId >= gameInfo.data?.worldSize[worldId] const lastLevel = levelId >= gameInfo.data?.worldSize[worldId]
const level = useLoadLevelQuery({game: gameId, world: worldId, level: levelId})
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
// impressum pop-up // impressum pop-up

Loading…
Cancel
Save