2023-01-19 17:59:18 +00:00
|
|
|
<template>
|
|
|
|
<section>
|
|
|
|
<div class="content">
|
2023-02-02 18:06:55 +00:00
|
|
|
<p class="title is-5">Steuerung</p>
|
2023-01-19 17:59:18 +00:00
|
|
|
<ul>
|
|
|
|
<li>Linksklick + Ziehen: Neues Türchen erstellen</li>
|
|
|
|
<li>Rechtsklick + Ziehen: Türchen verschieben</li>
|
|
|
|
<li>Doppel- oder Mittelklick: Türchen löschen</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2023-09-09 21:41:06 +00:00
|
|
|
<figure class="image is-unselectable">
|
2023-09-04 21:23:27 +00:00
|
|
|
<img :src="$advent22.api_url('general/background')" />
|
2023-09-07 01:17:14 +00:00
|
|
|
<RectangleCanvas
|
|
|
|
:rectangles="rectangles"
|
|
|
|
@draw="on_draw"
|
|
|
|
@drag="on_drag"
|
|
|
|
@remove="on_remove"
|
|
|
|
/>
|
2023-01-19 17:59:18 +00:00
|
|
|
</figure>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-09-07 02:08:56 +00:00
|
|
|
import { Door } from "@/lib/door";
|
|
|
|
import { Rectangle } from "@/lib/rectangle";
|
2023-09-06 16:25:35 +00:00
|
|
|
import { Options, Vue } from "vue-class-component";
|
2023-09-07 02:08:56 +00:00
|
|
|
|
2023-01-27 00:23:41 +00:00
|
|
|
import RectangleCanvas from "./RectangleCanvas.vue";
|
2023-01-19 17:59:18 +00:00
|
|
|
|
|
|
|
@Options({
|
|
|
|
components: {
|
2023-01-27 00:23:41 +00:00
|
|
|
RectangleCanvas,
|
2023-01-19 17:59:18 +00:00
|
|
|
},
|
2023-01-23 23:37:23 +00:00
|
|
|
props: {
|
2023-02-01 16:53:24 +00:00
|
|
|
doors: Array,
|
2023-01-23 23:37:23 +00:00
|
|
|
},
|
2023-02-01 16:53:24 +00:00
|
|
|
emits: ["update:doors"],
|
2023-01-19 17:59:18 +00:00
|
|
|
})
|
2023-01-24 23:19:25 +00:00
|
|
|
export default class extends Vue {
|
2023-02-01 16:53:24 +00:00
|
|
|
private doors!: Door[];
|
2023-01-23 23:37:23 +00:00
|
|
|
|
2023-09-06 16:25:35 +00:00
|
|
|
public get rectangles() {
|
2023-02-02 15:28:30 +00:00
|
|
|
return this.doors.map((door) => door.position);
|
2023-01-23 23:37:23 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 16:25:35 +00:00
|
|
|
public on_draw(position: Rectangle) {
|
2023-02-02 18:06:55 +00:00
|
|
|
this.doors.push(new Door(position));
|
2023-02-02 14:12:44 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 16:25:35 +00:00
|
|
|
public find_door_index(position: Rectangle): number {
|
2023-02-02 14:12:44 +00:00
|
|
|
return this.doors.findIndex((door) => door.position.equals(position));
|
|
|
|
}
|
|
|
|
|
2023-09-06 16:25:35 +00:00
|
|
|
public on_drag(old_pos: Rectangle, new_pos: Rectangle) {
|
2023-02-02 14:12:44 +00:00
|
|
|
const idx = this.find_door_index(old_pos);
|
|
|
|
|
|
|
|
if (idx === -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.doors[idx].position = new_pos;
|
|
|
|
}
|
|
|
|
|
2023-09-06 16:25:35 +00:00
|
|
|
public on_remove(position: Rectangle) {
|
2023-02-02 14:12:44 +00:00
|
|
|
const idx = this.find_door_index(position);
|
|
|
|
|
|
|
|
if (idx === -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.doors.splice(idx, 1);
|
|
|
|
}
|
|
|
|
|
2023-01-23 23:37:23 +00:00
|
|
|
public beforeUnmount() {
|
2023-02-01 16:53:24 +00:00
|
|
|
this.$emit("update:doors", this.doors);
|
2023-01-23 23:37:23 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-19 17:59:18 +00:00
|
|
|
</script>
|