Skip to content
Snippets Groups Projects
settingsmenu.js 1.34 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { SPACE } from "../../../../config";
    
    import ToolMenu from "./toolmenu";
    
    
    Maximilian Giller's avatar
    Maximilian Giller committed
    const LABEL_TOGGLE_ID = "#label-toggle";
    const RESIMULATE_BUTTON_ID = "#reanimate-button";
    const PHYSICS_DELAY_ID = "#stop-physics-delay";
    
    const SPACE_SELECT_ID = "#space-id-select";
    
    
    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);
            });
    
            this.find(SPACE_SELECT_ID).on("click", (e) => {
                var newSpace = e.target.value;
                if (newSpace === SPACE) {
                    return;
                }
    
    
                alert("Unable to load space at the moment! Editor object not implemented yet. See settingsmenu.js for further details.");
                // loadSpace(newSpace);
    
                this.hide();
            });