diff options
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/SCsub | 4 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 4 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_builds.cpp | 4 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_builds.h | 2 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_editor.cpp | 61 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_editor.h | 23 | ||||
-rw-r--r-- | modules/mono/editor/mono_bottom_panel.cpp | 15 | ||||
-rw-r--r-- | modules/mono/editor/mono_bottom_panel.h | 2 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 2 | ||||
-rw-r--r-- | modules/mono/mono_reg_utils.py | 12 |
10 files changed, 105 insertions, 24 deletions
diff --git a/modules/mono/SCsub b/modules/mono/SCsub index c3ab9212c7..27e60c4623 100644 --- a/modules/mono/SCsub +++ b/modules/mono/SCsub @@ -137,8 +137,8 @@ def mono_build_solution(source, target, env): msbuild_info = find_msbuild_windows() if msbuild_info is None: raise RuntimeError('Cannot find MSBuild executable') - msbuild_path = msbuild_windows[0] - framework_path_override = msbuild_windows[1] + msbuild_path = msbuild_info[0] + framework_path_override = msbuild_info[1] else: msbuild_path = find_msbuild_unix('msbuild') if msbuild_path is None: diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 2e1cdf8d01..3d91a6de6c 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -477,6 +477,7 @@ void CSharpLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft (void)p_script; // UNUSED #ifdef TOOLS_ENABLED + MonoReloadNode::get_singleton()->restart_reload_timer(); reload_assemblies_if_needed(p_soft_reload); #endif } @@ -624,6 +625,9 @@ void CSharpLanguage::reload_assemblies_if_needed(bool p_soft_reload) { //if instance states were saved, set them! } + + if (Engine::get_singleton()->is_editor_hint()) + EditorNode::get_singleton()->get_property_editor()->update_tree(); } #endif diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp index e02ba48010..83d2bb1471 100644 --- a/modules/mono/editor/godotsharp_builds.cpp +++ b/modules/mono/editor/godotsharp_builds.cpp @@ -278,7 +278,7 @@ bool GodotSharpBuilds::make_api_sln(GodotSharpBuilds::APIType p_api_type) { return true; } -bool godotsharp_build_callback() { +bool GodotSharpBuilds::build_project_blocking() { if (!FileAccess::exists(GodotSharpDirs::get_project_sln_path())) return true; // No solution to build @@ -357,7 +357,7 @@ GodotSharpBuilds::GodotSharpBuilds() { singleton = this; - EditorNode::get_singleton()->add_build_callback(&godotsharp_build_callback); + EditorNode::get_singleton()->add_build_callback(&GodotSharpBuilds::build_project_blocking); // Build tool settings EditorSettings *ed_settings = EditorSettings::get_singleton(); diff --git a/modules/mono/editor/godotsharp_builds.h b/modules/mono/editor/godotsharp_builds.h index 3486f9f3e9..7d2f38a774 100644 --- a/modules/mono/editor/godotsharp_builds.h +++ b/modules/mono/editor/godotsharp_builds.h @@ -92,6 +92,8 @@ public: static bool make_api_sln(APIType p_api_type); + static bool build_project_blocking(); + GodotSharpBuilds(); ~GodotSharpBuilds(); }; diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp index ebfbdafeaf..39c57ee0be 100644 --- a/modules/mono/editor/godotsharp_editor.cpp +++ b/modules/mono/editor/godotsharp_editor.cpp @@ -46,21 +46,6 @@ #include "../utils/mono_reg_utils.h" #endif -class MonoReloadNode : public Node { - GDCLASS(MonoReloadNode, Node) - -protected: - void _notification(int p_what) { - switch (p_what) { - case MainLoop::NOTIFICATION_WM_FOCUS_IN: { - CSharpLanguage::get_singleton()->reload_assemblies_if_needed(true); - } break; - default: { - } break; - }; - } -}; - GodotSharpEditor *GodotSharpEditor::singleton = NULL; bool GodotSharpEditor::_create_project_solution() { @@ -258,3 +243,49 @@ GodotSharpEditor::~GodotSharpEditor() { monodevel_instance = NULL; } } + +MonoReloadNode *MonoReloadNode::singleton = NULL; + +void MonoReloadNode::_reload_timer_timeout() { + + CSharpLanguage::get_singleton()->reload_assemblies_if_needed(false); +} + +void MonoReloadNode::restart_reload_timer() { + + reload_timer->stop(); + reload_timer->start(); +} + +void MonoReloadNode::_bind_methods() { + + ClassDB::bind_method(D_METHOD("_reload_timer_timeout"), &MonoReloadNode::_reload_timer_timeout); +} + +void MonoReloadNode::_notification(int p_what) { + switch (p_what) { + case MainLoop::NOTIFICATION_WM_FOCUS_IN: { + restart_reload_timer(); + CSharpLanguage::get_singleton()->reload_assemblies_if_needed(true); + } break; + default: { + } break; + }; +} + +MonoReloadNode::MonoReloadNode() { + + singleton = this; + + reload_timer = memnew(Timer); + add_child(reload_timer); + reload_timer->set_one_shot(false); + reload_timer->set_wait_time(EDITOR_DEF("mono/assembly_watch_interval_sec", 0.5)); + reload_timer->connect("timeout", this, "_reload_timer_timeout"); + reload_timer->start(); +} + +MonoReloadNode::~MonoReloadNode() { + + singleton = NULL; +} diff --git a/modules/mono/editor/godotsharp_editor.h b/modules/mono/editor/godotsharp_editor.h index 1ecb8c7a94..7b4b50b172 100644 --- a/modules/mono/editor/godotsharp_editor.h +++ b/modules/mono/editor/godotsharp_editor.h @@ -84,4 +84,27 @@ public: ~GodotSharpEditor(); }; +class MonoReloadNode : public Node { + GDCLASS(MonoReloadNode, Node) + + Timer *reload_timer; + + void _reload_timer_timeout(); + + static MonoReloadNode *singleton; + +protected: + static void _bind_methods(); + + void _notification(int p_what); + +public: + _FORCE_INLINE_ static MonoReloadNode *get_singleton() { return singleton; } + + void restart_reload_timer(); + + MonoReloadNode(); + ~MonoReloadNode(); +}; + #endif // GODOTSHARP_EDITOR_H diff --git a/modules/mono/editor/mono_bottom_panel.cpp b/modules/mono/editor/mono_bottom_panel.cpp index 8d6a618ee8..31dc09856a 100644 --- a/modules/mono/editor/mono_bottom_panel.cpp +++ b/modules/mono/editor/mono_bottom_panel.cpp @@ -139,6 +139,14 @@ void MonoBottomPanel::_errors_toggled(bool p_pressed) { build_tab->_update_issues_list(); } +void MonoBottomPanel::_build_project_pressed() { + + GodotSharpBuilds::get_singleton()->build_project_blocking(); + + MonoReloadNode::get_singleton()->restart_reload_timer(); + CSharpLanguage::get_singleton()->reload_assemblies_if_needed(true); +} + void MonoBottomPanel::_notification(int p_what) { switch (p_what) { @@ -153,6 +161,7 @@ void MonoBottomPanel::_notification(int p_what) { void MonoBottomPanel::_bind_methods() { + ClassDB::bind_method(D_METHOD("_build_project_pressed"), &MonoBottomPanel::_build_project_pressed); ClassDB::bind_method(D_METHOD("_warnings_toggled", "pressed"), &MonoBottomPanel::_warnings_toggled); ClassDB::bind_method(D_METHOD("_errors_toggled", "pressed"), &MonoBottomPanel::_errors_toggled); ClassDB::bind_method(D_METHOD("_build_tab_item_selected", "idx"), &MonoBottomPanel::_build_tab_item_selected); @@ -187,6 +196,12 @@ MonoBottomPanel::MonoBottomPanel(EditorNode *p_editor) { toolbar_hbc->set_h_size_flags(SIZE_EXPAND_FILL); panel_builds_tab->add_child(toolbar_hbc); + ToolButton *build_project_btn = memnew(ToolButton); + build_project_btn->set_text("Build Project"); + build_project_btn->set_focus_mode(FOCUS_NONE); + build_project_btn->connect("pressed", this, "_build_project_pressed"); + toolbar_hbc->add_child(build_project_btn); + toolbar_hbc->add_spacer(); warnings_btn = memnew(ToolButton); diff --git a/modules/mono/editor/mono_bottom_panel.h b/modules/mono/editor/mono_bottom_panel.h index 83da5b9809..5cc4aa3240 100644 --- a/modules/mono/editor/mono_bottom_panel.h +++ b/modules/mono/editor/mono_bottom_panel.h @@ -61,6 +61,8 @@ class MonoBottomPanel : public VBoxContainer { void _warnings_toggled(bool p_pressed); void _errors_toggled(bool p_pressed); + void _build_project_pressed(); + static MonoBottomPanel *singleton; protected: diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 6d7cde95df..904a8ae2c7 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -625,6 +625,8 @@ GDMono::~GDMono() { if (gdmono_log) memdelete(gdmono_log); + + singleton = NULL; } _GodotSharp *_GodotSharp::singleton = NULL; diff --git a/modules/mono/mono_reg_utils.py b/modules/mono/mono_reg_utils.py index 22c4aeaf4c..8ddddb3a24 100644 --- a/modules/mono/mono_reg_utils.py +++ b/modules/mono/mono_reg_utils.py @@ -1,6 +1,8 @@ import os import platform +from compat import decode_utf8 + if os.name == 'nt': import sys if sys.version_info < (3,): @@ -12,7 +14,7 @@ if os.name == 'nt': def _reg_open_key(key, subkey): try: return winreg.OpenKey(key, subkey) - except WindowsError, OSError: + except (WindowsError, OSError): if platform.architecture()[0] == '32bit': bitness_sam = winreg.KEY_WOW64_64KEY else: @@ -40,7 +42,7 @@ def _find_mono_in_reg(subkey, bits): with _reg_open_key_bits(winreg.HKEY_LOCAL_MACHINE, subkey, bits) as hKey: value, regtype = winreg.QueryValueEx(hKey, 'SdkInstallRoot') return value - except WindowsError, OSError: + except (WindowsError, OSError): return None @@ -79,7 +81,7 @@ def find_msbuild_tools_path_reg(): lines = subprocess.check_output([vswhere] + vswhere_args).splitlines() for line in lines: - parts = line.split(':', 1) + parts = decode_utf8(line).split(':', 1) if len(parts) < 2 or parts[0] != 'installationPath': continue @@ -96,7 +98,7 @@ def find_msbuild_tools_path_reg(): print('Error reading output from vswhere: ' + e.message) except WindowsError: pass # Fine, vswhere not found - except subprocess.CalledProcessError, OSError: + except (subprocess.CalledProcessError, OSError): pass # Try to find 14.0 in the Registry @@ -106,7 +108,7 @@ def find_msbuild_tools_path_reg(): with _reg_open_key(winreg.HKEY_LOCAL_MACHINE, subkey) as hKey: value, regtype = winreg.QueryValueEx(hKey, 'MSBuildToolsPath') return value - except WindowsError, OSError: + except (WindowsError, OSError): return '' return '' |