Skip to content

Commit

Permalink
[to pick] customize gamemode from menu!
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Apr 11, 2024
1 parent 4f9efb4 commit 830424e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions prismarine-viewer/examples/newStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const addNewStat = (id: string, width = 80, x = rightOffset, y = 0) => {
pane.style.fontFamily = 'monospace'
pane.style.fontSize = '12px'
pane.style.zIndex = '10000'
pane.style.pointerEvents = 'none'
document.body.appendChild(pane)
stats[id] = pane
if (y === 0) { // otherwise it's a custom position
Expand Down
14 changes: 11 additions & 3 deletions src/react/CreateWorld.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ import styles from './createWorld.module.css'

// const worldTypes = ['default', 'flat', 'largeBiomes', 'amplified', 'customized', 'buffet', 'debug_all_block_states']
const worldTypes = ['default', 'flat'/* , 'void' */]
const gameModes = ['survival', 'creative'/* , 'adventure', 'spectator' */]

export const creatingWorldState = proxy({
title: '',
type: worldTypes[0],
gameMode: gameModes[0],
version: ''
})

export default ({ cancelClick, createClick, customizeClick, versions, defaultVersion }) => {
const [quota, setQuota] = useState('')

const { title, type, version } = useSnapshot(creatingWorldState)
const { title, type, version, gameMode } = useSnapshot(creatingWorldState)
useEffect(() => {
creatingWorldState.version = defaultVersion
void navigator.storage?.estimate?.().then(({ quota, usage }) => {
Expand Down Expand Up @@ -54,9 +56,15 @@ export default ({ cancelClick, createClick, customizeClick, versions, defaultVer
<Button onClick={() => {
const index = worldTypes.indexOf(type)
creatingWorldState.type = worldTypes[index === worldTypes.length - 1 ? 0 : index + 1]
}}>{type}</Button>
<Button onClick={() => customizeClick()} disabled>
}}>World Type: {type}</Button>
{/* <Button onClick={() => customizeClick()} disabled>
Customize
</Button> */}
<Button onClick={() => {
const index = gameModes.indexOf(gameMode)
creatingWorldState.gameMode = gameModes[index === gameModes.length - 1 ? 0 : index + 1]
}}>
Gamemode: {gameMode}
</Button>
</div>
<div className='muted' style={{ fontSize: 8 }}>Default and other world types are WIP</div>
Expand Down
4 changes: 2 additions & 2 deletions src/react/CreateWorldProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default () => {
}}
createClick={async () => {
// create new world
const { title, type, version } = creatingWorldState
const { title, type, version, gameMode } = creatingWorldState
// todo display path in ui + disable if exist
const savePath = await uniqueFileNameFromWorldName(title, getWorldsPath())
await mkdirRecursive(savePath)
Expand Down Expand Up @@ -52,7 +52,7 @@ export default () => {
version,
generation,
'worldFolder': savePath,
gameMode: 0,
gameMode: gameMode === 'survival' ? 0 : 1,
},
}))
}}
Expand Down

0 comments on commit 830424e

Please sign in to comment.