| 5382 | } |
| 5383 | |
| 5384 | bool EditorNode::progress_task_step(const String &p_task, const String &p_state, int p_step, bool p_force_refresh) { |
| 5385 | if (!singleton) { |
| 5386 | return false; |
| 5387 | } else if (singleton->cmdline_mode) { |
| 5388 | double current_time = USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()); |
| 5389 | double elapsed_time = current_time - last_progress_time; |
| 5390 | if (p_task != last_progress_task || p_state != last_progress_state || p_step != last_progress_step || elapsed_time >= 1.0) { |
| 5391 | // Only print the progress if it's changed since the last print, or if one second has passed. |
| 5392 | // This prevents multithreaded import from printing the same progress too often, which would bloat the log file. |
| 5393 | const int percent = (p_step / float(progress_total_steps[p_task] + 1)) * 100; |
| 5394 | print_line_rich(vformat("[%4d%% ] [color=gray][b]%s[/b] | %s[/color]", percent, p_task, p_state)); |
| 5395 | last_progress_task = p_task; |
| 5396 | last_progress_state = p_state; |
| 5397 | last_progress_step = p_step; |
| 5398 | last_progress_time = current_time; |
| 5399 | } |
| 5400 | return false; |
| 5401 | } else if (singleton->progress_dialog) { |
| 5402 | return singleton->progress_dialog->task_step(p_task, p_state, p_step, p_force_refresh); |
| 5403 | } else { |
| 5404 | return false; |
| 5405 | } |
| 5406 | } |
| 5407 | |
| 5408 | void EditorNode::progress_end_task(const String &p_task) { |
| 5409 | if (!singleton) { |
no test coverage detected