Merge branch 'main' into story

pull/43/head
Alexander Bentkamp 2 years ago
commit 4158283eb3

@ -22,7 +22,7 @@ import './level.css'
import { Button } from './Button' import { Button } from './Button'
import { ConnectionContext, useLeanClient } from '../connection'; import { ConnectionContext, useLeanClient } from '../connection';
import { useGetGameInfoQuery, useLoadLevelQuery } from '../state/api'; import { useGetGameInfoQuery, useLoadLevelQuery } from '../state/api';
import { codeEdited, selectCode, progressSlice } from '../state/progress'; import { codeEdited, selectCode, progressSlice, selectCompleted } from '../state/progress';
import { useAppDispatch, useAppSelector } from '../hooks'; import { useAppDispatch, useAppSelector } from '../hooks';
import { useStore } from 'react-redux'; import { useStore } from 'react-redux';
@ -126,6 +126,7 @@ function Level() {
setCanUndo(code.trim() !== "") setCanUndo(code.trim() !== "")
} }
const completed = useAppSelector(selectCompleted(worldId, levelId))
const {editor, infoProvider, editorConnection} = const {editor, infoProvider, editorConnection} =
useLevelEditor(worldId, levelId, codeviewRef, initialCode, onDidChangeContent) useLevelEditor(worldId, levelId, codeviewRef, initialCode, onDidChangeContent)
@ -179,6 +180,8 @@ function Level() {
</InputModeContext.Provider> </InputModeContext.Provider>
</MonacoEditorContext.Provider> </MonacoEditorContext.Provider>
</EditorContext.Provider> </EditorContext.Provider>
{completed && <div className="conclusion"><Markdown>{level?.data?.conclusion}</Markdown></div>}
</div> </div>
<div className="doc-panel"> <div className="doc-panel">
{!level.isLoading && <Inventory tactics={level?.data?.tactics} lemmas={level?.data?.lemmas} definitions={level?.data?.definitions} />} {!level.isLoading && <Inventory tactics={level?.data?.tactics} lemmas={level?.data?.lemmas} definitions={level?.data?.definitions} />}

@ -43,6 +43,10 @@
padding: 1em; padding: 1em;
} }
.conclusion {
padding: 1em;
}
.exercise { .exercise {
flex: 1 1 auto; flex: 1 1 auto;
display: flex; display: flex;

@ -20,6 +20,7 @@ export interface ComputedInventoryItem {
interface LevelInfo { interface LevelInfo {
title: null|string, title: null|string,
introduction: null|string, introduction: null|string,
conclusion: null|string,
index: number, index: number,
tactics: ComputedInventoryItem[], tactics: ComputedInventoryItem[],
lemmas: ComputedInventoryItem[], lemmas: ComputedInventoryItem[],

@ -46,6 +46,7 @@ structure LevelInfo where
lemmas : Array ComputedInventoryItem lemmas : Array ComputedInventoryItem
definitions : Array ComputedInventoryItem definitions : Array ComputedInventoryItem
introduction : String introduction : String
conclusion : String
descrText : String := "" descrText : String := ""
descrFormat : String := "" descrFormat : String := ""
deriving ToJson, FromJson deriving ToJson, FromJson
@ -125,7 +126,8 @@ partial def handleServerEvent (ev : ServerEvent) : GameServerM Bool := do
definitions := lvl.definitions.computed, definitions := lvl.definitions.computed,
descrText := lvl.descrText, descrText := lvl.descrText,
descrFormat := lvl.descrFormat --toExpr <| format (lvl.goal.raw) --toString <| Syntax.formatStx (lvl.goal.raw) --Syntax.formatStx (lvl.goal.raw) , -- TODO descrFormat := lvl.descrFormat --toExpr <| format (lvl.goal.raw) --toString <| Syntax.formatStx (lvl.goal.raw) --Syntax.formatStx (lvl.goal.raw) , -- TODO
introduction := lvl.introduction } introduction := lvl.introduction
conclusion := lvl.conclusion }
c.hOut.writeLspResponse ⟨id, ToJson.toJson levelInfo⟩ c.hOut.writeLspResponse ⟨id, ToJson.toJson levelInfo⟩
return true return true
| Message.request id "loadDoc" params => | Message.request id "loadDoc" params =>

Loading…
Cancel
Save