import ToolMenu from "./toolmenu";

const LABEL_TOGGLE_ID = "#label-toggle";
const RESIMULATE_BUTTON_ID = "#reanimate-button";
const PHYSICS_DELAY_ID = "#stop-physics-delay";

export const PHYSICS_DELAY_KEY = "delay";
export const RESIMULATE_KEY = "resimulate";
export const LABELS_KEY = "labels";

export class SettingsMenu extends ToolMenu {
    constructor() {
        super();
    }

    onMenuShow(initial) {
        if (initial === false) {
            return;
        }

        // Initial interface hooks
        this.find(LABEL_TOGGLE_ID).on("change", (e) => {
            this.notifyTool(LABELS_KEY, e.target.checked);
        });
        this.find(PHYSICS_DELAY_ID).on("change", (e) => {
            this.notifyTool(PHYSICS_DELAY_KEY, e.target.value);
        });
        this.find(RESIMULATE_BUTTON_ID).on("click", () => {
            this.notifyTool(RESIMULATE_KEY);
        });
    }
}