Skip to content
Snippets Groups Projects
settingstool.js 677 B
Newer Older
  • Learn to ignore specific revisions
  • Maximilian Giller's avatar
    Maximilian Giller committed
    import { graph, state } from "../editor";
    import {
        SettingsMenu,
        LABELS_KEY,
        RESIMULATE_KEY,
        PHYSICS_DELAY_KEY,
    } from "./menus/settingsmenu";
    
    import Tool from "./tool";
    
    export default class SettingsTool extends Tool {
        constructor(key) {
    
            super("Settings", "settings", key, new SettingsMenu(), true);
    
    Maximilian Giller's avatar
    Maximilian Giller committed
    
        onMenuChange(key, value) {
            if (key === LABELS_KEY) {
                state.setLabelVisibility(value);
            } else if (key === RESIMULATE_KEY) {
                graph.restartSimulation();
            } else if (key === PHYSICS_DELAY_KEY) {
    
                graph.physicsDelay = Number(value) * 1000;  // Convert seconds to ms
    
    Maximilian Giller's avatar
    Maximilian Giller committed
            }
        }