Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Add editor keyboard shortcut for Mono Build solution button #52595

Merged
merged 1 commit into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
#include "core/project_settings.h"

#ifdef TOOLS_ENABLED
#include "core/os/keyboard.h"
#include "editor/bindings_generator.h"
#include "editor/csharp_project.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/node_dock.h"
#endif

Expand Down Expand Up @@ -1178,6 +1180,7 @@ void CSharpLanguage::_editor_init_callback() {

// Enable it as a plugin
EditorNode::add_editor_plugin(godotsharp_editor);
ED_SHORTCUT("mono/build_solution", TTR("Build Solution"), KEY_MASK_ALT | KEY_B);
godotsharp_editor->enable_plugin();

get_singleton()->godotsharp_editor = godotsharp_editor;
Expand Down
8 changes: 6 additions & 2 deletions modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,15 @@ public override void EnablePlugin()

AddToolSubmenuItem("C#", menuPopup);

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

toolBarButton = new ToolButton
{
Text = "Build",
HintTooltip = "Build solution",
FocusMode = Control.FocusModeEnum.None
HintTooltip = "Build Solution".TTR(),
FocusMode = Control.FocusModeEnum.None,
Shortcut = buildSolutionShortcut,
ShortcutInTooltip = true
};
toolBarButton.Connect("pressed", this, nameof(BuildSolutionPressed));
AddControlToContainer(CustomControlContainer.Toolbar, toolBarButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public static object GlobalDef(string setting, object defaultValue, bool restart
public static object EditorDef(string setting, object defaultValue, bool restartIfChanged = false) =>
internal_EditorDef(setting, defaultValue, restartIfChanged);

public static object EditorShortcut(string setting) =>
internal_EditorShortcut(setting);

[SuppressMessage("ReSharper", "InconsistentNaming")]
public static string TTR(this string text) => internal_TTR(text);

Expand All @@ -27,6 +30,9 @@ public static object EditorDef(string setting, object defaultValue, bool restart
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern object internal_EditorDef(string setting, object defaultValue, bool restartIfChanged);

[MethodImpl(MethodImplOptions.InternalCall)]
private static extern object internal_EditorShortcut(string setting);

[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string internal_TTR(string text);
}
Expand Down
7 changes: 7 additions & 0 deletions modules/mono/editor/editor_internal_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ MonoObject *godot_icall_Globals_EditorDef(MonoString *p_setting, MonoObject *p_d
return GDMonoMarshal::variant_to_mono_object(result);
}

MonoObject *godot_icall_Globals_EditorShortcut(MonoString *p_setting) {
String setting = GDMonoMarshal::mono_string_to_godot(p_setting);
Ref<ShortCut> result = ED_GET_SHORTCUT(setting);
return GDMonoMarshal::variant_to_mono_object(result);
}

MonoString *godot_icall_Globals_TTR(MonoString *p_text) {
String text = GDMonoMarshal::mono_string_to_godot(p_text);
return GDMonoMarshal::mono_string_from_godot(TTR(text));
Expand Down Expand Up @@ -427,6 +433,7 @@ void register_editor_internal_calls() {
GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_EditorScale", godot_icall_Globals_EditorScale);
GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_GlobalDef", godot_icall_Globals_GlobalDef);
GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_EditorDef", godot_icall_Globals_EditorDef);
GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_EditorShortcut", godot_icall_Globals_EditorShortcut);
GDMonoUtils::add_internal_call("GodotTools.Internals.Globals::internal_TTR", godot_icall_Globals_TTR);

// Utils.OS
Expand Down