mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-25 16:16:50 +00:00
Update spyglass to better support resource packs
This commit is contained in:
@@ -38,7 +38,8 @@ export function FileCreation({ docAndNode, gen, method }: Props) {
|
||||
return
|
||||
}
|
||||
const id = Identifier.parse(fileId.includes(':') || project.namespace === undefined ? fileId : `${project.namespace}:${fileId}`)
|
||||
const uri = `${getProjectRoot(project)}data/${id.namespace}/${genPath(gen, version)}/${id.path}.json`
|
||||
const pack = gen.tags?.includes('assets') ? 'assets' : 'data'
|
||||
const uri = `${getProjectRoot(project)}${pack}/${id.namespace}/${genPath(gen, version)}/${id.path}.json`
|
||||
Analytics.saveProjectFile(method)
|
||||
const text = docAndNode.doc.getText()
|
||||
client.fs.writeFile(uri, text).then(() => {
|
||||
|
||||
@@ -72,7 +72,7 @@ export function ProjectPanel() {
|
||||
const res = service?.dissectUri(uri)
|
||||
if (res?.ok) {
|
||||
// This is pretty hacky, improve this in the future when spyglass has a "constructUri" function
|
||||
const oldSuffix = `/${res.namespace}/${res.path}/${res.identifier}${res.ext}`
|
||||
const oldSuffix = `${res.pack}/${res.namespace}/${res.path}/${res.identifier}${res.ext}`
|
||||
if (!uri.endsWith(oldSuffix)) {
|
||||
console.warn(`Expected ${uri} to end with ${oldSuffix}`)
|
||||
return
|
||||
@@ -80,7 +80,7 @@ export function ProjectPanel() {
|
||||
const onRename = (newId: string) => {
|
||||
const prefix = uri.substring(0, uri.length - oldSuffix.length)
|
||||
const { namespace, path } = Identifier.parse(newId)
|
||||
const newUri = prefix + `/${namespace}/${res.path}/${path}${res.ext}`
|
||||
const newUri = prefix + `${res.pack}/${namespace}/${res.path}/${path}${res.ext}`
|
||||
service?.renameFile(uri, newUri).then(() => {
|
||||
setProjectUri(newUri)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user