Skip to content

Commit 315cd8e

Browse files
committed
Fixes
- Hopefully fixed #45 by making error catching set exportInProgress flag to false - Fixed #46, and #31
1 parent e360f57 commit 315cd8e

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

src/animatedJava.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const ANIMATED_JAVA = {
6262
store: store,
6363
format: modelFormat,
6464
registerSettingRenderer,
65+
exportInProgress: false,
6566
get variants() {
6667
return store.get('states')
6768
},
@@ -74,6 +75,7 @@ const ANIMATED_JAVA = {
7475
},
7576
asyncError(e: Error) {
7677
showUnknownErrorDialog(e)
78+
ANIMATED_JAVA.exportInProgress = false
7779
throw e
7880
// console.error('CUSTOM ERROR HANDLING', e)
7981
},

src/exporters/statueExporter.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface statueExporterSettings {
2020
boneType: 'aecStack' | 'armorStand'
2121
internalScoreboardObjective: string
2222
idScoreboardObjective: string
23-
exportMode: 'datapack' | 'mcb'
23+
exportMode: 'vanilla' | 'mcb'
2424
mcbFilePath: string | undefined
2525
dataPackPath: string | undefined
2626
markerArmorStands: boolean
@@ -421,6 +421,10 @@ async function exportDataPack(
421421
})
422422
}
423423

424+
const translatedCompilationText = tl(
425+
'animatedJava_exporter_statueExporter.exportingDataPackProgress'
426+
)
427+
424428
function onMessage(message: {
425429
type: 'progress' | 'EVT' | 'ERR' | 'INF' | 'TSK'
426430
msg?: string
@@ -432,14 +436,9 @@ async function exportDataPack(
432436
if (message.type === 'progress') {
433437
Blockbench.setProgress(message.percent, 50)
434438
Blockbench.setStatusBarText(
435-
format(
436-
tl(
437-
'animatedJava_exporter_statueExporter.exportingDataPackProgress'
438-
),
439-
{
440-
progress: (message.percent * 100).toPrecision(4),
441-
}
442-
)
439+
format(translatedCompilationText, {
440+
progress: (message.percent * 100).toPrecision(4),
441+
})
443442
)
444443
}
445444
}
@@ -451,6 +450,7 @@ async function exportDataPack(
451450
onMessage
452451
)
453452
let fileQueue = []
453+
console.log('Vanilla Data Pack:', dataPack)
454454

455455
Blockbench.setProgress(0, 0)
456456
Blockbench.setStatusBarText()
@@ -467,7 +467,7 @@ async function exportDataPack(
467467

468468
const dataPackPath = exporterSettings.dataPackPath
469469
const totalFiles = dataPack.length
470-
const tldMessage = tl(
470+
const translatedWritingText = tl(
471471
'animatedJava_exporter_statueExporter.writingDataPackProgress'
472472
)
473473
const createdPaths = new Set()
@@ -478,7 +478,7 @@ async function exportDataPack(
478478
if (!timeOut) {
479479
Blockbench.setProgress(cur / max, 50)
480480
Blockbench.setStatusBarText(
481-
format(tldMessage, {
481+
format(translatedWritingText, {
482482
progress: ((cur / max) * 100).toPrecision(4),
483483
fileName,
484484
})
@@ -542,7 +542,7 @@ async function statueExport(data: any) {
542542
case 'mcb':
543543
await exportMCFile(generated, data.settings, exporterSettings)
544544
break
545-
case 'datapack':
545+
case 'vanilla':
546546
await exportDataPack(generated, data.settings, exporterSettings)
547547
break
548548
}

src/lang/en.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ animatedJava.dialog.miscError.body: |-
6464

6565
animatedJava.exportCancelled: Export Cancelled
6666

67+
animatedJava.error.exportInProgress: Export in Progress
68+
6769
animatedJava.customErrorReport.titleUndefined: Unknown Error
6870

6971
animatedJava.popup.error.unableToGenerateTexturePath.title: Invalid texture path

src/mainEntry.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,15 @@ import lang_zh_tw from './lang/zh_tw.yaml'
7878
intl.register('zh_tw', lang_zh_tw)
7979
import { makeArmorStandModel } from './makeArmorStandModel'
8080

81-
let F_IS_BUILDING = false
8281
export const BuildModel = (callback: any, options: any) => {
83-
if (!F_IS_BUILDING) {
84-
F_IS_BUILDING = true
82+
if (!ANIMATED_JAVA.exportInProgress) {
83+
ANIMATED_JAVA.exportInProgress = true
8584
computeAnimationData(callback, options)
8685
.then(() => {
87-
F_IS_BUILDING = false
86+
ANIMATED_JAVA.exportInProgress = false
8887
})
8988
.catch((e) => {
90-
F_IS_BUILDING = false
89+
ANIMATED_JAVA.exportInProgress = false
9190
Blockbench.setProgress(0)
9291
if (
9392
e instanceof CustomError &&
@@ -106,7 +105,7 @@ export const BuildModel = (callback: any, options: any) => {
106105
}
107106
})
108107
} else {
109-
Blockbench.showQuickMessage(tl('error.build_in_progress'))
108+
Blockbench.showQuickMessage(tl('animatedJava.error.exportInProgress'))
110109
ERROR.ANIMATED_JAVA_BUSY()
111110
}
112111
}

src/typings/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as THREE from 'three'
22
declare global {
33
var AJ: any
4+
const ANIMATED_JAVA: any
45
var THREE: typeof import('three')
56
var konsole: Console
67
// var NodePreviewController: any

0 commit comments

Comments
 (0)