add world parameter to router
This commit is contained in:
@@ -31,6 +31,7 @@ function Level() {
|
||||
|
||||
const params = useParams();
|
||||
const levelId = parseInt(params.levelId)
|
||||
const worldId = params.worldId
|
||||
|
||||
const [tacticDocs, setTacticDocs] = useState([])
|
||||
const [lemmaDocs, setLemmaDocs] = useState([])
|
||||
@@ -105,7 +106,7 @@ function Level() {
|
||||
return () => { editor.dispose() }
|
||||
}, [])
|
||||
|
||||
const uri = `file:///level${levelId}`
|
||||
const uri = `file:///${worldId}/${levelId}`
|
||||
|
||||
// The next function will be called when the level changes
|
||||
useEffect(() => {
|
||||
@@ -122,7 +123,7 @@ function Level() {
|
||||
new AbbreviationRewriter(new AbbreviationProvider(), model, editor)
|
||||
|
||||
|
||||
leanClient.sendRequest("loadLevel", {world: "TestWorld", level: levelId}).then((res) => {
|
||||
leanClient.sendRequest("loadLevel", {world: worldId, level: levelId}).then((res) => {
|
||||
// setLevelTitle("Level " + res["index"] + ": " + res["title"])
|
||||
// setIndex(parseInt(res["index"]))
|
||||
setTacticDocs(res["tactics"])
|
||||
|
||||
@@ -91,7 +91,7 @@ function Welcome() {
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box textAlign='center' sx={{ m: 5 }}>
|
||||
<Button component={RouterLink} to="/level/1" variant="contained">Start rescue mission</Button>
|
||||
<Button component={RouterLink} to="/world/TestWorld/level/1" variant="contained">Start rescue mission</Button>
|
||||
</Box>
|
||||
<div ref={worldsRef} style={{"width": "100%","height": "50em"}} />
|
||||
</div>
|
||||
|
||||
@@ -29,7 +29,7 @@ const router = createHashRouter([
|
||||
element: <Welcome />,
|
||||
},
|
||||
{
|
||||
path: "/level/:levelId",
|
||||
path: "/world/:worldId/level/:levelId",
|
||||
element: <Level />,
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user