mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
DoorChooser usable but bad
This commit is contained in:
parent
d0756fda92
commit
ef5281e57b
3 changed files with 34 additions and 32 deletions
|
@ -1,26 +1,28 @@
|
|||
<template>
|
||||
<section>
|
||||
<div class="content">
|
||||
<p class="title is-5">Steuerung</p>
|
||||
<ul>
|
||||
<li>Linksklick: Türchen auswählen</li>
|
||||
<li>Linksklick: Türchen hochzählen</li>
|
||||
<li>Rechtsklick: Türchen runterzählen</li>
|
||||
</ul>
|
||||
</div>
|
||||
<figure class="image">
|
||||
<img src="@/assets/adventskalender.jpg" />
|
||||
<ThouCanvas>
|
||||
<SVGRect
|
||||
v-for="(door, index) in unchosen_doors"
|
||||
:key="`door-${index}`"
|
||||
<template v-for="(door, index) in doors" :key="`door-${index}`">
|
||||
<SVGRectText
|
||||
v-if="door.day >= 0"
|
||||
:text="String(door.day)"
|
||||
:rectangle="door.position"
|
||||
@click.left="choose_door(index)"
|
||||
/>
|
||||
<SVGRect
|
||||
:rectangle="door.position"
|
||||
:focused="door.day >= 0"
|
||||
@click.left="door.day++"
|
||||
@click.right="door.day--"
|
||||
style="cursor: pointer"
|
||||
/>
|
||||
<template
|
||||
v-for="(door, index) in chosen_doors"
|
||||
:key="`door_chosen-${index}`"
|
||||
>
|
||||
<SVGRect :rectangle="door.position" :focused="true" />
|
||||
<SVGRectText :rectangle="door.position" :text="String(door.day)" />
|
||||
</template>
|
||||
</ThouCanvas>
|
||||
</figure>
|
||||
|
@ -48,20 +50,6 @@ import SVGRectText from "../rects/SVGRectText.vue";
|
|||
})
|
||||
export default class extends Vue {
|
||||
private doors!: Door[];
|
||||
private day = 0;
|
||||
|
||||
private get chosen_doors(): Door[] {
|
||||
return this.doors.filter((door) => door.day !== undefined);
|
||||
}
|
||||
|
||||
private get unchosen_doors(): Door[] {
|
||||
return this.doors.filter((door) => door.day === undefined);
|
||||
}
|
||||
|
||||
private choose_door(index: number) {
|
||||
this.unchosen_doors[index].day = this.day;
|
||||
this.day++;
|
||||
}
|
||||
|
||||
public beforeUnmount() {
|
||||
this.$emit("update:doors", this.doors);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<section>
|
||||
<div class="content">
|
||||
<p class="title is-5">Steuerung</p>
|
||||
<ul>
|
||||
<li>Linksklick + Ziehen: Neues Türchen erstellen</li>
|
||||
<li>Rechtsklick + Ziehen: Türchen verschieben</li>
|
||||
|
@ -42,7 +43,7 @@ export default class extends Vue {
|
|||
}
|
||||
|
||||
private on_draw(position: Rectangle) {
|
||||
this.doors.push({ position: position });
|
||||
this.doors.push(new Door(position));
|
||||
}
|
||||
|
||||
private find_door_index(position: Rectangle): number {
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
import { Rectangle } from "../rects/rectangles";
|
||||
|
||||
export interface Door {
|
||||
day?: number;
|
||||
position: Rectangle;
|
||||
export class Door {
|
||||
private _day = -1;
|
||||
public position: Rectangle;
|
||||
|
||||
constructor(position: Rectangle, day = -1) {
|
||||
this.day = day;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public get day(): number {
|
||||
return this._day
|
||||
}
|
||||
|
||||
public set day(day: number) {
|
||||
this._day = Math.max(day, -1);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue