Mono: Add build project button and reload interval

This commit is contained in:
Ignacio Etcheverry 2017-10-29 05:57:20 +01:00
parent 452313ffb1
commit 27b7fb8e66
8 changed files with 96 additions and 17 deletions

View file

@ -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

View file

@ -269,7 +269,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
@ -348,7 +348,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();

View file

@ -89,6 +89,8 @@ public:
static bool make_api_sln(APIType p_api_type);
static bool build_project_blocking();
GodotSharpBuilds();
~GodotSharpBuilds();
};

View file

@ -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;
}

View file

@ -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

View file

@ -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);

View file

@ -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:

View file

@ -625,6 +625,8 @@ GDMono::~GDMono() {
if (gdmono_log)
memdelete(gdmono_log);
singleton = NULL;
}
_GodotSharp *_GodotSharp::singleton = NULL;