mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-21 19:15:32 +02:00
wip
This commit is contained in:
@@ -62,6 +62,7 @@ import { createRoomObjectPreviewEngine, RoomObjectPreviewEngine } from '@/world/
|
|||||||
import { camelToKebab } from '@/world/utility.js';
|
import { camelToKebab } from '@/world/utility.js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import { prefer } from '@/preferences.js';
|
import { prefer } from '@/preferences.js';
|
||||||
|
import { deepClone } from '@/utility/clone.js';
|
||||||
|
|
||||||
// TODO: instanceのidと紛らわしいのでid -> typeにする
|
// TODO: instanceのidと紛らわしいのでid -> typeにする
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ const dialog = useTemplateRef('dialog');
|
|||||||
const canvas = useTemplateRef('canvas');
|
const canvas = useTemplateRef('canvas');
|
||||||
const selectedId = ref<string | null>(null);
|
const selectedId = ref<string | null>(null);
|
||||||
const selectedInstanceId = ref<string | null>(null);
|
const selectedInstanceId = ref<string | null>(null);
|
||||||
const selectedObjectOptionsState = shallowRef<RoomStateObject | null>(null);
|
const selectedObjectOptionsState = ref<RoomStateObject | null>(null);
|
||||||
const selectedObjectDef = computed(() => OBJECT_DEFS.find(def => def.id === selectedId.value) ?? null);
|
const selectedObjectDef = computed(() => OBJECT_DEFS.find(def => def.id === selectedId.value) ?? null);
|
||||||
const showObjectOptions = ref(false);
|
const showObjectOptions = ref(false);
|
||||||
const engine = shallowRef<RoomObjectPreviewEngine | null>(null);
|
const engine = shallowRef<RoomObjectPreviewEngine | null>(null);
|
||||||
@@ -106,7 +107,7 @@ watch(selectedId, (newId) => {
|
|||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
engine.value!.load(newId).then(res => {
|
engine.value!.load(newId).then(res => {
|
||||||
selectedInstanceId.value = res.id;
|
selectedInstanceId.value = res.id;
|
||||||
selectedObjectOptionsState.value = res.options;
|
selectedObjectOptionsState.value = deepClone(res.options);
|
||||||
engine.value!.resize();
|
engine.value!.resize();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -114,15 +115,15 @@ watch(selectedId, (newId) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function updateObjectOption(k: string, v: any) {
|
function updateObjectOption(k: string, v: any) {
|
||||||
engine.value!.updateObjectOption(k, v);
|
const updatedOptions = engine.value!.updateObjectOption(k, v);
|
||||||
triggerRef(selectedObjectOptionsState);
|
selectedObjectOptionsState.value = deepClone(updatedOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ok() {
|
function ok() {
|
||||||
if (selectedId.value == null) return;
|
if (selectedId.value == null) return;
|
||||||
emit('ok', {
|
emit('ok', {
|
||||||
id: selectedId.value,
|
id: selectedId.value,
|
||||||
options: selectedObjectOptionsState.value,
|
options: deepClone(selectedObjectOptionsState.value),
|
||||||
});
|
});
|
||||||
dialog.value?.close();
|
dialog.value?.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ export class RoomObjectPreviewEngine {
|
|||||||
public updateObjectOption(key: string, value: any) {
|
public updateObjectOption(key: string, value: any) {
|
||||||
this.objectOptions[key] = value;
|
this.objectOptions[key] = value;
|
||||||
this.objectInstance?.onOptionsUpdated?.([key, value]);
|
this.objectInstance?.onOptionsUpdated?.([key, value]);
|
||||||
|
return this.objectOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public clear() {
|
public clear() {
|
||||||
|
|||||||
Reference in New Issue
Block a user