import {
    SettingsMenu,
    LABELS_KEY,
    RESIMULATE_KEY,
    PHYSICS_DELAY_KEY,
} from "./menus/settingsmenu";
import Tool from "./tool";
import SettingsIcon from "../../images/tools/settings.png";
import { Editor } from "../components/editor";

export default class SettingsTool extends Tool {
    constructor(key) {
        super("Settings", SettingsIcon, key, new SettingsMenu(), true);
    }

    onMenuChange(key, value) {
        if (key === LABELS_KEY) {
            Editor.globalState.setLabelVisibility(value);
        } else if (key === RESIMULATE_KEY) {
            Editor.globalGraph.restartSimulation();
        } else if (key === PHYSICS_DELAY_KEY) {
            Editor.globalGraph.physicsDelay = Number(value) * 1000; // Convert seconds to ms
        }
    }
}