scene switcher feature

This commit is contained in:
2025-12-06 09:30:50 +02:00
parent 7397c6dfe7
commit 82c3a0dec8
8 changed files with 228 additions and 67 deletions
+37 -32
View File
@@ -16,12 +16,14 @@
</image>
</g>
</teleport>
<teleport to=".scene-designer .lines" v-if="active && targetScene">
<OffsetLine :x1="targetScene.vd.x1" :y1="targetScene.vd.y1"
:x2="modelValue.__this.vd.x1" :y2="modelValue.__this.vd.y1" :o1="88" :o2="55"
class="scene-switcher" marker-start="url(#arrow)" ></OffsetLine>
</teleport>
<v-card v-if="selected" :title="modelValue.title" class="mx-2" variant="text">
<asset-selector @select="assignGameObject" :type="['GameObject']">
<template v-slot:activator="props">
<v-btn v-bind="props" prepend-icon="mdi-panorama-outline" color="success" block>Choose game object</v-btn>
</template>
</asset-selector>
<v-select label="Game Object Type" v-model="modelValue.type" density="compact" hide-details
:items="InteractiveObjectTypes.map(e=>({title: e.name, value: e.id}))"></v-select>
<v-form class="pt-4">
<v-text-field density="compact" :label="l.name" v-model="modelValue.title"></v-text-field>
<!-- <v-text-field density="compact" :label="l.id" v-model="modelValue.id"></v-text-field> -->
@@ -35,10 +37,10 @@
<v-number-input density="compact" label="Level score should be above" v-model="modelValue.activationScore"></v-number-input>
<v-select density="compact" label="Following elements should be completed" v-model="modelValue.activationTriggers"
:items="parent.data.items.filter(v=>!v.data.exclude && v.data!==modelValue).map(v=>({title: v.data.title, value: v.data.id}))" multiple ></v-select>
<v-select label="Activation Type" :items="activationTypes" density="compact" v-model="modelValue.activationType"></v-select>
</v-card>
</v-card>
</template>
<script>
@@ -52,24 +54,18 @@ import ClassicPuzzle from '../InteractiveObjects/ClassicPuzzle.vue';
import Particles from '../InteractiveObjects/Particles.vue';
import GenericObject from '../InteractiveObjects/GenericObject.vue';
import CharacterObject from '../InteractiveObjects/CharacterObject.vue';
import SceneSwitcher from '../InteractiveObjects/SceneSwitcher.vue';
import OffsetLine from './OffsetLine.vue';
import { InteractiveObjectTypes } from '../InteractiveObjects/InteractiveObject';
const components = {
SvgIcon, OffsetLine, GenericObject, CharacterObject, VideoPlayer, SceneSwitcher,
PuzzleGame1, PuzzleGame2, MazeQuizGame, Particles, ClassicPuzzle
};
export default {
emits:['target', 'preview'],
components: {
SvgIcon, OffsetLine, GenericObject, CharacterObject, VideoPlayer,
PuzzleGame1, PuzzleGame2, MazeQuizGame, Particles, ClassicPuzzle
},
data(){
return {
active: false
}
},
mounted(){
this.active = true;
this.modelValue.points ??= 10;
this.modelValue.activationScore ??= 0;
},
props:{
//context: Object,
modelValue: Object,
@@ -79,6 +75,23 @@ export default {
visible: Boolean,
parent: Object
},
components,
data(){
return {
InteractiveObjectTypes,
active: false,
activationTypes: [{ title:'Unlock', value:'unlock'}, { title:'Appear', value:'appear'}]
}
},
mounted(){
this.active = true;
this.modelValue.points ??= 10;
this.modelValue.activationScore ??= 0;
this.modelValue.type ??= 'GenericObject';
if (components[this.modelValue.type].__transform){
components[this.modelValue.type].__transform(this.modelValue)
}
},
computed:{
showInView(){
this.vd.__showInView = this.visible && this.parent.visible;
@@ -86,7 +99,10 @@ export default {
},
mv(){
return this.modelValue
}
},
targetScene(){
return this.modelValue.__root.scenes.find(s=>s.data.id == this.modelValue?.switchScene)
},
},
steps: [['x1', 'y1']],
name: 'game-object',
@@ -94,17 +110,6 @@ export default {
methods:{
intersect(v){
return Utils.intersectPointRect([this.vd.x1, this.vd.y1], v);
},
assignGameObject(e){
this.modelValue.go = e.id;
if (this.modelValue.id == this.modelValue.title){
this.modelValue.title = e.name
}
if (e.type == 'InteractiveObject'){
this.modelValue.type = e.id;
}else{
this.modelValue.type = 'GenericObject'
}
}
}
}