mirror of
https://github.com/godotengine/godot.git
synced 2025-03-07 23:32:58 +08:00
Merge pull request #97492 from Geometror/profiler-autostart-indicator
Add profiler autostart indicator to EditorRunBar
This commit is contained in:
commit
7efe038eed
@ -34,6 +34,7 @@
|
||||
#include "core/os/os.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/gui/editor_run_bar.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "editor/themes/editor_theme_manager.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
@ -430,6 +431,7 @@ void EditorProfiler::_internal_profiles_pressed() {
|
||||
|
||||
void EditorProfiler::_autostart_toggled(bool p_toggled_on) {
|
||||
EditorSettings::get_singleton()->set_project_metadata("debug_options", "autostart_profiler", p_toggled_on);
|
||||
EditorRunBar::get_singleton()->update_profiler_autostart_indicator();
|
||||
}
|
||||
|
||||
void EditorProfiler::_notification(int p_what) {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "core/os/os.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/gui/editor_run_bar.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "scene/resources/image_texture.h"
|
||||
|
||||
@ -436,6 +437,7 @@ void EditorVisualProfiler::_clear_pressed() {
|
||||
|
||||
void EditorVisualProfiler::_autostart_toggled(bool p_toggled_on) {
|
||||
EditorSettings::get_singleton()->set_project_metadata("debug_options", "autostart_visual_profiler", p_toggled_on);
|
||||
EditorRunBar::get_singleton()->update_profiler_autostart_indicator();
|
||||
}
|
||||
|
||||
void EditorVisualProfiler::_notification(int p_what) {
|
||||
|
@ -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);
|
||||
|
@ -54,6 +54,9 @@ class EditorRunBar : public MarginContainer {
|
||||
|
||||
PanelContainer *main_panel = nullptr;
|
||||
HBoxContainer *main_hbox = nullptr;
|
||||
HBoxContainer *outer_hbox = nullptr;
|
||||
|
||||
Button *profiler_autostart_indicator = nullptr;
|
||||
|
||||
Button *play_button = nullptr;
|
||||
Button *pause_button = nullptr;
|
||||
@ -83,6 +86,8 @@ class EditorRunBar : public MarginContainer {
|
||||
void _run_scene(const String &p_scene_path = "");
|
||||
void _run_native(const Ref<EditorExportPreset> &p_preset);
|
||||
|
||||
void _profiler_autostart_indicator_pressed();
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
@ -106,6 +111,8 @@ public:
|
||||
void set_movie_maker_enabled(bool p_enabled);
|
||||
bool is_movie_maker_enabled() const;
|
||||
|
||||
void update_profiler_autostart_indicator();
|
||||
|
||||
Button *get_pause_button() { return pause_button; }
|
||||
|
||||
HBoxContainer *get_buttons_container();
|
||||
|
1
editor/icons/ProfilerAutostartWarning.svg
Normal file
1
editor/icons/ProfilerAutostartWarning.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><radialGradient xlink:href="#a" id="b" cx="12.039" cy="6.909" r="5.11" fx="11.285" fy="6.896" gradientTransform="matrix(1.19638 -1.2376 1.21246 1.17207 -11.159 13.888)" gradientUnits="userSpaceOnUse"/><radialGradient xlink:href="#a" id="d" cx="12.039" cy="6.909" r="5.11" fx="11.285" fy="6.896" gradientTransform="matrix(1.19638 -1.2376 1.21246 1.17207 -11.159 13.888)" gradientUnits="userSpaceOnUse"/><linearGradient id="a"><stop offset=".108" stop-color="#ffdd65"/><stop offset="1" stop-color="#ffdd65" stop-opacity="0"/></linearGradient><path id="c" fill="#ffdd65" d="M7.56 10.905L6.355 5.79l4.085 3.304z"/></defs><path fill="#ffdd65" d="M39.087-34.74a.507.507 0 00-.431.247l-3.045 5.074a.507.507 0 00.431.77h6.09a.507.507 0 00.435-.769l-3.045-5.074a.507.507 0 00-.431-.246zm-.507 1.523h1.015v2.538H38.58zm0 3.045h1.015v1.015H38.58zM41.79-25.317a7 7 0 00-7 7 7 7 0 007 7 7 7 0 007-7 7 7 0 00-7-7zm0 2a5 5 0 015 5 5 5 0 01-5 5 5 5 0 01-5-5 5 5 0 015-5z"/><path fill="none" stroke="#ffdd65" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M38.941-19.26a3 3 0 012.76-2.056 3 3 0 012.876 1.89"/><path fill="#ffdd65" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.7" d="M40.79-17.5l1-5 1 5z" paint-order="stroke markers fill"/><circle cx="41.789" cy="-16.317" r="2" fill="#ffdd65"/><g transform="translate(47.69 -41.492)"><path fill="none" stroke="url(#b)" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.797" d="M4.74 9.936a3.757 3.757 0 01.176-4.033 3.757 3.757 0 013.73-1.544 3.757 3.757 0 012.976 2.727"/><use xlink:href="#c" paint-order="stroke markers fill"/><circle cx="2.298" cy="13.837" r="1.797" fill="#ffdd65" transform="rotate(-32.152)"/><circle cx="8" cy="8" r="6.323" fill="none" stroke="#ffdd65" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.355" paint-order="fill markers stroke"/></g><g transform="translate(66.007 -44.302)"><path fill="none" stroke="url(#d)" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.797" d="M4.74 9.936a3.757 3.757 0 01.176-4.033 3.757 3.757 0 013.73-1.544 3.757 3.757 0 012.976 2.727"/><use xlink:href="#c" paint-order="stroke markers fill"/><circle cx="2.298" cy="13.837" r="1.797" fill="#ffdd65" transform="rotate(-32.152)"/><circle cx="8" cy="8" r="6.323" fill="none" stroke="#ffdd65" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.355" paint-order="fill markers stroke"/></g><path fill="#1d2229" d="M8 3a6 6 0 00-6 6 6 6 0 006 6 6 6 0 006-6 6 6 0 00-6-6zm0 2a4 4 0 014 4 4 4 0 01-4 4 4 4 0 01-4-4 4 4 0 014-4z" paint-order="fill markers stroke"/><path fill="#1d2229" d="M7 1h2v3H7z" paint-order="fill markers stroke"/><rect width="2" height="2" x="11.021" y="-6.293" fill="#1d2229" paint-order="fill markers stroke" ry=".5" transform="rotate(45)"/><rect width="6" height="1" x="5" y="1" fill="#1d2229" paint-order="fill markers stroke" ry=".5"/><circle cx="8" cy="9" r="1" fill="#1d2229" paint-order="fill markers stroke"/><path fill="#1d2229" d="M7 9h2L8 5.016z" paint-order="fill markers stroke"/><rect width="2" height="2" x="-1.707" y="5.021" fill="#1d2229" paint-order="fill markers stroke" ry=".5" transform="rotate(-45)"/><rect width="1" height="1" x="4.5" y="8.5" fill="#1d2229" paint-order="fill markers stroke" ry=".5"/><rect width="1" height="1" x="10.5" y="8.5" fill="#1d2229" paint-order="fill markers stroke" ry=".5"/><rect width="1" height="1" x="7.5" y="11.5" fill="#1d2229" paint-order="fill markers stroke" ry=".5"/><circle cx="20" cy="-21" r="6" fill="#ffdd65" paint-order="fill markers stroke"/><circle cx="20" cy="-21" r="4" fill="#fff" paint-order="fill markers stroke"/><path fill="#ffdd65" d="M19-29h2v3h-2z" paint-order="fill markers stroke"/><rect width="2" height="2" x="-1.707" y="-35.991" fill="#ffdd65" paint-order="fill markers stroke" ry=".5" transform="rotate(45)"/><rect width="6" height="1" x="17" y="-29" fill="#ffdd65" paint-order="fill markers stroke" ry=".5"/><circle cx="20" cy="-21" r="1" fill="#ffdd65" paint-order="fill markers stroke"/><path fill="#ffdd65" d="M19-21h2l-1-3.984z" paint-order="fill markers stroke"/><rect width="2" height="2" x="27.991" y="-7.707" fill="#ffdd65" paint-order="fill markers stroke" ry=".5" transform="rotate(-45)"/><rect width="1" height="1" x="16.5" y="-21.5" fill="#ffdd65" paint-order="fill markers stroke" ry=".5"/><rect width="1" height="1" x="22.5" y="-21.5" fill="#ffdd65" paint-order="fill markers stroke" ry=".5"/><rect width="1" height="1" x="19.5" y="-18.5" fill="#ffdd65" paint-order="fill markers stroke" ry=".5"/></svg>
|
After Width: | Height: | Size: 4.6 KiB |
@ -1963,6 +1963,14 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
|
||||
p_theme->set_color("movie_writer_icon_pressed", EditorStringName(EditorStyles), Color(0, 0, 0, 0.84));
|
||||
p_theme->set_color("movie_writer_icon_hover", EditorStringName(EditorStyles), Color(1, 1, 1, 0.9));
|
||||
p_theme->set_color("movie_writer_icon_hover_pressed", EditorStringName(EditorStyles), Color(0, 0, 0, 0.84));
|
||||
|
||||
// Profiler autostart indicator panel.
|
||||
Ref<StyleBoxFlat> style_profiler_autostart = style_launch_pad->duplicate();
|
||||
style_profiler_autostart->set_bg_color(Color(1, 0.867, 0.396));
|
||||
p_theme->set_type_variation("ProfilerAutostartIndicator", "Button");
|
||||
p_theme->set_stylebox(CoreStringName(normal), "ProfilerAutostartIndicator", style_profiler_autostart);
|
||||
p_theme->set_stylebox(SceneStringName(pressed), "ProfilerAutostartIndicator", style_profiler_autostart);
|
||||
p_theme->set_stylebox("hover", "ProfilerAutostartIndicator", style_profiler_autostart);
|
||||
}
|
||||
|
||||
// Standard GUI variations.
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "core/os/os.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/gui/editor_run_bar.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
|
||||
@ -227,6 +228,7 @@ void EditorNetworkProfiler::_clear_pressed() {
|
||||
|
||||
void EditorNetworkProfiler::_autostart_toggled(bool p_toggled_on) {
|
||||
EditorSettings::get_singleton()->set_project_metadata("debug_options", "autostart_network_profiler", p_toggled_on);
|
||||
EditorRunBar::get_singleton()->update_profiler_autostart_indicator();
|
||||
}
|
||||
|
||||
void EditorNetworkProfiler::_replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button) {
|
||||
|
Loading…
Reference in New Issue
Block a user