mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Allow custom monitors to select desired type
This commit is contained in:
parent
9cd297b6f2
commit
1a8306bbc1
9 changed files with 151 additions and 28 deletions
|
|
@ -88,6 +88,9 @@ String EditorPerformanceProfiler::_create_label(float p_value, Performance::Moni
|
|||
case Performance::MONITOR_TYPE_TIME: {
|
||||
return TS->format_number(rtos(p_value * 1000).pad_decimals(2)) + " " + TTR("ms");
|
||||
}
|
||||
case Performance::MONITOR_TYPE_PERCENTAGE: {
|
||||
return TS->format_number(rtos(p_value * 100).pad_decimals(2)) + "%";
|
||||
}
|
||||
default: {
|
||||
return TS->format_number(rtos(p_value));
|
||||
}
|
||||
|
|
@ -317,7 +320,7 @@ void EditorPerformanceProfiler::reset() {
|
|||
monitor_draw->queue_redraw();
|
||||
}
|
||||
|
||||
void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_names) {
|
||||
void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_names, const PackedInt32Array &p_types) {
|
||||
HashMap<StringName, int> names;
|
||||
for (int i = 0; i < p_names.size(); i++) {
|
||||
names.insert("custom:" + p_names[i], Performance::MONITOR_MAX + i);
|
||||
|
|
@ -340,6 +343,7 @@ void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_name
|
|||
}
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (const KeyValue<StringName, int> &E : names) {
|
||||
String name = String(E.key).replace_first("custom:", "");
|
||||
String base = "Custom";
|
||||
|
|
@ -347,7 +351,9 @@ void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_name
|
|||
base = name.get_slicec('/', 0);
|
||||
name = name.get_slicec('/', 1);
|
||||
}
|
||||
monitors.insert(E.key, Monitor(name, base, E.value, Performance::MONITOR_TYPE_QUANTITY, nullptr));
|
||||
Performance::MonitorType type = Performance::MonitorType(p_types[index]);
|
||||
monitors.insert(E.key, Monitor(name, base, E.value, type, nullptr));
|
||||
index++;
|
||||
}
|
||||
|
||||
_build_monitor_tree();
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ protected:
|
|||
|
||||
public:
|
||||
void reset();
|
||||
void update_monitors(const Vector<StringName> &p_names);
|
||||
void update_monitors(const Vector<StringName> &p_names, const PackedInt32Array &p_types);
|
||||
void add_profile_frame(const Vector<float> &p_values);
|
||||
List<float> *get_monitor_data(const StringName &p_name);
|
||||
EditorPerformanceProfiler();
|
||||
|
|
|
|||
|
|
@ -912,13 +912,25 @@ void ScriptEditorDebugger::_msg_show_selection_limit_warning(uint64_t p_thread_i
|
|||
}
|
||||
|
||||
void ScriptEditorDebugger::_msg_performance_profile_names(uint64_t p_thread_id, const Array &p_data) {
|
||||
ERR_FAIL_COND(p_data.size() != 2);
|
||||
Array name_data = p_data[0];
|
||||
Array type_data = p_data[1];
|
||||
|
||||
Vector<StringName> monitors;
|
||||
monitors.resize(p_data.size());
|
||||
for (int i = 0; i < p_data.size(); i++) {
|
||||
ERR_FAIL_COND(p_data[i].get_type() != Variant::STRING_NAME);
|
||||
monitors.set(i, p_data[i]);
|
||||
monitors.resize(name_data.size());
|
||||
for (int i = 0; i < name_data.size(); i++) {
|
||||
ERR_FAIL_COND(name_data[i].get_type() != Variant::STRING_NAME);
|
||||
monitors.set(i, name_data[i]);
|
||||
}
|
||||
performance_profiler->update_monitors(monitors);
|
||||
|
||||
PackedInt32Array types;
|
||||
types.resize(type_data.size());
|
||||
for (int i = 0; i < type_data.size(); i++) {
|
||||
ERR_FAIL_COND(type_data[i].get_type() != Variant::INT);
|
||||
types.set(i, type_data[i]);
|
||||
}
|
||||
|
||||
performance_profiler->update_monitors(monitors, types);
|
||||
}
|
||||
|
||||
void ScriptEditorDebugger::_msg_filesystem_update_file(uint64_t p_thread_id, const Array &p_data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue