mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Intelligent graphic sets implemented
This commit is contained in:
58
tilorswift/js/menu/IntelligentBrushSwitch.js
Normal file
58
tilorswift/js/menu/IntelligentBrushSwitch.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import Widget from "./Widget.js";
|
||||
import {Switch} from "./Switch.js";
|
||||
|
||||
export class IntelligentBrushSwitch extends Widget
|
||||
{
|
||||
constructor(tilesetPicker, brush) {
|
||||
super('Intelligenter Pinsel');
|
||||
|
||||
this.tilesetPicker = tilesetPicker;
|
||||
this.brush = brush;
|
||||
|
||||
this.switch = new Switch();
|
||||
this.switch.onToggle = (status) => {
|
||||
if (this.isActive) {
|
||||
this.setIntelligentBrush(status);
|
||||
}
|
||||
}
|
||||
this.htmlElement.appendChild(this.switch.htmlElement);
|
||||
|
||||
if (tilesetPicker.tileset.hasExtendedTiles()) {
|
||||
this.setIntelligentBrush(true);
|
||||
}
|
||||
}
|
||||
|
||||
switchOn()
|
||||
{
|
||||
if (!this.switch.status) {
|
||||
this.switch.toggle()
|
||||
this.setIntelligentBrush(true);
|
||||
}
|
||||
}
|
||||
|
||||
switchOff()
|
||||
{
|
||||
if (this.switch.status) {
|
||||
this.switch.toggle()
|
||||
this.setIntelligentBrush(false);
|
||||
}
|
||||
}
|
||||
|
||||
setIntelligentBrush(status)
|
||||
{
|
||||
this.brush.isIntelligent = status;
|
||||
this.tilesetPicker.updateExtendedTileVisibility();
|
||||
}
|
||||
|
||||
enable() {
|
||||
super.enable();
|
||||
|
||||
this.switch.enable();
|
||||
}
|
||||
|
||||
disable() {
|
||||
super.disable();
|
||||
|
||||
this.switch.disable();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user