diff --git a/client/src/components/Level.tsx b/client/src/components/Level.tsx index 7c9cea0..6f2cea9 100644 --- a/client/src/components/Level.tsx +++ b/client/src/components/Level.tsx @@ -42,8 +42,20 @@ import Split from 'react-split' import { Alert } from '@mui/material'; import { GameIdContext } from '../App'; +import { GameHint } from './infoview/rpcApi'; + export const MonacoEditorContext = React.createContext(null as any); +// TODO: Not used yet +export const HintContext = React.createContext<{ + hints: Array, + setHints: React.Dispatch>> +}>({ + hints: [], + setHints: () => {}, +}); + + export const InputModeContext = React.createContext<{ commandLineMode: boolean, setCommandLineMode: React.Dispatch>, @@ -74,7 +86,7 @@ function Level() { function PlayableLevel({worldId, levelId}) { const codeviewRef = useRef(null) - const introductionPanelRef = useRef(null) + const chatPanelRef = useRef(null) const gameId = React.useContext(GameIdContext) const initialCode = useAppSelector(selectCode(gameId, worldId, levelId)) @@ -84,12 +96,17 @@ function PlayableLevel({worldId, levelId}) { const [commandLineInput, setCommandLineInput] = useState("") const [canUndo, setCanUndo] = useState(initialCode.trim() !== "") + // The array of all shown hints. This excludes introduction and conclusion + // TODO: Not used yet + const [hints, setHints] = useState(Array) + const theme = useTheme(); useEffect(() => { // Scroll to top when loading a new level - introductionPanelRef.current!.scrollTo(0,0) + // TODO: Thats the wrong behaviour probably + chatPanelRef.current!.scrollTo(0,0) // Reset command line input when loading a new level setCommandLineInput("") }, [levelId]) @@ -179,15 +196,35 @@ function PlayableLevel({worldId, levelId}) { return <>
- -
-
- {level?.data?.introduction && + +
+ {level?.data?.introduction && +
+ {level?.data?.introduction} +
+ } + {hints.map(hint => +
{hint.text}
) + } + {completed && + <>
- {level?.data?.introduction} + Level completed! 🎉
- } -
+ {level?.data?.conclusion?.trim() && +
+ {level?.data?.conclusion} +
+ } + { hints.map(hint =>
{hint.text}
) } + {levelId >= gameInfo.data?.worldSize[worldId] ? + : + } + + } +
+
{(level?.data?.statementName ? @@ -207,34 +244,23 @@ function PlayableLevel({worldId, levelId}) {
+ {editorConnection &&
} - - - {completed &&
- {level?.data?.conclusion?.trim() && -
- {level?.data?.conclusion} -
- } - {levelId >= gameInfo.data?.worldSize[worldId] ? - : - } - -
} + +
{!level.isLoading && }
-
+ {/*
{inventoryDoc && } -
+
*/} } diff --git a/client/src/components/infoview/hints.tsx b/client/src/components/infoview/hints.tsx index 1e7816d..c9df021 100644 --- a/client/src/components/infoview/hints.tsx +++ b/client/src/components/infoview/hints.tsx @@ -3,7 +3,7 @@ import * as React from 'react'; import { Alert, FormControlLabel, Switch } from '@mui/material'; import Markdown from '../Markdown'; -function Hint({hint} : {hint: GameHint}) { +export function Hint({hint} : {hint: GameHint}) { return
{hint.text}
} diff --git a/client/src/components/infoview/info.tsx b/client/src/components/infoview/info.tsx index 68fa254..6c4c97a 100644 --- a/client/src/components/infoview/info.tsx +++ b/client/src/components/infoview/info.tsx @@ -17,7 +17,7 @@ import { RpcContext, useRpcSessionAtPos } from '../../../../node_modules/lean4-i import { GoalsLocation, Locations, LocationsContext } from '../../../../node_modules/lean4-infoview/src/infoview/goalLocation'; import { InteractiveCode } from '../../../../node_modules/lean4-infoview/src/infoview/interactiveCode' import { CircularProgress } from '@mui/material'; -import { InputModeContext, MonacoEditorContext } from '../Level' +import { InputModeContext, MonacoEditorContext, HintContext } from '../Level' type InfoStatus = 'updating' | 'error' | 'ready'; diff --git a/client/src/components/level.css b/client/src/components/level.css index a3a6ba7..e20e344 100644 --- a/client/src/components/level.css +++ b/client/src/components/level.css @@ -29,7 +29,7 @@ overflow: auto; } -.introduction-panel, .infoview, .exercise { +.chat-panel, .infoview, .exercise { padding-top: 1em; padding-left: 1em; padding-right: 1em; @@ -93,12 +93,12 @@ mjx-container[jax="CHTML"][display="true"] { /* Styling tables for Markdown */ -.introduction-panel table, .introduction-panel th, .introduction-panel td { +.chat-panel table, .chat-panel th, .chat-panel td { /* border: 1px solid rgb(0, 0, 0, 0.12); */ border-collapse: collapse; } -.introduction-panel th, .introduction-panel td { +.chat-panel th, .chat-panel td { padding-left: .5em; padding-right: .5em; } @@ -155,7 +155,7 @@ td code { border: 1px solid rgb(230, 122, 0); } -.introduction-panel { +.chat-panel { border: 1px solid rgb(192, 18, 178); }