mirror of
https://github.com/godotengine/godot.git
synced 2024-12-15 10:12:40 +08:00
Merge pull request #32235 from Calinou/improve-network-profiler-ui
Improve the network profiler UI
This commit is contained in:
commit
11f75cdd3c
@ -43,9 +43,15 @@ void EditorNetworkProfiler::_bind_methods() {
|
||||
|
||||
void EditorNetworkProfiler::_notification(int p_what) {
|
||||
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
|
||||
activate->set_icon(get_icon("Play", "EditorIcons"));
|
||||
clear_button->set_icon(get_icon("Clear", "EditorIcons"));
|
||||
incoming_bandwidth_text->set_right_icon(get_icon("ArrowDown", "EditorIcons"));
|
||||
outgoing_bandwidth_text->set_right_icon(get_icon("ArrowUp", "EditorIcons"));
|
||||
|
||||
// This needs to be done here to set the faded color when the profiler is first opened
|
||||
incoming_bandwidth_text->add_color_override("font_color_uneditable", get_color("font_color", "Editor") * Color(1, 1, 1, 0.5));
|
||||
outgoing_bandwidth_text->add_color_override("font_color_uneditable", get_color("font_color", "Editor") * Color(1, 1, 1, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +119,14 @@ void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) {
|
||||
|
||||
incoming_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_incoming)));
|
||||
outgoing_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_outgoing)));
|
||||
|
||||
// Make labels more prominent when the bandwidth is greater than 0 to attract user attention
|
||||
incoming_bandwidth_text->add_color_override(
|
||||
"font_color_uneditable",
|
||||
get_color("font_color", "Editor") * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5));
|
||||
outgoing_bandwidth_text->add_color_override(
|
||||
"font_color_uneditable",
|
||||
get_color("font_color", "Editor") * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5));
|
||||
}
|
||||
|
||||
bool EditorNetworkProfiler::is_profiling() {
|
||||
@ -139,27 +153,32 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
|
||||
hb->add_spacer();
|
||||
|
||||
Label *lb = memnew(Label);
|
||||
lb->set_text("Down ");
|
||||
lb->set_text(TTR("Down"));
|
||||
hb->add_child(lb);
|
||||
|
||||
incoming_bandwidth_text = memnew(LineEdit);
|
||||
incoming_bandwidth_text->set_editable(false);
|
||||
incoming_bandwidth_text->set_custom_minimum_size(Size2(100, 0));
|
||||
incoming_bandwidth_text->set_custom_minimum_size(Size2(120, 0) * EDSCALE);
|
||||
incoming_bandwidth_text->set_align(LineEdit::Align::ALIGN_RIGHT);
|
||||
incoming_bandwidth_text->set_text("0.0 B/s");
|
||||
hb->add_child(incoming_bandwidth_text);
|
||||
|
||||
Control *down_up_spacer = memnew(Control);
|
||||
down_up_spacer->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
|
||||
hb->add_child(down_up_spacer);
|
||||
|
||||
lb = memnew(Label);
|
||||
lb->set_text("Up ");
|
||||
lb->set_text(TTR("Up"));
|
||||
hb->add_child(lb);
|
||||
|
||||
outgoing_bandwidth_text = memnew(LineEdit);
|
||||
outgoing_bandwidth_text->set_editable(false);
|
||||
outgoing_bandwidth_text->set_custom_minimum_size(Size2(100, 0));
|
||||
outgoing_bandwidth_text->set_custom_minimum_size(Size2(120, 0) * EDSCALE);
|
||||
outgoing_bandwidth_text->set_align(LineEdit::Align::ALIGN_RIGHT);
|
||||
outgoing_bandwidth_text->set_text("0.0 B/s");
|
||||
hb->add_child(outgoing_bandwidth_text);
|
||||
|
||||
// Set initial texts in the incoming/outgoing bandwidth labels
|
||||
set_bandwidth(0, 0);
|
||||
|
||||
counters_display = memnew(Tree);
|
||||
counters_display->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
|
||||
counters_display->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
@ -169,7 +188,7 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
|
||||
counters_display->set_column_titles_visible(true);
|
||||
counters_display->set_column_title(0, TTR("Node"));
|
||||
counters_display->set_column_expand(0, true);
|
||||
counters_display->set_column_min_width(0, 60);
|
||||
counters_display->set_column_min_width(0, 60 * EDSCALE);
|
||||
counters_display->set_column_title(1, TTR("Incoming RPC"));
|
||||
counters_display->set_column_expand(1, false);
|
||||
counters_display->set_column_min_width(1, 120 * EDSCALE);
|
||||
|
1
editor/icons/icon_arrow_down.svg
Normal file
1
editor/icons/icon_arrow_down.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 3.002a1 1 0 0 0 -.69336.29102 1 1 0 0 0 0 1.4141l2.293 2.293h-4.5859c-.55228 0-1 .4477-1 1s.44772 1 1 1h4.5859l-2.293 2.293a1 1 0 0 0 0 1.4141 1 1 0 0 0 1.4141 0l4-4a1.0001 1.0001 0 0 0 0-1.4141l-4-4a1 1 0 0 0 -.7207-.29102z" fill="#e0e0e0" fill-opacity=".99608" transform="matrix(0 1 -1 0 16.0021 -.00004)"/></svg>
|
After Width: | Height: | Size: 410 B |
1
editor/icons/icon_arrow_up.svg
Normal file
1
editor/icons/icon_arrow_up.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8.00008 1049.4022a1 1 0 0 0 .69336-.291 1 1 0 0 0 0-1.4141l-2.293-2.293h4.5859c.55228 0 1-.4477 1-1s-.44772-1-1-1h-4.5859l2.293-2.293a1 1 0 0 0 0-1.4141 1 1 0 0 0 -1.4141 0l-4 4a1.0001 1.0001 0 0 0 0 1.4141l4 4a1 1 0 0 0 .7207.291z" fill="#e0e0e0" fill-opacity=".99608" transform="matrix(0 1 -1 0 1052.4021 -.00004)"/></svg>
|
After Width: | Height: | Size: 417 B |
Loading…
Reference in New Issue
Block a user