Skip to content

Commit 4dfd011

Browse files
committed
The beginning of an export progress dialog
1 parent 92e4ae1 commit 4dfd011

File tree

5 files changed

+64
-5
lines changed

5 files changed

+64
-5
lines changed

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { addTranslations, translate } from './util/translation'
4848
import * as VirtualFileSystem from './util/virtualFileSystem'
4949
import { openUnexpectedErrorDialog } from './ui/popups/unexpectedError'
5050
import * as minecraft from './minecraft'
51+
import { openAJExportInProgressDialog } from './ui/ajExportInProgress'
5152

5253
Prism.languages.mcfunction = {}
5354

@@ -70,6 +71,7 @@ globalThis.AnimatedJava = {
7071
// Expose this plugin's events to other plugins
7172
events,
7273
openUnexpectedErrorDialog,
74+
openAJExportInProgressDialog,
7375

7476
API: {
7577
Settings: AJSettings,

src/lang/en.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ animated_java.dialog.close_button: Done
1919
### About
2020
animated_java.dialog.about.title: About Animated Java
2121

22+
### Export in Progress
23+
animated_java.dialog.export_in_progress.title: Exporting Project...
24+
2225
### Settings
2326
animated_java.settings.accessability_options_group: Accessability
2427

src/ui/ajExportInProgress.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { translate } from '../util/translation'
2+
import { SvelteDialog } from './util/svelteDialog'
3+
import ExportInProgressComponent from './components/exportInProgress.svelte'
4+
5+
export function openAJExportInProgressDialog() {
6+
const dialog = new SvelteDialog({
7+
title: translate('animated_java.dialog.export_in_progress.title'),
8+
id: 'animated_java:export_in_progress',
9+
width: 600,
10+
buttons: [],
11+
svelteComponent: ExportInProgressComponent,
12+
svelteComponentProps: {},
13+
}).show()
14+
open_interface = {} as Dialog
15+
return dialog
16+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<script lang="ts" context="module">
2+
import { tweened } from 'svelte/motion'
3+
import { cubicOut } from 'svelte/easing'
4+
</script>
5+
6+
<script lang="ts">
7+
import { onDestroy } from 'svelte'
8+
9+
jQuery('.dialog_close_button').remove()
10+
11+
const progress = tweened(0, {
12+
duration: 100,
13+
easing: cubicOut,
14+
})
15+
16+
const interval = setInterval(() => {
17+
// @ts-ignore
18+
progress.set(Prop.progress)
19+
}, 16)
20+
21+
onDestroy(() => {
22+
clearInterval(interval)
23+
})
24+
</script>
25+
26+
<div class="progress-bar-container">
27+
<progress value={$progress} />
28+
</div>
29+
30+
<style>
31+
.progress-bar-container {
32+
display: flex;
33+
flex-direction: row;
34+
align-items: center;
35+
}
36+
progress {
37+
flex-grow: 1;
38+
}
39+
</style>

src/ui/util/svelteDialog.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export class SvelteDialog extends Dialog {
2626
this.onOpen = () => {
2727
const parentElement = mount.parentElement
2828
if (this.instance || !parentElement) return
29-
// console.log('onOpen')
3029
parentElement.style.overflow = 'visible'
3130
this.instance = new options.svelteComponent({
3231
target: parentElement,
@@ -43,19 +42,19 @@ export class SvelteDialog extends Dialog {
4342
this.onButton = (...args) => {
4443
if (!this.instance) return
4544
// console.log('onButton')
46-
this.instance.$destroy()
47-
this.instance = undefined
4845
if (super.onButton) super.onButton(...args)
4946
if (options.onClose) options.onClose()
47+
this.instance.$destroy()
48+
this.instance = undefined
5049
}
5150

5251
this.onCancel = (...args) => {
5352
if (!this.instance) return
5453
// console.log('onCancel')
55-
this.instance.$destroy()
56-
this.instance = undefined
5754
if (super.onCancel) super.onCancel(...args)
5855
if (options.onClose) options.onClose()
56+
this.instance.$destroy()
57+
this.instance = undefined
5958
}
6059
}
6160
}

0 commit comments

Comments
 (0)