summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2020-03-02 22:07:48 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2020-03-02 22:09:38 +0100
commit46bc1a7c3f9c27202d274e4afa3ae87d93c7f59c (patch)
tree0c7f35b8f5510fcffd02c45e056d7352bbd89c0a
parentc9768f15f7bb194622b9020ab2614d47ac7e63dd (diff)
Improve the GIProbe editor contextual label
- Change the label color depending on the estimated performance (green = fast, yellow = average, red = slow). - Use the Unicode multiplication symbol. - Make the label translatable.
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp
index ddcbb11f7c..c077c23e8a 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -70,22 +70,33 @@ void GIProbeEditorPlugin::_notification(int p_what) {
return;
}
- String text;
-
- Vector3i size = gi_probe->get_estimated_cell_size();
- text = itos(size.x) + ", " + itos(size.y) + ", " + itos(size.z);
+ const Vector3i size = gi_probe->get_estimated_cell_size();
+ String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z);
int data_size = 4;
if (GLOBAL_GET("rendering/quality/gi_probes/anisotropic")) {
data_size += 4;
}
- text += " - VRAM Size: " + String::num(size.x * size.y * size.z * data_size / (1024.0 * 1024.0), 2) + " Mb.";
+ const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0);
+ text += " - " + vformat(TTR("VRAM Size: %s MB"), String::num(size_mb, 2));
if (bake_info->get_text() == text) {
return;
}
- bake_info->add_color_override("font_color", bake_info->get_color("success_color", "Editor"));
+ // Color the label depending on the estimated performance level.
+ Color color;
+ if (size_mb <= 16.0 + CMP_EPSILON) {
+ // Fast.
+ color = bake_info->get_color("success_color", "Editor");
+ } else if (size_mb <= 64.0 + CMP_EPSILON) {
+ // Medium.
+ color = bake_info->get_color("warning_color", "Editor");
+ } else {
+ // Slow.
+ color = bake_info->get_color("error_color", "Editor");
+ }
+ bake_info->add_color_override("font_color", color);
bake_info->set_text(text);
}
}