private void UpdateDisplay(DisplayedTask task, Progress.Item dataSource) { task.nameLabel.text = dataSource.name; task.descriptionLabel.text = dataSource.description; task.SetIndefinite(dataSource.indefinite); if (!dataSource.indefinite) { var p01 = Mathf.Clamp01(dataSource.progress); task.progressBar.value = p01 * 100.0f; if (task.progressLabel != null) { task.progressLabel.text = $"{Mathf.FloorToInt(p01 * 100.0f)}%"; } task.SetProgressStyleFull(dataSource.progress > 0.96f); } if (dataSource.status == Progress.Status.Canceled) { task.descriptionLabel.text = "Cancelled"; UpdateStatusIcon(task, ProgressWindow.kCanceledIcon); task.progress.AddToClassList("unity-progress-bar__progress__inactive"); } else if (dataSource.status == Progress.Status.Failed) { if (string.IsNullOrEmpty(task.descriptionLabel.text)) { task.descriptionLabel.text = "Failed"; } UpdateStatusIcon(task, ProgressWindow.kFailedIcon); task.progress.AddToClassList("unity-progress-bar__progress__inactive"); } else if (dataSource.status == Progress.Status.Succeeded) { if (string.IsNullOrEmpty(task.descriptionLabel.text)) { task.descriptionLabel.text = "Done"; } task.progressBar.value = 100; task.SetProgressStyleFull(true); UpdateStatusIcon(task, ProgressWindow.kSuccessIcon); task.progressLabel.style.unityBackgroundImageTintColor = new StyleColor(Color.green); // Update running time to force elapsed time to show when the task is set to show ETA UpdateRunningTime(); if (m_MainTask == task && m_DetailsFoldoutToggle.value) { m_DetailsFoldoutToggle.value = false; } } task.cancelButton.style.display = dataSource.running ? DisplayStyle.Flex : DisplayStyle.None; task.cancelButton.visible = dataSource.cancellable; }
private void UpdateDisplay(DisplayedTask task, ProgressItem dataSource) { task.nameLabel.text = dataSource.name; task.descriptionLabel.text = dataSource.description; task.SetIndefinite(dataSource.indefinite); if (!dataSource.indefinite) { var p01 = Mathf.Clamp01(dataSource.progress); task.progressBar.value = p01 * 100.0f; if (task.progressLabel != null) { task.progressLabel.text = $"{Mathf.FloorToInt(p01 * 100.0f)}%"; } task.SetProgressStyleFull(dataSource.progress > 0.96f); } if (dataSource.status == ProgressStatus.Canceled) { task.descriptionLabel.text += " (Cancelled)"; UpdateProgressCompletion(task, ProgressWindow.kCanceledIcon); } else if (dataSource.status == ProgressStatus.Failed) { task.descriptionLabel.text += " (Failed)"; UpdateProgressCompletion(task, ProgressWindow.kFailedIcon); } else if (dataSource.status == ProgressStatus.Succeeded) { task.progressBar.value = 100; task.SetProgressStyleFull(true); UpdateProgressCompletion(task, ProgressWindow.kSuccessIcon); task.progressLabel.style.unityBackgroundImageTintColor = new StyleColor(Color.green); if (m_MainTask == task && m_DetailsFoldoutToggle.value) { m_DetailsFoldoutToggle.value = false; } } task.deleteButton.style.display = !dataSource.running ? DisplayStyle.Flex : DisplayStyle.None; task.cancelButton.style.display = dataSource.running ? DisplayStyle.Flex : DisplayStyle.None; task.cancelButton.visible = dataSource.cancellable; }