mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 06:01:14 +00:00
Merge pull request #109391 from mihe/headless-progress-percentage
Fix headless import/export reporting progress greater than 100%
This commit is contained in:
commit
b438d2149b
1 changed files with 4 additions and 4 deletions
|
|
@ -5354,15 +5354,14 @@ bool EditorNode::is_object_of_custom_type(const Object *p_object, const StringNa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to track the progress of tasks in the CLI output (since we don't have any other frame of reference).
|
// 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 HashMap<String, int> progress_total_steps;
|
||||||
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) {
|
void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) {
|
||||||
if (!singleton) {
|
if (!singleton) {
|
||||||
return;
|
return;
|
||||||
} else if (singleton->cmdline_mode) {
|
} else if (singleton->cmdline_mode) {
|
||||||
print_line_rich(vformat("[ 0%% ] [color=gray][b]%s[/b] | Started %s (%d steps)[/color]", p_task, p_label, 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;
|
progress_total_steps[p_task] = p_steps;
|
||||||
} else if (singleton->progress_dialog) {
|
} else if (singleton->progress_dialog) {
|
||||||
singleton->progress_dialog->add_task(p_task, p_label, p_steps, p_can_cancel);
|
singleton->progress_dialog->add_task(p_task, p_label, p_steps, p_can_cancel);
|
||||||
}
|
}
|
||||||
|
|
@ -5372,7 +5371,7 @@ bool EditorNode::progress_task_step(const String &p_task, const String &p_state,
|
||||||
if (!singleton) {
|
if (!singleton) {
|
||||||
return false;
|
return false;
|
||||||
} else if (singleton->cmdline_mode) {
|
} else if (singleton->cmdline_mode) {
|
||||||
const int percent = (p_step / float(progress_total_steps + 1)) * 100;
|
const int percent = (p_step / float(progress_total_steps[p_task] + 1)) * 100;
|
||||||
print_line_rich(vformat("[%4d%% ] [color=gray][b]%s[/b] | %s[/color]", percent, p_task, p_state));
|
print_line_rich(vformat("[%4d%% ] [color=gray][b]%s[/b] | %s[/color]", percent, p_task, p_state));
|
||||||
return false;
|
return false;
|
||||||
} else if (singleton->progress_dialog) {
|
} else if (singleton->progress_dialog) {
|
||||||
|
|
@ -5386,6 +5385,7 @@ void EditorNode::progress_end_task(const String &p_task) {
|
||||||
if (!singleton) {
|
if (!singleton) {
|
||||||
return;
|
return;
|
||||||
} else if (singleton->cmdline_mode) {
|
} else if (singleton->cmdline_mode) {
|
||||||
|
progress_total_steps.erase(p_task);
|
||||||
print_line_rich(vformat("[color=green][ DONE ][/color] [b]%s[/b]\n", p_task));
|
print_line_rich(vformat("[color=green][ DONE ][/color] [b]%s[/b]\n", p_task));
|
||||||
} else if (singleton->progress_dialog) {
|
} else if (singleton->progress_dialog) {
|
||||||
singleton->progress_dialog->end_task(p_task);
|
singleton->progress_dialog->end_task(p_task);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue