Skip to content

Commit

Permalink
chore:remove sceneIndex & add costume's config in backdrop
Browse files Browse the repository at this point in the history
  • Loading branch information
luoliwoshang committed Feb 19, 2024
1 parent 3d96349 commit 871e8ba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 47 deletions.
41 changes: 2 additions & 39 deletions spx-gui/src/class/backdrop.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: TuGitee [email protected]
* @Date: 2024-01-19 21:53:50
* @LastEditors: xuning [email protected]
* @LastEditTime: 2024-02-06 12:52:11
* @LastEditors: Zhang Zhi Yang
* @LastEditTime: 2024-02-19 09:10:03
* @FilePath: /spx-gui/src/class/backdrop.ts
* @Description: The class of a backdrop.
*/
Expand Down Expand Up @@ -122,46 +122,9 @@ export class Backdrop extends AssetBase {
"path": file.name
})),
"zorder": useProjectStore().project?.sprite.list.map(sprite => sprite.name) || [],
"sceneIndex": 0
}
}

/**
* Get the current scene index.
*/
get currentSceneIndex(): number {
return this.config.sceneIndex ?? 0
}

/**
* Set the current scene index.
*/
set currentSceneIndex(index: number) {
if (!this.config.scenes[index]) {
throw new Error(`Scene ${index} does not exist.`)
}
this.config.sceneIndex = index
}

/**
* Get the current scene.
*/
get currentScene() {
return this.config.scenes[this.currentSceneIndex]
}

/**
* Get the current scene with config.
*/
get currentSceneConfig(): Scene {
const scene = this.currentScene
return Object.assign({}, scene, {
index: this.currentSceneIndex,
file: this.files[this.currentSceneIndex],
url: this.files[this.currentSceneIndex].url
})
}

/**
* Get the directory of the backdrop.
*/
Expand Down
5 changes: 3 additions & 2 deletions spx-gui/src/components/stage-viewer-demo/StageViewerDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* @Description:
-->
<template>
<input type="file" @change="add" accept=".zip">
<div style="display: flex;">
<div>
<input type="file" @change="add" accept=".zip">
<p>show in stage viewer</p>
<template v-for="sprite in sprites" :key="sprite.name">
<button :style="currentSpriteNames.includes(sprite.name) ? { color: 'blue' } : {}"
Expand Down Expand Up @@ -44,7 +44,8 @@
@update:value="(val) => { currentSprite && currentSprite.setCy(val as number) }"></n-input-number>
<n-switch v-model:value="visible" @update:value="(val) => { currentSprite && currentSprite.setVisible(val) }" />
</div>
<StageViewer @onSpritesDragEnd="onDragEnd" :currentSpriteNames="currentSpriteNames" :project="(project as Project)" />
<StageViewer @onSpritesDragEnd="onDragEnd" :currentSpriteNames="currentSpriteNames"
:project="(project as Project)" />
</div>
</template>
<script setup lang="ts">
Expand Down
18 changes: 12 additions & 6 deletions spx-gui/src/interface/file.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* @Author: TuGitee [email protected]
* @Date: 2024-01-24 21:42:28
* @LastEditors: TuGitee [email protected]
* @LastEditTime: 2024-01-25 14:32:14
* @FilePath: \builder\spx-gui\src\interface\file.ts
* @LastEditors: Zhang Zhi Yang
* @LastEditTime: 2024-02-19 09:05:07
* @FilePath: /spx-gui/src/interface/file.ts
* @Description: The interface of file.
*/

Expand Down Expand Up @@ -164,15 +164,21 @@ export interface BackdropConfig extends Config {
/**
* The image of the backdrop.
*/
scenes: Scene[];
scenes?: Scene[];

/**
* The sprite zorder in the stage, the later Sprite will be above the previous Sprite, which means that the later Sprite will override the previous Sprite.
*/
zorder: string[];

/**
* The index of the current scene.
* The costume of the backdrop
*/
sceneIndex?: number;
costumes?: Costume[];

/**
* The index of the current costume.
*/
currentCostumeIndex?: number;

}

0 comments on commit 871e8ba

Please sign in to comment.