summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-09-22 21:19:37 +0200
committerGitHub <noreply@github.com>2019-09-22 21:19:37 +0200
commit11f75cdd3ca7cf1cce886ffac7cdd19efbc32ace (patch)
treee856f42a990033b66de245002d0033d18cae9cc8 /editor
parent7174677fc8c8de2c24da508910368cb16b56199d (diff)
parentba8601f557bae4734ea8a0dcb5760ae4dbe04092 (diff)
Merge pull request #32235 from Calinou/improve-network-profiler-ui
Improve the network profiler UI
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_network_profiler.cpp35
-rw-r--r--editor/icons/icon_arrow_down.svg1
-rw-r--r--editor/icons/icon_arrow_up.svg1
3 files changed, 29 insertions, 8 deletions
diff --git a/editor/editor_network_profiler.cpp b/editor/editor_network_profiler.cpp
index b90fe96cee..8482c4e38a 100644
--- a/editor/editor_network_profiler.cpp
+++ b/editor/editor_network_profiler.cpp
@@ -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);
diff --git a/editor/icons/icon_arrow_down.svg b/editor/icons/icon_arrow_down.svg
new file mode 100644
index 0000000000..49a93e6e28
--- /dev/null
+++ b/editor/icons/icon_arrow_down.svg
@@ -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> \ No newline at end of file
diff --git a/editor/icons/icon_arrow_up.svg b/editor/icons/icon_arrow_up.svg
new file mode 100644
index 0000000000..9bf19a6a12
--- /dev/null
+++ b/editor/icons/icon_arrow_up.svg
@@ -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> \ No newline at end of file