Beispiel #1
0
 public PathGizmo(CustomPathEditorPlugin plugin, PathGizmoPlugin gizmoPlug, EditorInterface editor, CustomPath path)
 {
     this.editor = editor;
     this.path   = path;
     this.plugin = plugin;
     gizmoPlugin = gizmoPlug;
 }
Beispiel #2
0
 public override void _ExitTree()
 {
     RemoveCustomType("Custom3DPath");
     path = null;
     handleMenu.QueueFree();
     curveClose.QueueFree();
     curveDel.QueueFree();
     curveCreate.QueueFree();
     curveEdit.QueueFree();
     RemoveSpatialGizmoPlugin(gizmoPlugin);
     gizmoPlugin = null;
     sep.QueueFree();
 }
Beispiel #3
0
    public override void _EnterTree()
    {
        path        = null;
        editor      = GetEditorInterface();
        baseControl = editor.GetBaseControl();
        AddCustomType("Custom3DPath", "Spatial", GD.Load("res://addons/fabianlc_better3d_path/CustomPath.cs") as Script
                      , GD.Load("res://addons/fabianlc_better3d_path/Path3D.svg") as Texture);
        mirrorHandleAngle  = true;
        mirrorHandleLength = true;

        gizmoPlugin = new PathGizmoPlugin(this, editor);
        AddSpatialGizmoPlugin(gizmoPlugin);

        sep = new VSeparator();
        sep.Hide();
        AddControlToContainer(CustomControlContainer.SpatialEditorMenu, sep);
        curveEdit            = new ToolButton();
        curveEdit.Icon       = baseControl.GetIcon("CurveEdit", "EditorIcons");
        curveEdit.ToggleMode = true;
        curveEdit.Hide();
        curveEdit.FocusMode   = Control.FocusModeEnum.None;
        curveEdit.HintTooltip = (("Select Points") + "\n" + ("Shift+Drag: Select Control Points")
                                 + "\n" + "KEY_CMD" + ("Click: Add Point") + "\n" + ("Right Click: Delete Point"));
        AddControlToContainer(CustomControlContainer.SpatialEditorMenu, curveEdit);
        curveCreate            = new ToolButton();
        curveCreate.Icon       = baseControl.GetIcon("CurveCreate", "EditorIcons");
        curveCreate.ToggleMode = true;
        curveCreate.Hide();
        curveCreate.FocusMode   = Control.FocusModeEnum.None;;
        curveCreate.HintTooltip = (("Add Point (in empty space)") + "\n" + ("Split Segment (in curve)"));
        AddControlToContainer(CustomControlContainer.SpatialEditorMenu, curveCreate);
        curveDel            = new ToolButton();
        curveDel.Icon       = baseControl.GetIcon("CurveDelete", "EditorIcons");
        curveDel.ToggleMode = true;
        curveDel.Hide();
        curveDel.FocusMode   = Control.FocusModeEnum.None;;
        curveDel.HintTooltip = (("Delete Point"));
        AddControlToContainer(CustomControlContainer.SpatialEditorMenu, curveDel);
        curveClose      = new ToolButton();
        curveClose.Icon = baseControl.GetIcon("CurveClose", "EditorIcons");
        curveClose.Hide();
        curveClose.FocusMode   = Control.FocusModeEnum.None;;
        curveClose.HintTooltip = (("Close Curve"));
        AddControlToContainer(CustomControlContainer.SpatialEditorMenu, curveClose);

        PopupMenu menu;

        handleMenu      = new MenuButton();
        handleMenu.Text = (("Options"));
        handleMenu.Hide();
        AddControlToContainer(CustomControlContainer.SpatialEditorMenu, handleMenu);

        menu = handleMenu.GetPopup();

        menu.AddCheckItem("Mirror Handle Angles");
        menu.SetItemChecked((int)Options.Angle, mirrorHandleAngle);
        menu.AddCheckItem("Mirror Handle Lengths");
        menu.SetItemChecked((int)Options.Length, mirrorHandleLength);
        menu.AddCheckItem("Enable Snap", (int)Options.DoSnap);
        menu.SetItemChecked((int)Options.DoSnap, snapEnabled);
        menu.AddItem("Configure snap", (int)Options.ConfigureSnap);
        menu.AddCheckItem("Lock X", (int)Options.LockX);
        menu.SetItemChecked((int)Options.LockX, lockX);
        menu.AddCheckItem("Lock Y", (int)Options.LockY);
        menu.SetItemChecked((int)Options.LockY, lockY);
        menu.AddCheckItem("Lock Z", (int)Options.LockZ);
        menu.SetItemChecked((int)Options.LockZ, lockZ);

        menu.Connect("id_pressed", this, nameof(HandleOptionPressed));

        curveEdit.Pressed = (true);

        curveCreate.Connect("pressed", this, "_ModeChanged", new Godot.Collections.Array {
            0
        });
        curveEdit.Connect("pressed", this, "_ModeChanged", new Godot.Collections.Array {
            1
        });
        curveDel.Connect("pressed", this, "_ModeChanged", new Godot.Collections.Array {
            2
        });
        curveClose.Connect("pressed", this, "_CloseCurve");
    }