add a way to disable prompts on load
This commit is contained in:
parent
3daefc23de
commit
32482d87dc
4 changed files with 9 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ import { fsState, loadSave } from './loadSave'
|
|||
import { oneOf } from '@zardoy/utils'
|
||||
import JSZip from 'jszip'
|
||||
import { join } from 'path'
|
||||
import { options } from './optionsStorage'
|
||||
|
||||
const { promisify } = require('util')
|
||||
const browserfs = require('browserfs')
|
||||
|
|
@ -124,10 +125,10 @@ export const openWorldDirectory = async (/** @type {FileSystemDirectoryHandle?}
|
|||
}
|
||||
const directoryHandle = _directoryHandle
|
||||
|
||||
const requestResult = SUPPORT_WRITE ? await directoryHandle.requestPermission?.({ mode: 'readwrite' }) : undefined
|
||||
const requestResult = SUPPORT_WRITE && !options.preferLoadReadonly ? await directoryHandle.requestPermission?.({ mode: 'readwrite' }) : undefined
|
||||
const writeAccess = requestResult === 'granted'
|
||||
|
||||
const doContinue = writeAccess || !SUPPORT_WRITE || confirm('Continue in readonly mode?')
|
||||
const doContinue = writeAccess || !SUPPORT_WRITE || options.disableLoadPrompts || confirm('Continue in readonly mode?')
|
||||
if (!doContinue) return
|
||||
await new Promise(resolve => {
|
||||
browserfs.configure({
|
||||
|
|
|
|||
|
|
@ -384,7 +384,6 @@ async function connect (connectOptions) {
|
|||
|
||||
setLoadingScreenStatus('Starting local server')
|
||||
window.serverDataChannel ??= {}
|
||||
window.worldLoaded = false
|
||||
localServer = window.localServer = startLocalServer()
|
||||
// todo need just to call quit if started
|
||||
// loadingScreen.maybeRecoverable = false
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ export const fsState = proxy({
|
|||
const PROPOSE_BACKUP = true
|
||||
|
||||
export const loadSave = async (root = '/world') => {
|
||||
const disablePrompts = options.disableLoadPrompts
|
||||
|
||||
// todo do it in singleplayer as well
|
||||
for (const key in forceCachedDataPaths) {
|
||||
delete forceCachedDataPaths[key]
|
||||
|
|
@ -50,7 +52,7 @@ export const loadSave = async (root = '/world') => {
|
|||
const qs = new URLSearchParams(window.location.search)
|
||||
version = levelDat.Version?.Name ?? qs.get('version')
|
||||
if (!version) {
|
||||
const newVersion = prompt(`In 1.8 and before world save doesn\'t contain version info, please enter version you want to use to load the world.\nSupported versions ${supportedVersions.join(', ')}`, '1.8.8')
|
||||
const newVersion = disablePrompts ? '1.8.8' : prompt(`In 1.8 and before world save doesn\'t contain version info, please enter version you want to use to load the world.\nSupported versions ${supportedVersions.join(', ')}`, '1.8.8')
|
||||
if (!newVersion) return
|
||||
version = newVersion
|
||||
}
|
||||
|
|
@ -89,7 +91,7 @@ export const loadSave = async (root = '/world') => {
|
|||
|
||||
}
|
||||
|
||||
if (warnings.length) {
|
||||
if (warnings.length && !disablePrompts) {
|
||||
const doContinue = confirm(`Continue with following warnings?\n${warnings.join('\n')}`)
|
||||
if (!doContinue) return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ const defaultOptions = {
|
|||
numWorkers: 4,
|
||||
localServerOptions: {},
|
||||
localUsername: 'wanderer',
|
||||
preferLoadReadonly: false,
|
||||
disableLoadPrompts: false
|
||||
}
|
||||
|
||||
export const options = proxy(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue