|
@@ -32,11 +32,13 @@
|
|
|
|
|
|
#include "core/config/project_settings.h"
|
|
|
#include "editor/debugger/editor_debugger_node.h"
|
|
|
+#include "editor/debugger/script_editor_debugger.h"
|
|
|
#include "editor/editor_command_palette.h"
|
|
|
#include "editor/editor_node.h"
|
|
|
#include "editor/editor_run_native.h"
|
|
|
#include "editor/editor_settings.h"
|
|
|
#include "editor/editor_string_names.h"
|
|
|
+#include "editor/gui/editor_bottom_panel.h"
|
|
|
#include "editor/gui/editor_quick_open_dialog.h"
|
|
|
#include "scene/gui/box_container.h"
|
|
|
#include "scene/gui/button.h"
|
|
@@ -52,6 +54,7 @@ void EditorRunBar::_notification(int p_what) {
|
|
|
|
|
|
case NOTIFICATION_THEME_CHANGED: {
|
|
|
_update_play_buttons();
|
|
|
+ profiler_autostart_indicator->set_button_icon(get_editor_theme_icon(SNAME("ProfilerAutostartWarning")));
|
|
|
pause_button->set_button_icon(get_editor_theme_icon(SNAME("Pause")));
|
|
|
stop_button->set_button_icon(get_editor_theme_icon(SNAME("Stop")));
|
|
|
|
|
@@ -261,6 +264,20 @@ void EditorRunBar::_run_native(const Ref<EditorExportPreset> &p_preset) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void EditorRunBar::_profiler_autostart_indicator_pressed() {
|
|
|
+ // Switch to the first profiler tab in the bottom panel.
|
|
|
+ EditorNode::get_singleton()->get_bottom_panel()->make_item_visible(EditorDebuggerNode::get_singleton(), true);
|
|
|
+
|
|
|
+ if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_profiler", false)) {
|
|
|
+ EditorDebuggerNode::get_singleton()->get_current_debugger()->switch_to_debugger(2);
|
|
|
+ } else if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_visual_profiler", false)) {
|
|
|
+ EditorDebuggerNode::get_singleton()->get_current_debugger()->switch_to_debugger(3);
|
|
|
+ } else {
|
|
|
+ // Switch to the network profiler tab.
|
|
|
+ EditorDebuggerNode::get_singleton()->get_current_debugger()->switch_to_debugger(7);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void EditorRunBar::play_main_scene(bool p_from_native) {
|
|
|
if (p_from_native) {
|
|
|
run_native->resume_run_native();
|
|
@@ -352,6 +369,28 @@ bool EditorRunBar::is_movie_maker_enabled() const {
|
|
|
return write_movie_button->is_pressed();
|
|
|
}
|
|
|
|
|
|
+void EditorRunBar::update_profiler_autostart_indicator() {
|
|
|
+ bool profiler_active = EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_profiler", false);
|
|
|
+ bool visual_profiler_active = EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_visual_profiler", false);
|
|
|
+ bool network_profiler_active = EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_network_profiler", false);
|
|
|
+ bool any_profiler_active = profiler_active | visual_profiler_active | network_profiler_active;
|
|
|
+ profiler_autostart_indicator->set_visible(any_profiler_active);
|
|
|
+ if (any_profiler_active) {
|
|
|
+ String tooltip = TTR("Autostart is enabled for the following profilers, which can have a performance impact:");
|
|
|
+ if (profiler_active) {
|
|
|
+ tooltip += "\n- " + TTR("Profiler");
|
|
|
+ }
|
|
|
+ if (visual_profiler_active) {
|
|
|
+ tooltip += "\n- " + TTR("Visual Profiler");
|
|
|
+ }
|
|
|
+ if (network_profiler_active) {
|
|
|
+ tooltip += "\n- " + TTR("Network Profiler");
|
|
|
+ }
|
|
|
+ tooltip += "\n\n" + TTR("Click to open the first profiler for which autostart is enabled.");
|
|
|
+ profiler_autostart_indicator->set_tooltip_text(tooltip);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
HBoxContainer *EditorRunBar::get_buttons_container() {
|
|
|
return main_hbox;
|
|
|
}
|
|
@@ -364,8 +403,20 @@ void EditorRunBar::_bind_methods() {
|
|
|
EditorRunBar::EditorRunBar() {
|
|
|
singleton = this;
|
|
|
|
|
|
+ outer_hbox = memnew(HBoxContainer);
|
|
|
+ add_child(outer_hbox);
|
|
|
+
|
|
|
+ // Use a button for the indicator since it comes with a background panel and pixel perfect centering of an icon.
|
|
|
+ profiler_autostart_indicator = memnew(Button);
|
|
|
+ profiler_autostart_indicator->set_icon_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
|
|
+ profiler_autostart_indicator->set_focus_mode(FOCUS_NONE);
|
|
|
+ profiler_autostart_indicator->set_theme_type_variation("ProfilerAutostartIndicator");
|
|
|
+ profiler_autostart_indicator->connect(SceneStringName(pressed), callable_mp(this, &EditorRunBar::_profiler_autostart_indicator_pressed));
|
|
|
+ outer_hbox->add_child(profiler_autostart_indicator);
|
|
|
+ update_profiler_autostart_indicator();
|
|
|
+
|
|
|
main_panel = memnew(PanelContainer);
|
|
|
- add_child(main_panel);
|
|
|
+ outer_hbox->add_child(main_panel);
|
|
|
|
|
|
main_hbox = memnew(HBoxContainer);
|
|
|
main_panel->add_child(main_hbox);
|