From b1550a8927166b8b989a2bc33653d2d319aa98dc Mon Sep 17 00:00:00 2001
From: ComfyFluffy <24245520+ComfyFluffy@users.noreply.github.com>
Date: Tue, 7 May 2024 15:34:57 +0800
Subject: [PATCH 1/7] add loading for runner
---
.../project/runner/IframeDisplay.vue | 27 ++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/spx-gui/src/components/project/runner/IframeDisplay.vue b/spx-gui/src/components/project/runner/IframeDisplay.vue
index 93bc6d55a..02af87028 100644
--- a/spx-gui/src/components/project/runner/IframeDisplay.vue
+++ b/spx-gui/src/components/project/runner/IframeDisplay.vue
@@ -1,5 +1,8 @@
-
+
+
+
+
+
+
From c97a0b70ed750b2fe6f2ccc7dbff821ec9543d39 Mon Sep 17 00:00:00 2001
From: ComfyFluffy <24245520+ComfyFluffy@users.noreply.github.com>
Date: Wed, 8 May 2024 21:08:04 +0800
Subject: [PATCH 2/7] loading for sprites/sounds in panel
---
spx-gui/src/components/editor/panels/common/PanelItem.vue | 8 +++++++-
spx-gui/src/components/editor/panels/sound/SoundItem.vue | 8 +++++++-
.../src/components/editor/panels/sprite/SpriteItem.vue | 2 +-
spx-gui/src/components/share/SharePage.vue | 8 ++++++++
4 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/spx-gui/src/components/editor/panels/common/PanelItem.vue b/spx-gui/src/components/editor/panels/common/PanelItem.vue
index f84e64e77..d13a7156d 100644
--- a/spx-gui/src/components/editor/panels/common/PanelItem.vue
+++ b/spx-gui/src/components/editor/panels/common/PanelItem.vue
@@ -7,15 +7,17 @@
+
From 3c7f507d865fa889a529b1a7a23518ded212b7d1 Mon Sep 17 00:00:00 2001
From: ComfyFluffy <24245520+ComfyFluffy@users.noreply.github.com>
Date: Wed, 8 May 2024 22:02:08 +0800
Subject: [PATCH 3/7] stage loading
---
.../preview/stage-viewer/SpriteItem.vue | 10 +++----
.../stage-viewer/SpriteTransformer.vue | 8 +++--
.../preview/stage-viewer/StageViewer.vue | 30 +++++++++++++++----
.../editor/preview/stage-viewer/common.ts | 14 ---------
4 files changed, 33 insertions(+), 29 deletions(-)
delete mode 100644 spx-gui/src/components/editor/preview/stage-viewer/common.ts
diff --git a/spx-gui/src/components/editor/preview/stage-viewer/SpriteItem.vue b/spx-gui/src/components/editor/preview/stage-viewer/SpriteItem.vue
index ff2a9316d..dc79f0e84 100644
--- a/spx-gui/src/components/editor/preview/stage-viewer/SpriteItem.vue
+++ b/spx-gui/src/components/editor/preview/stage-viewer/SpriteItem.vue
@@ -22,12 +22,12 @@ import type { Sprite } from '@/models/sprite'
import type { Size } from '@/models/common'
import { useImgFile } from '@/utils/file'
import { useEditorCtx } from '../../EditorContextProvider.vue'
-import { useSpritesReady } from './common'
import { round } from '@/utils/utils'
const props = defineProps<{
sprite: Sprite
mapSize: Size
+ spritesReadyMap: Map
}>()
const nodeRef = ref()
@@ -36,19 +36,17 @@ const costume = computed(() => props.sprite.costume)
const bitmapResolution = computed(() => costume.value?.bitmapResolution ?? 1)
const image = useImgFile(() => costume.value?.img)
-const spritesReady = useSpritesReady()
-
watchEffect((onCleanup) => {
// We need to notify event ready for SpriteTransformer (to get correct node size)
const name = props.sprite.name
const img = image.value
- onCleanup(() => spritesReady.delete(props.sprite.name))
+ onCleanup(() => props.spritesReadyMap.delete(props.sprite.name))
if (img == null) {
- spritesReady.set(props.sprite.name, false)
+ props.spritesReadyMap.set(props.sprite.name, false)
return
}
function handleImageLoad() {
- spritesReady.set(name, true)
+ props.spritesReadyMap.set(name, true)
}
img.addEventListener('load', handleImageLoad)
onCleanup(() => img.removeEventListener('load', handleImageLoad))
diff --git a/spx-gui/src/components/editor/preview/stage-viewer/SpriteTransformer.vue b/spx-gui/src/components/editor/preview/stage-viewer/SpriteTransformer.vue
index 62d73e285..dbdece1a0 100644
--- a/spx-gui/src/components/editor/preview/stage-viewer/SpriteTransformer.vue
+++ b/spx-gui/src/components/editor/preview/stage-viewer/SpriteTransformer.vue
@@ -7,11 +7,13 @@ import { effect, ref } from 'vue'
import type { Transformer } from 'konva/lib/shapes/Transformer'
import type { Node } from 'konva/lib/Node'
import { useEditorCtx } from '../../EditorContextProvider.vue'
-import { useSpritesReady } from './common'
+
+const props = defineProps<{
+ spritesReadyMap: Map
+}>()
const transformer = ref()
const editorCtx = useEditorCtx()
-const spritesReady = useSpritesReady()
effect(async () => {
if (transformer.value == null) return
@@ -22,7 +24,7 @@ effect(async () => {
return
}
// Wait for sprite ready, so that Konva can get correct node size
- if (!spritesReady.get(sprite.name)) return
+ if (!props.spritesReadyMap.get(sprite.name)) return
const stage = transformerNode.getStage()
if (stage == null) throw new Error('no stage')
const selectedNode = stage.findOne((node: Node) => node.getAttr('spriteName') === sprite.name)
diff --git a/spx-gui/src/components/editor/preview/stage-viewer/StageViewer.vue b/spx-gui/src/components/editor/preview/stage-viewer/StageViewer.vue
index f8a81a024..880197456 100644
--- a/spx-gui/src/components/editor/preview/stage-viewer/StageViewer.vue
+++ b/spx-gui/src/components/editor/preview/stage-viewer/StageViewer.vue
@@ -16,10 +16,11 @@
:key="sprite.name"
:sprite="sprite"
:map-size="mapSize!"
+ :sprites-ready-map="spritesReadyMap"
/>
-
+
@@ -38,14 +39,15 @@
}}
+