This commit is contained in:
2025-03-18 12:21:21 +02:00
parent eaa46eeda8
commit 1f6ee77c24
17 changed files with 407 additions and 275 deletions
+52 -31
View File
@@ -1,31 +1,50 @@
<template>
<v-card :title="id == 'add' ? $l.createGameObject : $l.editGameObject" class="container my-3">
<v-form class="pa-4" v-model="valid">
<v-text-field :label="$l.name" v-model="object.name" :rules="[rules.required]"></v-text-field>
<v-textarea :label="$l.description" v-model="object.description"></v-textarea>
<v-select :label="$l.objectType" v-model="object.type" :items="$p.objectTypes" :rules="[rules.required]">
</v-select>
<v-file-input :label="$l.objectFile" v-model="object.file" :rules="[rules.requiredFile]"></v-file-input>
<div v-if="object.asset?.name">{{ object.asset.name }}</div>
</v-form>
<v-card-actions>
<v-btn @click="saveAndPreview" :loading="loading" prepend-icon="mdi-content-save" color="primary"
:disabled="!valid">
{{ $l.saveAndPreview }}
</v-btn>
<v-btn @click="publish" prepend-icon="mdi-publish" color="success" v-if="false && object.id">{{ $l.publish
}}</v-btn>
</v-card-actions>
</v-card>
<v-card :title="$l.preview" class="container my-3" v-if="object.asset">
<AssetPreview :object="object" ref="assetPreview" ></AssetPreview>
<v-card-actions>
<v-btn @click="captureThumbnail" v-if="forRendering" prepend-icon="mdi-camera" color="secondary">
{{ $l.captureThumbnail }}
</v-btn>
</v-card-actions>
</v-card>
<v-container max-width="1400">
<v-tabs v-model="panel">
<v-tab value="edit">
<v-icon icon="mdi-pencil"></v-icon> {{ id == 'add' ? l.createGameObject : l.editGameObject }}
</v-tab>
<v-tab value="preview" v-if="object.asset">
<v-icon icon="mdi-panorama-outline"></v-icon> {{ l.preview }}
</v-tab>
</v-tabs>
<v-tabs-window v-model="panel">
<v-tabs-window-item value="edit">
<v-card class="container my-3">
<v-form class="pa-4" v-model="valid">
<v-text-field :label="l.name" v-model="object.name" :rules="[rules.required]"></v-text-field>
<v-textarea :label="l.description" v-model="object.description"></v-textarea>
<v-select :label="l.objectType" v-model="object.type" :items="$p.objectTypes.map(ot=>({title:l[ot.value], value:ot.value}))" tit :rules="[rules.required]">
</v-select>
<v-file-input :label="l.objectFile" v-model="object.file" :rules="[rules.requiredFile]"></v-file-input>
<div v-if="object.asset?.name">{{ object.asset.name }}</div>
</v-form>
<v-card-actions>
<v-btn @click="save" :loading="loading" prepend-icon="mdi-content-save" color="success"
:disabled="!valid">
{{ l.save }}
</v-btn>
<v-btn @click="save({preview: true})" :loading="loading" prepend-icon="mdi-content-save" color="primary"
:disabled="!valid">
{{ l.saveAndPreview }}
</v-btn>
<v-btn @click="publish" prepend-icon="mdi-publish" color="success" v-if="false && object.id">{{ l.publish
}}</v-btn>
</v-card-actions>
</v-card>
</v-tabs-window-item>
<v-tabs-window-item value="preview">
<v-card :title="l.preview" class="container my-3" v-if="object.asset">
<AssetPreview :object="object" ref="assetPreview" ></AssetPreview>
<v-card-actions>
<v-btn @click="captureThumbnail" v-if="forRendering" prepend-icon="mdi-camera" color="secondary">
{{ l.captureThumbnail }}
</v-btn>
</v-card-actions>
</v-card>
</v-tabs-window-item>
</v-tabs-window>
</v-container>
</template>
<script>
@@ -33,11 +52,12 @@
export default {
data() {
return {
panel: 'edit',
object: {},
valid: false,
rules: {
required: v => v ? true : this.$l.fieldRequired,
requiredFile: v => (v?.size || this.id != 'add') ? true : this.$l.fieldRequired
required: v => v ? true : this.l.fieldRequired,
requiredFile: v => (v?.size || this.id != 'add') ? true : this.l.fieldRequired
},
loading: false
}
@@ -59,7 +79,7 @@ export default {
},
},
methods: {
async saveAndPreview(params) {
async save(params) {
this.loading = true;
try {
let fd = new FormData();
@@ -79,11 +99,12 @@ export default {
console.error(err);
}
this.loading = false
this.panel = 'preview';
},
async captureThumbnail() {
this.object.thumb = await this.$refs.assetPreview.gameEngine.captureScreenshot();
await this.saveAndPreview({ thumbOnly: true });
await this.save({ thumbOnly: true });
},
async publish() {