Example #1
0
    public void ConnectSignals()
    {
        PlayBtn.Connect("pressed", this, nameof(PlayStream));
        StopBtn.Connect("pressed", this, nameof(StopStream));
        NextBtn.Connect("pressed", this, nameof(NextStation));
        Radio.Connect("index_pressed", this, nameof(RadioPressed));
        VolumeBar.Connect("value_changed", this, nameof(ChangeVolume));
        AddStation.Connect("pressed", this, nameof(PopupAddStation));
        NewStation.Connect("confirmed", this, nameof(AddNewStation));

        StationHandler.Connect(nameof(StationHandler.AddNewStation), this, nameof(AddRadioItem));
    }
 public override void _EnterTree()
 {
     _settingsButton = new ToolButton {
         Text = "Polygonizer Settings"
     };
     _settingsButton.Connect("pressed", this, nameof(Settings_ButtonClicked));
     _button = new ToolButton {
         Text = "Polygonize"
     };
     _button.Connect("pressed", this, nameof(Polygonize_ButtonClicked));
     _button.Hide();
     _settingsDialog = (ConfirmationDialog)ResourceLoader.Load <PackedScene>("addons/Polygonizer/SettingsDialog.tscn").Instance();
     GetEditorInterface().GetBaseControl().AddChild(_settingsDialog);
     GetEditorInterface().GetInspector().Connect("property_edited", this, nameof(OnPropertyEdited));
     AddControlToContainer(CustomControlContainer.CanvasEditorMenu, _settingsButton);
     AddControlToContainer(CustomControlContainer.CanvasEditorMenu, _button);
     GetEditorInterface().GetSelection().Connect("selection_changed", this, nameof(OnSelectionChanged));
     _settingsDialog.Connect("confirmed", this, nameof(Settings_DialogConfirmed));
 }
Example #3
0
        public override void _Ready()
        {
            base._Ready();

            editorInterface = GodotSharpEditor.Instance.GetEditorInterface();

            var editorBaseControl = editorInterface.GetBaseControl();

            SizeFlagsVertical = (int)SizeFlags.ExpandFill;
            SetAnchorsAndMarginsPreset(LayoutPreset.Wide);

            panelTabs = new TabContainer
            {
                TabAlign          = TabContainer.TabAlignEnum.Left,
                RectMinSize       = new Vector2(0, 228) * EditorScale,
                SizeFlagsVertical = (int)SizeFlags.ExpandFill
            };
            panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles"));
            panelTabs.AddStyleboxOverride("tab_fg", editorBaseControl.GetStylebox("DebuggerTabFG", "EditorStyles"));
            panelTabs.AddStyleboxOverride("tab_bg", editorBaseControl.GetStylebox("DebuggerTabBG", "EditorStyles"));
            AddChild(panelTabs);

            {
                // Builds tab
                panelBuildsTab = new VBoxContainer
                {
                    Name = "Builds".TTR(),
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill
                };
                panelTabs.AddChild(panelBuildsTab);

                var toolBarHBox = new HBoxContainer {
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill
                };
                panelBuildsTab.AddChild(toolBarHBox);

                var buildProjectBtn = new Button
                {
                    Text      = "Build Project".TTR(),
                    FocusMode = FocusModeEnum.None
                };
                buildProjectBtn.Connect("pressed", this, nameof(BuildProjectPressed));
                toolBarHBox.AddChild(buildProjectBtn);

                toolBarHBox.AddSpacer(begin: false);

                warningsBtn = new ToolButton
                {
                    Text       = "Warnings".TTR(),
                    ToggleMode = true,
                    Pressed    = true,
                    Visible    = false,
                    FocusMode  = FocusModeEnum.None
                };
                warningsBtn.Connect("toggled", this, nameof(_WarningsToggled));
                toolBarHBox.AddChild(warningsBtn);

                errorsBtn = new ToolButton
                {
                    Text       = "Errors".TTR(),
                    ToggleMode = true,
                    Pressed    = true,
                    Visible    = false,
                    FocusMode  = FocusModeEnum.None
                };
                errorsBtn.Connect("toggled", this, nameof(_ErrorsToggled));
                toolBarHBox.AddChild(errorsBtn);

                toolBarHBox.AddSpacer(begin: false);

                viewLogBtn = new Button
                {
                    Text      = "View log".TTR(),
                    FocusMode = FocusModeEnum.None,
                    Visible   = false
                };
                viewLogBtn.Connect("pressed", this, nameof(_ViewLogPressed));
                toolBarHBox.AddChild(viewLogBtn);

                var hsc = new HSplitContainer
                {
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill,
                    SizeFlagsVertical   = (int)SizeFlags.ExpandFill
                };
                panelBuildsTab.AddChild(hsc);

                buildTabsList = new ItemList {
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill
                };
                buildTabsList.Connect("item_selected", this, nameof(_BuildTabsItemSelected));
                buildTabsList.Connect("nothing_selected", this, nameof(_BuildTabsNothingSelected));
                hsc.AddChild(buildTabsList);

                buildTabs = new TabContainer
                {
                    TabAlign            = TabContainer.TabAlignEnum.Left,
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill,
                    TabsVisible         = false
                };
                hsc.AddChild(buildTabs);
            }
        }
