mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Snow fullscreen effect implemented
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import GraphicSet from "../../../js/GraphicSet.js";
|
||||
import Setting from "../../../js/Setting.js";
|
||||
import TilorswiftTilesetSelectedEvent from "../events/TilorswiftTilesetSelectedEvent.js";
|
||||
import {Checkbox} from "./elements/Checkbox.js";
|
||||
|
||||
export default class Dialog
|
||||
{
|
||||
@@ -66,6 +67,16 @@ export default class Dialog
|
||||
return htmlElementInput;
|
||||
}
|
||||
|
||||
createCheckbox(label, value, isChecked = false, onClick = () => {})
|
||||
{
|
||||
const checkbox = new Checkbox(label, value, isChecked);
|
||||
checkbox.onClick = onClick;
|
||||
|
||||
this.inputAreaElement.appendChild(checkbox.htmlElement);
|
||||
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
createTilesetSelector()
|
||||
{
|
||||
let htmlElement = document.createElement('div');
|
||||
@@ -133,6 +144,8 @@ export default class Dialog
|
||||
return htmlElement;
|
||||
}
|
||||
|
||||
|
||||
|
||||
createFileInput(types = [])
|
||||
{
|
||||
let input = document.createElement('input');
|
||||
|
||||
45
tilorswift/js/dialog/DialogEffects.js
Normal file
45
tilorswift/js/dialog/DialogEffects.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import Dialog from "./Dialog.js";
|
||||
import TilorswiftEffectsUpdatedEvent from "../events/TilorswiftEffectsUpdatedEvent.js";
|
||||
|
||||
export default class DialogEffects extends Dialog
|
||||
{
|
||||
constructor(effects, checked, translations)
|
||||
{
|
||||
super();
|
||||
this.setMessage('Effekte');
|
||||
this.effects = [];
|
||||
|
||||
for (const effect of effects) {
|
||||
const checkbox = this.createCheckbox(
|
||||
translations[effect],
|
||||
effect,
|
||||
checked.indexOf(effect) !== -1,
|
||||
() => {
|
||||
console.log(checkbox.name, 'is', checkbox.isChecked());
|
||||
}
|
||||
);
|
||||
|
||||
this.effects.push(checkbox);
|
||||
this.inputAreaElement.appendChild(checkbox.htmlElement);
|
||||
}
|
||||
|
||||
this.createButton('Abbrechen');
|
||||
this.buttonOk = this.createButton('OK');
|
||||
this.buttonOk.addEventListener(
|
||||
'click',
|
||||
() => {
|
||||
const effectNames = [];
|
||||
|
||||
for (const effect of this.effects) {
|
||||
if (effect.isChecked()) {
|
||||
effectNames.push(effect.name);
|
||||
}
|
||||
}
|
||||
|
||||
window.dispatchEvent(
|
||||
new TilorswiftEffectsUpdatedEvent(effectNames)
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
29
tilorswift/js/dialog/elements/Checkbox.js
Normal file
29
tilorswift/js/dialog/elements/Checkbox.js
Normal file
@@ -0,0 +1,29 @@
|
||||
export class Checkbox
|
||||
{
|
||||
constructor(label, name, isChecked = false)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
this.htmlElement = document.createElement('div');
|
||||
|
||||
this.onClick = () => {};
|
||||
|
||||
this.checkbox = document.createElement('input');
|
||||
this.checkbox.type = 'checkbox';
|
||||
this.checkbox.checked = isChecked;
|
||||
this.checkbox.onclick = () => {
|
||||
this.onClick();
|
||||
}
|
||||
|
||||
this.htmlLabel = document.createElement('label');
|
||||
this.htmlLabel.innerText = label;
|
||||
|
||||
this.htmlElement.appendChild(this.checkbox);
|
||||
this.htmlElement.appendChild(this.htmlLabel);
|
||||
}
|
||||
|
||||
isChecked()
|
||||
{
|
||||
return this.checkbox.checked;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user