diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-07-11 13:59:06 +0200 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-07-11 13:59:06 +0200 |
commit | 4061e132ff4a5cdbe76390fa55fb7eacbf4afe97 (patch) | |
tree | 0b31c381860f1dd6a3f0d9e731bd8e03af6d8e77 | |
parent | 2c6daf73f3a1077dfae0ca88117a3f4b583eb7e6 (diff) |
Mono: Add old TTRs to GodotTools
9 files changed, 74 insertions, 45 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs b/modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs index e216d30462..4535ed7247 100644 --- a/modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs +++ b/modules/mono/editor/GodotTools/GodotTools/CSharpProject.cs @@ -1,9 +1,9 @@ using Godot; using System; -using System.Collections.Generic; using Godot.Collections; using GodotTools.Internals; using GodotTools.ProjectEditor; +using static GodotTools.Internals.Globals; using File = GodotTools.Utils.File; using Directory = GodotTools.Utils.Directory; @@ -26,7 +26,7 @@ namespace GodotTools public static void AddItem(string projectPath, string itemType, string include) { - if (!(bool) Internal.GlobalDef("mono/project/auto_update_project", true)) + if (!(bool) GlobalDef("mono/project/auto_update_project", true)) return; ProjectUtils.AddItemToProjectChecked(projectPath, itemType, include); diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs index 433a931941..e606781115 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using GodotTools.Build; using GodotTools.Internals; using GodotTools.Utils; +using static GodotTools.Internals.Globals; using Error = Godot.Error; using File = GodotTools.Utils.File; using Directory = GodotTools.Utils.Directory; @@ -376,7 +377,7 @@ namespace GodotTools { // Build tool settings - Internal.EditorDef("mono/builds/build_tool", OS.IsWindows() ? BuildTool.MsBuildVs : BuildTool.MsBuildMono); + EditorDef("mono/builds/build_tool", OS.IsWindows() ? BuildTool.MsBuildVs : BuildTool.MsBuildMono); var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings(); @@ -390,7 +391,7 @@ namespace GodotTools $"{PropNameMsbuildMono},{PropNameXbuild}" }); - Internal.EditorDef("mono/builds/print_build_output", false); + EditorDef("mono/builds/print_build_output", false); } } } diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index da439b8d6f..422752bb72 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using GodotTools.Internals; using GodotTools.ProjectEditor; +using static GodotTools.Internals.Globals; using File = GodotTools.Utils.File; using Path = System.IO.Path; using OS = GodotTools.Utils.OS; @@ -32,9 +33,9 @@ namespace GodotTools private bool CreateProjectSolution() { - using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...", 2)) // TTR("Generating solution...") + using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 2)) { - pr.Step("Generating C# project..."); // TTR("Generating C# project...") + pr.Step("Generating C# project...".TTR()); string resourceDir = ProjectSettings.GlobalizePath("res://"); @@ -67,7 +68,7 @@ namespace GodotTools } catch (IOException e) { - ShowErrorDialog($"Failed to save solution. Exception message: {e.Message}"); // TTR + ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message); return false; } @@ -79,14 +80,14 @@ namespace GodotTools if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Editor, apiConfig)) return false; - pr.Step("Done"); // TTR("Done") + pr.Step("Done".TTR()); // Here, after all calls to progress_task_step CallDeferred(nameof(_RemoveCreateSlnMenuOption)); } else { - ShowErrorDialog("Failed to create C# project."); // TTR + ShowErrorDialog("Failed to create C# project.".TTR()); } return true; @@ -407,7 +408,7 @@ namespace GodotTools MonoBottomPanel = new MonoBottomPanel(); - bottomPanelBtn = AddControlToBottomPanel(MonoBottomPanel, "Mono"); // TTR("Mono") + bottomPanelBtn = AddControlToBottomPanel(MonoBottomPanel, "Mono".TTR()); AddChild(new HotReloadAssemblyWatcher {Name = "HotReloadAssemblyWatcher"}); @@ -419,7 +420,7 @@ namespace GodotTools // TODO: Remove or edit this info dialog once Mono support is no longer in alpha { - menuPopup.AddItem("About C# support", (int) MenuOptions.AboutCSharp); // TTR("About C# support") + menuPopup.AddItem("About C# support".TTR(), (int) MenuOptions.AboutCSharp); aboutDialog = new AcceptDialog(); editorBaseControl.AddChild(aboutDialog); aboutDialog.WindowTitle = "Important: C# support is not feature-complete"; @@ -441,7 +442,7 @@ namespace GodotTools var aboutLabel = new Label(); aboutHBox.AddChild(aboutLabel); - aboutLabel.RectMinSize = new Vector2(600, 150) * Internal.EditorScale; + aboutLabel.RectMinSize = new Vector2(600, 150) * EditorScale; aboutLabel.SizeFlagsVertical = (int) Control.SizeFlags.ExpandFill; aboutLabel.Autowrap = true; aboutLabel.Text = @@ -454,7 +455,7 @@ namespace GodotTools " 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!"; - Internal.EditorDef("mono/editor/show_info_on_start", true); + EditorDef("mono/editor/show_info_on_start", true); // CheckBox in main container aboutDialogCheckBox = new CheckBox {Text = "Show this warning when starting the editor"}; @@ -473,7 +474,7 @@ namespace GodotTools else { bottomPanelBtn.Hide(); - menuPopup.AddItem("Create C# solution", (int) MenuOptions.CreateSln); // TTR("Create C# solution") + menuPopup.AddItem("Create C# solution".TTR(), (int) MenuOptions.CreateSln); } menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed)); @@ -488,7 +489,7 @@ namespace GodotTools AddControlToContainer(CustomControlContainer.Toolbar, buildButton); // External editor settings - Internal.EditorDef("mono/editor/external_editor", ExternalEditor.None); + EditorDef("mono/editor/external_editor", ExternalEditor.None); string settingsHintStr = "Disabled"; diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj index a0ff8a0df1..01e8c87d14 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj +++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj @@ -44,6 +44,7 @@ <Compile Include="Internals\GodotSharpDirs.cs" /> <Compile Include="Internals\Internal.cs" /> <Compile Include="Internals\ScriptClassParser.cs" /> + <Compile Include="Internals\Globals.cs" /> <Compile Include="MonoDevelopInstance.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Build\BuildSystem.cs" /> diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs index aa52079cf4..0f6f5ffadc 100644 --- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs +++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs @@ -1,5 +1,6 @@ using Godot; using GodotTools.Internals; +using static GodotTools.Internals.Globals; namespace GodotTools { @@ -37,7 +38,7 @@ namespace GodotTools watchTimer = new Timer { OneShot = false, - WaitTime = (float) Internal.EditorDef("mono/assembly_watch_interval_sec", 0.5) + WaitTime = (float) EditorDef("mono/assembly_watch_interval_sec", 0.5) }; watchTimer.Connect("timeout", this, nameof(TimerTimeout)); AddChild(watchTimer); diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs new file mode 100644 index 0000000000..793f84fd77 --- /dev/null +++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs @@ -0,0 +1,33 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace GodotTools.Internals +{ + public static class Globals + { + public static float EditorScale => internal_EditorScale(); + + public static object GlobalDef(string setting, object defaultValue, bool restartIfChanged = false) => + internal_GlobalDef(setting, defaultValue, restartIfChanged); + + public static object EditorDef(string setting, object defaultValue, bool restartIfChanged = false) => + internal_EditorDef(setting, defaultValue, restartIfChanged); + + [SuppressMessage("ReSharper", "InconsistentNaming")] + public static string TTR(this string text) => internal_TTR(text); + + // Internal Calls + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern float internal_EditorScale(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern object internal_GlobalDef(string setting, object defaultValue, bool restartIfChanged); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern object internal_EditorDef(string setting, object defaultValue, bool restartIfChanged); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern string internal_TTR(string text); + } +} diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs index 5c7ce832cd..c33cb8b785 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs @@ -10,14 +10,6 @@ namespace GodotTools.Internals public const string CSharpLanguageType = "CSharpScript"; public const string CSharpLanguageExtension = "cs"; - public static float EditorScale => internal_EditorScale(); - - public static object GlobalDef(string setting, object defaultValue, bool restartIfChanged = false) => - internal_GlobalDef(setting, defaultValue, restartIfChanged); - - public static object EditorDef(string setting, object defaultValue, bool restartIfChanged = false) => - internal_EditorDef(setting, defaultValue, restartIfChanged); - public static string FullTemplatesDir => internal_FullTemplatesDir(); @@ -62,15 +54,6 @@ namespace GodotTools.Internals // Internal Calls [MethodImpl(MethodImplOptions.InternalCall)] - private static extern float internal_EditorScale(); - - [MethodImpl(MethodImplOptions.InternalCall)] - private static extern object internal_GlobalDef(string setting, object defaultValue, bool restartIfChanged); - - [MethodImpl(MethodImplOptions.InternalCall)] - private static extern object internal_EditorDef(string setting, object defaultValue, bool restartIfChanged); - - [MethodImpl(MethodImplOptions.InternalCall)] private static extern string internal_FullTemplatesDir(); [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs b/modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs index 300cf7fcb9..53ff0891d5 100644 --- a/modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs +++ b/modules/mono/editor/GodotTools/GodotTools/MonoBottomPanel.cs @@ -3,6 +3,7 @@ using System; using System.IO; using Godot.Collections; using GodotTools.Internals; +using static GodotTools.Internals.Globals; using File = GodotTools.Utils.File; using Path = System.IO.Path; @@ -254,7 +255,7 @@ namespace GodotTools panelTabs = new TabContainer { TabAlign = TabContainer.TabAlignEnum.Left, - RectMinSize = new Vector2(0, 228) * Internal.EditorScale, + RectMinSize = new Vector2(0, 228) * EditorScale, SizeFlagsVertical = (int) SizeFlags.ExpandFill }; panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles")); @@ -266,7 +267,7 @@ namespace GodotTools // Builds tab panelBuildsTab = new VBoxContainer { - Name = "Builds", // TTR + Name = "Builds".TTR(), SizeFlagsHorizontal = (int) SizeFlags.ExpandFill }; panelTabs.AddChild(panelBuildsTab); @@ -276,7 +277,7 @@ namespace GodotTools var buildProjectBtn = new Button { - Text = "Build Project", // TTR + Text = "Build Project".TTR(), FocusMode = FocusModeEnum.None }; buildProjectBtn.Connect("pressed", this, nameof(BuildProjectPressed)); @@ -286,7 +287,7 @@ namespace GodotTools warningsBtn = new ToolButton { - Text = "Warnings", // TTR + Text = "Warnings".TTR(), ToggleMode = true, Pressed = true, Visible = false, @@ -297,7 +298,7 @@ namespace GodotTools errorsBtn = new ToolButton { - Text = "Errors", // TTR + Text = "Errors".TTR(), ToggleMode = true, Pressed = true, Visible = false, @@ -310,7 +311,7 @@ namespace GodotTools viewLogBtn = new Button { - Text = "View log", // TTR + Text = "View log".TTR(), FocusMode = FocusModeEnum.None, Visible = false }; diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index a3b5b450ef..3813c0ce45 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -231,24 +231,29 @@ uint32_t godot_icall_GodotSharpExport_GetExportedAssemblyDependencies(MonoString return GodotSharpExport::get_exported_assembly_dependencies(project_dll_name, project_dll_src_path, build_config, custom_lib_dir, dependencies); } -float godot_icall_Internal_EditorScale() { +float godot_icall_Globals_EditorScale() { return EDSCALE; } -MonoObject *godot_icall_Internal_GlobalDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) { +MonoObject *godot_icall_Globals_GlobalDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) { String setting = GDMonoMarshal::mono_string_to_godot(p_setting); Variant default_value = GDMonoMarshal::mono_object_to_variant(p_default_value); Variant result = _GLOBAL_DEF(setting, default_value, (bool)p_restart_if_changed); return GDMonoMarshal::variant_to_mono_object(result); } -MonoObject *godot_icall_Internal_EditorDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) { +MonoObject *godot_icall_Globals_EditorDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) { String setting = GDMonoMarshal::mono_string_to_godot(p_setting); Variant default_value = GDMonoMarshal::mono_object_to_variant(p_default_value); Variant result = _GLOBAL_DEF(setting, default_value, (bool)p_restart_if_changed); 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)); +} + MonoString *godot_icall_Internal_FullTemplatesDir() { String full_templates_dir = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG); return GDMonoMarshal::mono_string_from_godot(full_templates_dir); @@ -402,9 +407,6 @@ void register_editor_internal_calls() { mono_add_internal_call("GodotTools.GodotSharpExport::internal_GetExportedAssemblyDependencies", (void *)godot_icall_GodotSharpExport_GetExportedAssemblyDependencies); // Internals - mono_add_internal_call("GodotTools.Internals.Internal::internal_EditorScale", (void *)godot_icall_Internal_EditorScale); - mono_add_internal_call("GodotTools.Internals.Internal::internal_GlobalDef", (void *)godot_icall_Internal_GlobalDef); - mono_add_internal_call("GodotTools.Internals.Internal::internal_EditorDef", (void *)godot_icall_Internal_EditorDef); mono_add_internal_call("GodotTools.Internals.Internal::internal_FullTemplatesDir", (void *)godot_icall_Internal_FullTemplatesDir); mono_add_internal_call("GodotTools.Internals.Internal::internal_SimplifyGodotPath", (void *)godot_icall_Internal_SimplifyGodotPath); mono_add_internal_call("GodotTools.Internals.Internal::internal_IsOsxAppBundleInstalled", (void *)godot_icall_Internal_IsOsxAppBundleInstalled); @@ -424,6 +426,12 @@ void register_editor_internal_calls() { mono_add_internal_call("GodotTools.Internals.Internal::internal_GetScriptsMetadataOrNothing", (void *)godot_icall_Internal_GetScriptsMetadataOrNothing); mono_add_internal_call("GodotTools.Internals.Internal::internal_MonoWindowsInstallRoot", (void *)godot_icall_Internal_MonoWindowsInstallRoot); + // Globals + mono_add_internal_call("GodotTools.Internals.Globals::internal_EditorScale", (void *)godot_icall_Globals_EditorScale); + mono_add_internal_call("GodotTools.Internals.Globals::internal_GlobalDef", (void *)godot_icall_Globals_GlobalDef); + mono_add_internal_call("GodotTools.Internals.Globals::internal_EditorDef", (void *)godot_icall_Globals_EditorDef); + mono_add_internal_call("GodotTools.Internals.Globals::internal_TTR", (void *)godot_icall_Globals_TTR); + // Utils.OS mono_add_internal_call("GodotTools.Utils.OS::GetPlatformName", (void *)godot_icall_Utils_OS_GetPlatformName); } |