|
@@ -34,6 +34,7 @@
|
|
#include "editor/editor_settings.h"
|
|
#include "editor/editor_settings.h"
|
|
#include "editor/editor_string_names.h"
|
|
#include "editor/editor_string_names.h"
|
|
#include "editor/themes/editor_scale.h"
|
|
#include "editor/themes/editor_scale.h"
|
|
|
|
+#include "scene/gui/check_box.h"
|
|
|
|
|
|
void EditorNetworkProfiler::_bind_methods() {
|
|
void EditorNetworkProfiler::_bind_methods() {
|
|
ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable")));
|
|
ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable")));
|
|
@@ -170,15 +171,42 @@ void EditorNetworkProfiler::add_node_data(const NodeInfo &p_info) {
|
|
}
|
|
}
|
|
|
|
|
|
void EditorNetworkProfiler::_activate_pressed() {
|
|
void EditorNetworkProfiler::_activate_pressed() {
|
|
|
|
+ _update_button_text();
|
|
|
|
+
|
|
if (activate->is_pressed()) {
|
|
if (activate->is_pressed()) {
|
|
refresh_timer->start();
|
|
refresh_timer->start();
|
|
|
|
+ } else {
|
|
|
|
+ refresh_timer->stop();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ emit_signal(SNAME("enable_profiling"), activate->is_pressed());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorNetworkProfiler::_update_button_text() {
|
|
|
|
+ if (activate->is_pressed()) {
|
|
activate->set_icon(theme_cache.stop_icon);
|
|
activate->set_icon(theme_cache.stop_icon);
|
|
activate->set_text(TTR("Stop"));
|
|
activate->set_text(TTR("Stop"));
|
|
} else {
|
|
} else {
|
|
- refresh_timer->stop();
|
|
|
|
activate->set_icon(theme_cache.play_icon);
|
|
activate->set_icon(theme_cache.play_icon);
|
|
activate->set_text(TTR("Start"));
|
|
activate->set_text(TTR("Start"));
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorNetworkProfiler::started() {
|
|
|
|
+ if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_network_profiler", false)) {
|
|
|
|
+ set_profiling(true);
|
|
|
|
+ refresh_timer->start();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorNetworkProfiler::stopped() {
|
|
|
|
+ set_profiling(false);
|
|
|
|
+ refresh_timer->stop();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorNetworkProfiler::set_profiling(bool p_pressed) {
|
|
|
|
+ activate->set_pressed(p_pressed);
|
|
|
|
+ _update_button_text();
|
|
emit_signal(SNAME("enable_profiling"), activate->is_pressed());
|
|
emit_signal(SNAME("enable_profiling"), activate->is_pressed());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -192,6 +220,10 @@ void EditorNetworkProfiler::_clear_pressed() {
|
|
refresh_replication_data();
|
|
refresh_replication_data();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void EditorNetworkProfiler::_autostart_toggled(bool p_toggled_on) {
|
|
|
|
+ EditorSettings::get_singleton()->set_project_metadata("debug_options", "autostart_network_profiler", p_toggled_on);
|
|
|
|
+}
|
|
|
|
+
|
|
void EditorNetworkProfiler::_replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button) {
|
|
void EditorNetworkProfiler::_replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button) {
|
|
if (!p_item) {
|
|
if (!p_item) {
|
|
return;
|
|
return;
|
|
@@ -268,6 +300,12 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
|
|
clear_button->connect(SceneStringName(pressed), callable_mp(this, &EditorNetworkProfiler::_clear_pressed));
|
|
clear_button->connect(SceneStringName(pressed), callable_mp(this, &EditorNetworkProfiler::_clear_pressed));
|
|
hb->add_child(clear_button);
|
|
hb->add_child(clear_button);
|
|
|
|
|
|
|
|
+ CheckBox *autostart_checkbox = memnew(CheckBox);
|
|
|
|
+ autostart_checkbox->set_text(TTR("Autostart"));
|
|
|
|
+ autostart_checkbox->set_pressed(EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_network_profiler", false));
|
|
|
|
+ autostart_checkbox->connect(SceneStringName(toggled), callable_mp(this, &EditorNetworkProfiler::_autostart_toggled));
|
|
|
|
+ hb->add_child(autostart_checkbox);
|
|
|
|
+
|
|
hb->add_spacer();
|
|
hb->add_spacer();
|
|
|
|
|
|
Label *lb = memnew(Label);
|
|
Label *lb = memnew(Label);
|