private void OnSelectionChanged() { UpdatePreviews(); if (GetEditorInterface().GetSelection().GetSelectedNodes().Count == 0) { _button.Hide(); } else { bool nonSpriteExists; try { nonSpriteExists = GetEditorInterface().GetSelection().GetSelectedNodes().Cast <Node>() .Any(n => !(n is Sprite)); } catch (NullReferenceException) { //suppress NullReferenceException return; } if (nonSpriteExists) { _button.Hide(); return; } _button.Show(); } }
public override void MakeVisible(bool visible) { if (visible) { GD.Print("Visible"); curveCreate.Show(); curveEdit.Show(); curveDel.Show(); curveClose.Show(); handleMenu.Show(); sep.Show(); } else { GD.Print("Hide"); curveCreate.Hide(); curveEdit.Hide(); curveDel.Hide(); curveClose.Hide(); handleMenu.Hide(); sep.Hide(); { CustomPath pre = path; path = null; if (IsInstanceValid(pre) && IsInstanceValid(pre.curve)) { pre.curve.EmitSignal("changed"); } } } }
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)); }
void DropDownEventHandler(object sender, EventArgs e) { editButton.Hide(); if (sender == typeMenuAudioItem) { SwapTreeView(audioTreeView, sender); return; } if (sender == typeMenuFileItem) { SwapTreeView(fileTreeView, sender); return; } if (sender == typeMenuIconItem) { SwapTreeView(iconTreeView, sender); return; } if (sender == typeMenuImageItem) { SwapTreeView(imageTreeView, sender); return; } if (sender == typeMenuOtherItem) { SwapTreeView(otherTreeView, sender); return; } if (sender == typeMenuStringItem) { editButton.Show(); SwapTreeView(stringTreeView, sender); return; } }
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); }
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); }
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"); }
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(); 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.Title = "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.GetThemeIcon("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, Android, iOS and HTML5, but not yet to 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.Toggled += enabled => { bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start"); if (showOnStart != enabled) { editorSettings.SetSetting("mono/editor/show_info_on_start", enabled); } }; aboutVBox.AddChild(aboutDialogCheckBox); } if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath)) { try { // Migrate solution from old configuration names to: Debug, ExportDebug and ExportRelease DotNetSolution.MigrateFromOldConfigNames(GodotSharpDirs.ProjectSlnPath); var msbuildProject = ProjectUtils.Open(GodotSharpDirs.ProjectCsProjPath) ?? throw new Exception("Cannot open C# project"); // NOTE: The order in which changes are made to the project is important // Migrate csproj from old configuration names to: Debug, ExportDebug and ExportRelease ProjectUtils.MigrateFromOldConfigNames(msbuildProject); // Apply the other fixes only after configurations have been migrated // Make sure the existing project has the ProjectTypeGuids property (for VisualStudio) ProjectUtils.EnsureHasProjectTypeGuids(msbuildProject); // Make sure the existing project has Api assembly references configured correctly ProjectUtils.FixApiHintPath(msbuildProject); // Make sure the existing project references the Microsoft.NETFramework.ReferenceAssemblies nuget package ProjectUtils.EnsureHasNugetNetFrameworkRefAssemblies(msbuildProject); if (msbuildProject.HasUnsavedChanges) { // Save a copy of the project before replacing it FileUtils.SaveBackupCopy(GodotSharpDirs.ProjectCsProjPath); msbuildProject.Save(); } } catch (Exception e) { GD.PushError(e.ToString()); } } else { bottomPanelBtn.Hide(); menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln); } menuPopup.IdPressed += _MenuOptionPressed; var buildButton = new ToolButton { Text = "Build", HintTooltip = "Build solution", FocusMode = Control.FocusModeEnum.None }; buildButton.PressedSignal += _BuildSolutionPressed; AddControlToContainer(CustomControlContainer.Toolbar, buildButton); // 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); }