diff --git a/Source/Editor/Modules/ProgressReportingModule.cs b/Source/Editor/Modules/ProgressReportingModule.cs index 713292657..b038d9a4c 100644 --- a/Source/Editor/Modules/ProgressReportingModule.cs +++ b/Source/Editor/Modules/ProgressReportingModule.cs @@ -96,6 +96,7 @@ namespace FlaxEditor.Modules handler.ProgressStart += HandlerOnProgressStart; handler.ProgressChanged += HandlerOnProgressChanged; handler.ProgressEnd += HandlerOnProgressEnd; + handler.ProgressFailed += HandlerOnProgressFail; } /// @@ -113,6 +114,7 @@ namespace FlaxEditor.Modules handler.ProgressStart -= HandlerOnProgressStart; handler.ProgressChanged -= HandlerOnProgressChanged; handler.ProgressEnd -= HandlerOnProgressEnd; + handler.ProgressFailed -= HandlerOnProgressFail; } private void UpdateProgress() @@ -150,5 +152,10 @@ namespace FlaxEditor.Modules Editor.Windows.FlashMainWindow(); } } + + private void HandlerOnProgressFail(ProgressHandler handler) + { + Editor.UI.ProgressFailed(); + } } } diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index a3bdf8ee0..d261ba33a 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -31,6 +31,7 @@ namespace FlaxEditor.Modules { private Label _progressLabel; private ProgressBar _progressBar; + private Button _outputLogButton; private List> _statusMessages; private ContentStats _contentStats; @@ -303,7 +304,25 @@ namespace FlaxEditor.Modules if (_progressLabel != null) _progressLabel.Text = text; if (_progressBar != null) + { + if (_outputLogButton.Visible) + { + _progressBar.BarColor = Style.Current.ProgressNormal; + var scale = _progressBar.SmoothingScale; + _progressBar.SmoothingScale = 0; + _progressBar.Value = 0; + _progressBar.SmoothingScale = scale; + _outputLogButton.Visible = false; + } _progressBar.Value = progress * 100.0f; + } + } + + internal void ProgressFailed() + { + _progressBar.BarColor = Color.Red; + _progressLabel.Text = "Failed"; + _outputLogButton.Visible = true; } /// @@ -600,6 +619,32 @@ namespace FlaxEditor.Modules Parent = progressPanel, Offsets = new Margin(-progressBarWidth - progressBarRightMargin, progressBarWidth, progressBarHeight * -0.5f, progressBarHeight), }; + _outputLogButton = new Button() + { + AnchorPreset = AnchorPresets.TopLeft, + Parent = _progressBar, + Visible = false, + Text = "Output Log", + TooltipText = "Opens or shows the output log window.", + BackgroundColor = Color.Transparent, + BorderColor = Color.Transparent, + BackgroundColorHighlighted = Color.Transparent, + BackgroundColorSelected = Color.Transparent, + BorderColorHighlighted = Color.Transparent, + BorderColorSelected = Color.Transparent, + }; + _outputLogButton.LocalY -= 2; + var defaultTextColor = _outputLogButton.TextColor; + _outputLogButton.HoverBegin += () => _outputLogButton.TextColor = Style.Current.BackgroundSelected; + _outputLogButton.HoverEnd += () => _outputLogButton.TextColor = defaultTextColor; + _outputLogButton.Clicked += () => + { + Editor.Windows.OutputLogWin.FocusOrShow(); + //_progressBar.BarColor = Style.Current.ProgressNormal; + //_progressBar.Value = 0; + //ProgressVisible = false; + //_outputLogButton.Visible = false; + }; _progressLabel = new Label { HorizontalAlignment = TextAlignment.Far, diff --git a/Source/Editor/Progress/Handlers/CompileScriptsProgress.cs b/Source/Editor/Progress/Handlers/CompileScriptsProgress.cs index ef814a0fb..085a0fddf 100644 --- a/Source/Editor/Progress/Handlers/CompileScriptsProgress.cs +++ b/Source/Editor/Progress/Handlers/CompileScriptsProgress.cs @@ -21,7 +21,7 @@ namespace FlaxEditor.Progress.Handlers // Link for events ScriptsBuilder.CompilationBegin += OnStart; ScriptsBuilder.CompilationSuccess += OnEnd; - ScriptsBuilder.CompilationFailed += OnEnd; + ScriptsBuilder.CompilationFailed += OnFail; ScriptsBuilder.CompilationStarted += () => OnUpdate(0.2f, "Compiling scripts..."); ScriptsBuilder.ScriptsReloadCalled += () => OnUpdate(0.8f, "Reloading scripts..."); ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin; diff --git a/Source/Editor/Progress/ProgressHandler.cs b/Source/Editor/Progress/ProgressHandler.cs index 74b31ff1f..71e8a1a20 100644 --- a/Source/Editor/Progress/ProgressHandler.cs +++ b/Source/Editor/Progress/ProgressHandler.cs @@ -51,6 +51,11 @@ namespace FlaxEditor.Progress /// public event ProgressDelegate ProgressEnd; + /// + /// Occurs when the progress fails + /// + public event ProgressDelegate ProgressFailed; + /// /// Gets a value indicating whether this handler action can be cancelled. /// @@ -109,5 +114,19 @@ namespace FlaxEditor.Progress ProgressChanged?.Invoke(this); ProgressEnd?.Invoke(this); } + + /// + /// Called when progress action fails + /// + protected virtual void OnFail() + { + if (!_isActive) + throw new InvalidOperationException("Already ended."); + + _isActive = false; + _progress = 0; + _infoText = string.Empty; + ProgressFailed?.Invoke(this); + } } }