Example #4
0
        public override void EnablePlugin()
        {
            base.EnablePlugin();

            if (Instance != null)
            {
                throw new InvalidOperationException();
            }
            Instance = this;

            var editorInterface   = GetEditorInterface();
            var editorBaseControl = editorInterface.GetBaseControl();

            editorSettings = editorInterface.GetEditorSettings();

            errorDialog = new AcceptDialog();
            editorBaseControl.AddChild(errorDialog);

            BottomPanel = new BottomPanel();

            bottomPanelBtn = AddControlToBottomPanel(BottomPanel, "Mono".TTR());

            AddChild(new HotReloadAssemblyWatcher {
                Name = "HotReloadAssemblyWatcher"
            });

            menuPopup = new PopupMenu();
            menuPopup.Hide();
            menuPopup.SetAsToplevel(true);

            AddToolSubmenuItem("Mono", menuPopup);

            // TODO: Remove or edit this info dialog once Mono support is no longer in alpha
            {
                menuPopup.AddItem("About C# support".TTR(), (int)MenuOptions.AboutCSharp);
                aboutDialog = new AcceptDialog();
                editorBaseControl.AddChild(aboutDialog);
                aboutDialog.WindowTitle = "Important: C# support is not feature-complete";

                // We don't use DialogText as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox
                // we'll add. Instead we add containers and a new autowrapped Label inside.

                // Main VBoxContainer (icon + label on top, checkbox at bottom)
                var aboutVBox = new VBoxContainer();
                aboutDialog.AddChild(aboutVBox);

                // HBoxContainer for icon + label
                var aboutHBox = new HBoxContainer();
                aboutVBox.AddChild(aboutHBox);

                var aboutIcon = new TextureRect();
                aboutIcon.Texture = aboutIcon.GetIcon("NodeWarning", "EditorIcons");
                aboutHBox.AddChild(aboutIcon);

                var aboutLabel = new Label();
                aboutHBox.AddChild(aboutLabel);
                aboutLabel.RectMinSize       = new Vector2(600, 150) * EditorScale;
                aboutLabel.SizeFlagsVertical = (int)Control.SizeFlags.ExpandFill;
                aboutLabel.Autowrap          = true;
                aboutLabel.Text =
                    "C# support in Godot Engine is in late alpha stage and, while already usable, " +
                    "it is not meant for use in production.\n\n" +
                    "Projects can be exported to Linux, macOS, Windows and Android, but not yet to iOS, HTML5 or UWP. " +
                    "Bugs and usability issues will be addressed gradually over future releases, " +
                    "potentially including compatibility breaking changes as new features are implemented for a better overall C# experience.\n\n" +
                    "If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, MSBuild version, IDE, etc.:\n\n" +
                    "        https://github.com/godotengine/godot/issues\n\n" +
                    "Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!";

                EditorDef("mono/editor/show_info_on_start", true);

                // CheckBox in main container
                aboutDialogCheckBox = new CheckBox {
                    Text = "Show this warning when starting the editor"
                };
                aboutDialogCheckBox.Connect("toggled", this, nameof(_ToggleAboutDialogOnStart));
                aboutVBox.AddChild(aboutDialogCheckBox);
            }

            if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
            {
                // Make sure the existing project has Api assembly references configured correctly
                CsProjOperations.FixApiHintPath(GodotSharpDirs.ProjectCsProjPath);
            }
            else
            {
                bottomPanelBtn.Hide();
                menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
            }

            menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed));

            var buildButton = new ToolButton
            {
                Text        = "Build",
                HintTooltip = "Build solution",
                FocusMode   = Control.FocusModeEnum.None
            };

            buildButton.Connect("pressed", this, nameof(_BuildSolutionPressed));
            AddControlToContainer(CustomControlContainer.Toolbar, buildButton);

            // External editor settings
            EditorDef("mono/editor/external_editor", ExternalEditorId.None);

            string settingsHintStr = "Disabled";

            if (OS.IsWindows)
            {
                settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsOSX)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsUnixLike())
            {
                settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }

            editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
            {
                ["type"]        = Variant.Type.Int,
                ["name"]        = "mono/editor/external_editor",
                ["hint"]        = PropertyHint.Enum,
                ["hint_string"] = settingsHintStr
            });

            // Export plugin
            var exportPlugin = new ExportPlugin();

            AddExportPlugin(exportPlugin);
            exportPlugin.RegisterExportSettings();
            exportPluginWeak = WeakRef(exportPlugin);

            BuildManager.Initialize();
            RiderPathManager.Initialize();

            GodotIdeManager = new GodotIdeManager();
            AddChild(GodotIdeManager);
        }
