Make performance monitor names translatable

This commit is contained in:
Haoyu Qiu 2024-05-14 09:35:25 +08:00
parent 557f63d037
commit d33e79f299
2 changed files with 48 additions and 38 deletions

View File

@ -31,6 +31,7 @@
#include "editor_performance_profiler.h"
#include "editor/editor_property_name_processor.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
@ -231,7 +232,7 @@ TreeItem *EditorPerformanceProfiler::_get_monitor_base(const StringName &p_base_
}
TreeItem *base = monitor_tree->create_item(monitor_tree->get_root());
base->set_text(0, p_base_name);
base->set_text(0, EditorPropertyNameProcessor::get_singleton()->process_name(p_base_name, EditorPropertyNameProcessor::get_settings_style()));
base->set_editable(0, false);
base->set_selectable(0, false);
base->set_expand_right(0, true);
@ -248,7 +249,7 @@ TreeItem *EditorPerformanceProfiler::_create_monitor_item(const StringName &p_mo
item->set_editable(0, true);
item->set_selectable(0, false);
item->set_selectable(1, false);
item->set_text(0, p_monitor_name);
item->set_text(0, EditorPropertyNameProcessor::get_singleton()->process_name(p_monitor_name, EditorPropertyNameProcessor::get_settings_style()));
return item;
}
@ -378,6 +379,12 @@ void EditorPerformanceProfiler::_notification(int p_what) {
E.value->set_custom_font(0, get_theme_font(SNAME("bold"), EditorStringName(EditorFonts)));
}
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
_build_monitor_tree();
}
} break;
}
}
@ -386,6 +393,7 @@ EditorPerformanceProfiler::EditorPerformanceProfiler() {
set_split_offset(340 * EDSCALE);
monitor_tree = memnew(Tree);
monitor_tree->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
monitor_tree->set_columns(2);
monitor_tree->set_column_title(0, TTR("Monitor"));
monitor_tree->set_column_title(1, TTR("Value"));
@ -411,9 +419,11 @@ EditorPerformanceProfiler::EditorPerformanceProfiler() {
monitor_draw->add_child(info_message);
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
String base = EditorPropertyNameProcessor::get_singleton()->process_name(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 0), EditorPropertyNameProcessor::STYLE_CAPITALIZED);
String name = EditorPropertyNameProcessor::get_singleton()->process_name(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 1), EditorPropertyNameProcessor::STYLE_CAPITALIZED);
monitors.insert(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)), Monitor(name, base, i, Performance::get_singleton()->get_monitor_type(Performance::Monitor(i)), nullptr));
const Performance::Monitor monitor = Performance::Monitor(i);
const String path = Performance::get_singleton()->get_monitor_name(monitor);
const String base = path.get_slicec('/', 0);
const String name = path.get_slicec('/', 1);
monitors.insert(path, Monitor(name, base, i, Performance::get_singleton()->get_monitor_type(monitor), nullptr));
}
_build_monitor_tree();

View File

@ -106,41 +106,41 @@ int Performance::_get_node_count() const {
String Performance::get_monitor_name(Monitor p_monitor) const {
ERR_FAIL_INDEX_V(p_monitor, MONITOR_MAX, String());
static const char *names[MONITOR_MAX] = {
"time/fps",
"time/process",
"time/physics_process",
"time/navigation_process",
"memory/static",
"memory/static_max",
"memory/msg_buf_max",
"object/objects",
"object/resources",
"object/nodes",
"object/orphan_nodes",
"raster/total_objects_drawn",
"raster/total_primitives_drawn",
"raster/total_draw_calls",
"video/video_mem",
"video/texture_mem",
"video/buffer_mem",
"physics_2d/active_objects",
"physics_2d/collision_pairs",
"physics_2d/islands",
PNAME("time/fps"),
PNAME("time/process"),
PNAME("time/physics_process"),
PNAME("time/navigation_process"),
PNAME("memory/static"),
PNAME("memory/static_max"),
PNAME("memory/msg_buf_max"),
PNAME("object/objects"),
PNAME("object/resources"),
PNAME("object/nodes"),
PNAME("object/orphan_nodes"),
PNAME("raster/total_objects_drawn"),
PNAME("raster/total_primitives_drawn"),
PNAME("raster/total_draw_calls"),
PNAME("video/video_mem"),
PNAME("video/texture_mem"),
PNAME("video/buffer_mem"),
PNAME("physics_2d/active_objects"),
PNAME("physics_2d/collision_pairs"),
PNAME("physics_2d/islands"),
#ifndef _3D_DISABLED
"physics_3d/active_objects",
"physics_3d/collision_pairs",
"physics_3d/islands",
PNAME("physics_3d/active_objects"),
PNAME("physics_3d/collision_pairs"),
PNAME("physics_3d/islands"),
#endif // _3D_DISABLED
"audio/driver/output_latency",
"navigation/active_maps",
"navigation/regions",
"navigation/agents",
"navigation/links",
"navigation/polygons",
"navigation/edges",
"navigation/edges_merged",
"navigation/edges_connected",
"navigation/edges_free",
PNAME("audio/driver/output_latency"),
PNAME("navigation/active_maps"),
PNAME("navigation/regions"),
PNAME("navigation/agents"),
PNAME("navigation/links"),
PNAME("navigation/polygons"),
PNAME("navigation/edges"),
PNAME("navigation/edges_merged"),
PNAME("navigation/edges_connected"),
PNAME("navigation/edges_free"),
};