diff --git a/Source/Editor/GUI/StatusBar.cs b/Source/Editor/GUI/StatusBar.cs
index 80a500236..f8f7ae839 100644
--- a/Source/Editor/GUI/StatusBar.cs
+++ b/Source/Editor/GUI/StatusBar.cs
@@ -30,6 +30,11 @@ namespace FlaxEditor.GUI
///
public string Text { get; set; }
+ ///
+ /// Gets or sets the status text color
+ ///
+ public Color TextColor { get; set; } = Style.Current.Foreground;
+
///
/// Initializes a new instance of the class.
///
@@ -51,7 +56,7 @@ namespace FlaxEditor.GUI
Render2D.DrawSprite(style.StatusBarSizeGrip, new Rectangle(Width - 12, 10, 12, 12), style.Foreground);
// Draw status text
- Render2D.DrawText(style.FontSmall, Text, new Rectangle(4, 0, Width - 20, Height), style.Foreground, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, Text, new Rectangle(4, 0, Width - 20, Height), TextColor, TextAlignment.Near, TextAlignment.Center);
}
}
}
diff --git a/Source/Editor/Modules/ProgressReportingModule.cs b/Source/Editor/Modules/ProgressReportingModule.cs
index 713292657..16acd7f8b 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,11 @@ namespace FlaxEditor.Modules
Editor.Windows.FlashMainWindow();
}
}
+
+ private void HandlerOnProgressFail(ProgressHandler handler, string message)
+ {
+ UpdateProgress();
+ Editor.UI.ProgressFailed(message);
+ }
}
}
diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs
index a3bdf8ee0..c72e07c6c 100644
--- a/Source/Editor/Modules/UIModule.cs
+++ b/Source/Editor/Modules/UIModule.cs
@@ -31,8 +31,10 @@ namespace FlaxEditor.Modules
{
private Label _progressLabel;
private ProgressBar _progressBar;
+ private Button _outputLogButton;
private List> _statusMessages;
private ContentStats _contentStats;
+ private bool _progressFailed;
private ContextMenuButton _menuFileSaveScenes;
private ContextMenuButton _menuFileCloseScenes;
@@ -252,6 +254,12 @@ namespace FlaxEditor.Modules
{
if (StatusBar == null)
return;
+
+ if (ScriptsBuilder.LastCompilationFailed)
+ {
+ ProgressFailed("Scripts Compilation Failed");
+ return;
+ }
var contentStats = FlaxEngine.Content.Stats;
Color color;
@@ -303,7 +311,28 @@ namespace FlaxEditor.Modules
if (_progressLabel != null)
_progressLabel.Text = text;
if (_progressBar != null)
+ {
+ if (_progressFailed)
+ {
+ ResetProgressFailure();
+ }
_progressBar.Value = progress * 100.0f;
+ }
+ }
+
+ internal void ProgressFailed(string message)
+ {
+ _progressFailed = true;
+ StatusBar.StatusColor = Color.Red;
+ StatusBar.Text = message;
+ _outputLogButton.Visible = true;
+ }
+
+ internal void ResetProgressFailure()
+ {
+ _outputLogButton.Visible = false;
+ _progressFailed = false;
+ UpdateStatusBar();
}
///
@@ -581,6 +610,30 @@ namespace FlaxEditor.Modules
Parent = mainWindow,
Offsets = new Margin(0, 0, -StatusBar.DefaultHeight, StatusBar.DefaultHeight),
};
+ // Output log button
+ _outputLogButton = new Button()
+ {
+ AnchorPreset = AnchorPresets.TopLeft,
+ Parent = StatusBar,
+ Visible = false,
+ Text = "",
+ Width = 200,
+ 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 = StatusBar.TextColor;
+ _outputLogButton.HoverBegin += () => StatusBar.TextColor = Style.Current.BackgroundSelected;
+ _outputLogButton.HoverEnd += () => StatusBar.TextColor = defaultTextColor;
+ _outputLogButton.Clicked += () =>
+ {
+ Editor.Windows.OutputLogWin.FocusOrShow();
+ };
// Progress bar with label
const float progressBarWidth = 120.0f;
diff --git a/Source/Editor/Progress/Handlers/CompileScriptsProgress.cs b/Source/Editor/Progress/Handlers/CompileScriptsProgress.cs
index ef814a0fb..59d40463e 100644
--- a/Source/Editor/Progress/Handlers/CompileScriptsProgress.cs
+++ b/Source/Editor/Progress/Handlers/CompileScriptsProgress.cs
@@ -1,6 +1,5 @@
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
-using FlaxEngine;
using FlaxEditor.Utilities;
namespace FlaxEditor.Progress.Handlers
@@ -21,7 +20,7 @@ namespace FlaxEditor.Progress.Handlers
// Link for events
ScriptsBuilder.CompilationBegin += OnStart;
ScriptsBuilder.CompilationSuccess += OnEnd;
- ScriptsBuilder.CompilationFailed += OnEnd;
+ ScriptsBuilder.CompilationFailed += OnCompilationFailed;
ScriptsBuilder.CompilationStarted += () => OnUpdate(0.2f, "Compiling scripts...");
ScriptsBuilder.ScriptsReloadCalled += () => OnUpdate(0.8f, "Reloading scripts...");
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
@@ -45,6 +44,11 @@ namespace FlaxEditor.Progress.Handlers
Newtonsoft.Json.JsonSerializer.ClearCache();
}
+ private void OnCompilationFailed()
+ {
+ OnFail("Scripts compilation failed");
+ }
+
private void OnScriptsReloadEnd()
{
_selectionCache.Restore();
diff --git a/Source/Editor/Progress/ProgressHandler.cs b/Source/Editor/Progress/ProgressHandler.cs
index 74b31ff1f..2738b7c57 100644
--- a/Source/Editor/Progress/ProgressHandler.cs
+++ b/Source/Editor/Progress/ProgressHandler.cs
@@ -16,6 +16,11 @@ namespace FlaxEditor.Progress
///
/// The calling handler.
public delegate void ProgressDelegate(ProgressHandler handler);
+
+ ///
+ /// Progress failed handler event delegate
+ ///
+ public delegate void ProgressFailedDelegate(ProgressHandler handler, string message);
private float _progress;
private bool _isActive;
@@ -51,6 +56,11 @@ namespace FlaxEditor.Progress
///
public event ProgressDelegate ProgressEnd;
+ ///
+ /// Occurs when the progress fails
+ ///
+ public event ProgressFailedDelegate ProgressFailed;
+
///
/// Gets a value indicating whether this handler action can be cancelled.
///
@@ -109,5 +119,19 @@ namespace FlaxEditor.Progress
ProgressChanged?.Invoke(this);
ProgressEnd?.Invoke(this);
}
+
+ ///
+ /// Called when progress action fails
+ ///
+ protected virtual void OnFail(string message)
+ {
+ if (!_isActive)
+ throw new InvalidOperationException("Already ended.");
+
+ _isActive = false;
+ _progress = 0;
+ _infoText = string.Empty;
+ ProgressFailed?.Invoke(this, message);
+ }
}
}