Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make performance monitor names translatable #91927

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions editor/debugger/editor_performance_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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"));
Expand All @@ -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();
Expand Down
66 changes: 33 additions & 33 deletions main/performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"),

};

Expand Down
Loading