Example #5
0
        public override void EnablePlugin()
        {
            base.EnablePlugin();

            if (Instance != null)
            {
                throw new InvalidOperationException();
            }
            Instance = this;

            var editorInterface   = GetEditorInterface();
            var editorBaseControl = editorInterface.GetBaseControl();

            _editorSettings = editorInterface.GetEditorSettings();

            _errorDialog = new AcceptDialog();
            editorBaseControl.AddChild(_errorDialog);

            MSBuildPanel    = new MSBuildPanel();
            _bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR());

            AddChild(new HotReloadAssemblyWatcher {
                Name = "HotReloadAssemblyWatcher"
            });

            _menuPopup = new PopupMenu();
            _menuPopup.Hide();
            _menuPopup.SetAsToplevel(true);

            AddToolSubmenuItem("C#", _menuPopup);

            var buildSolutionShortcut = (ShortCut)EditorShortcut("mono/build_solution");

            _toolBarButton = new ToolButton
            {
                Text              = "Build",
                HintTooltip       = "Build Solution".TTR(),
                FocusMode         = Control.FocusModeEnum.None,
                Shortcut          = buildSolutionShortcut,
                ShortcutInTooltip = true
            };
            _toolBarButton.Connect("pressed", this, nameof(BuildSolutionPressed));
            AddControlToContainer(CustomControlContainer.Toolbar, _toolBarButton);

            if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
            {
                ApplyNecessaryChangesToSolution();
            }
            else
            {
                _bottomPanelBtn.Hide();
                _toolBarButton.Hide();
                _menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
            }

            _menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed));

            // External editor settings
            EditorDef("mono/editor/external_editor", ExternalEditorId.None);

            string settingsHintStr = "Disabled";

            if (OS.IsWindows)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudio}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsOSX)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsUnixLike)
            {
                settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }

            _editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
            {
                ["type"]        = Variant.Type.Int,
                ["name"]        = "mono/editor/external_editor",
                ["hint"]        = PropertyHint.Enum,
                ["hint_string"] = settingsHintStr
            });

            // Export plugin
            var exportPlugin = new ExportPlugin();

            AddExportPlugin(exportPlugin);
            exportPlugin.RegisterExportSettings();
            _exportPluginWeak = WeakRef(exportPlugin);

            BuildManager.Initialize();
            RiderPathManager.Initialize();

            GodotIdeManager = new GodotIdeManager();
            AddChild(GodotIdeManager);
        }
Example #6
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");
    }