2
0
Эх сурвалжийг харах

Merge pull request #105770 from Calinou/editor-progress-improve-cli-reporting

Improve editor progress reporting on the command line
Thaddeus Crews 4 сар өмнө
parent
commit
9f65708fe0

+ 9 - 3
editor/editor_node.cpp

@@ -5134,11 +5134,16 @@ bool EditorNode::is_object_of_custom_type(const Object *p_object, const StringNa
 	return false;
 }
 
+// Used to track the progress of tasks in the CLI output (since we don't have any other frame of reference).
+// All tasks run sequentially, so we can just keep a single counter.
+static int progress_total_steps = 0;
+
 void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) {
 	if (!singleton) {
 		return;
 	} else if (singleton->cmdline_mode) {
-		print_line(p_task + ": begin: " + p_label + " steps: " + itos(p_steps));
+		print_line_rich(vformat("[   0%% ] [color=gray][b]%s[/b] | Started %s (%d steps)[/color]", p_task, p_label, p_steps));
+		progress_total_steps = p_steps;
 	} else if (singleton->progress_dialog) {
 		singleton->progress_dialog->add_task(p_task, p_label, p_steps, p_can_cancel);
 	}
@@ -5148,7 +5153,8 @@ bool EditorNode::progress_task_step(const String &p_task, const String &p_state,
 	if (!singleton) {
 		return false;
 	} else if (singleton->cmdline_mode) {
-		print_line("\t" + p_task + ": step " + itos(p_step) + ": " + p_state);
+		const int percent = (p_step / float(progress_total_steps + 1)) * 100;
+		print_line_rich(vformat("[%4d%% ] [color=gray][b]%s[/b] | %s[/color]", percent, p_task, p_state));
 		return false;
 	} else if (singleton->progress_dialog) {
 		return singleton->progress_dialog->task_step(p_task, p_state, p_step, p_force_refresh);
@@ -5161,7 +5167,7 @@ void EditorNode::progress_end_task(const String &p_task) {
 	if (!singleton) {
 		return;
 	} else if (singleton->cmdline_mode) {
-		print_line(p_task + ": end");
+		print_line_rich(vformat("[color=green][ DONE ][/color] [b]%s[/b]\n", p_task));
 	} else if (singleton->progress_dialog) {
 		singleton->progress_dialog->end_task(p_task);
 	}