diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs
index e5a949f3b..061bb6b9a 100644
--- a/Source/Editor/Editor.cs
+++ b/Source/Editor/Editor.cs
@@ -47,7 +47,8 @@ namespace FlaxEditor
private bool _isAfterInit, _areModulesInited, _areModulesAfterInitEnd, _isHeadlessMode;
private string _projectToOpen;
private float _lastAutoSaveTimer;
- private AutoSavePopup _autoSavePopup;
+ private Button _saveNowButton;
+ private Button _cancelSaveButton;
private bool _autoSaveNow;
private Guid _startupSceneCmdLine;
@@ -492,28 +493,6 @@ namespace FlaxEditor
{
var timeSinceLastSave = Time.UnscaledGameTime - _lastAutoSaveTimer;
var timeToNextSave = options.AutoSaveFrequency * 60.0f - timeSinceLastSave;
- var countDownDuration = 4.0f;
-
- // Show auto save popup
- if (timeToNextSave <= options.AutoSaveReminderTime && timeToNextSave >= 0)
- {
- if (_autoSavePopup == null)
- {
- _autoSavePopup = AutoSavePopup.Show(Instance.Windows.MainWindow.GUI, timeToNextSave);
- _autoSavePopup.SaveNowButton.Clicked += () => _autoSaveNow = true;
- _autoSavePopup.CancelSaveButton.Clicked += () =>
- {
- Log("Auto save canceled");
- _autoSavePopup.HidePopup();
- _lastAutoSaveTimer = Time.UnscaledGameTime; // Reset timer
- };
- }
- else if (!_autoSavePopup.Visible && !_autoSavePopup.UserClosed)
- _autoSavePopup.ShowPopup();
-
- if (_autoSavePopup.Visible)
- _autoSavePopup.UpdateTime(timeToNextSave);
- }
if (timeToNextSave <= 0.0f || _autoSaveNow)
{
@@ -524,14 +503,76 @@ namespace FlaxEditor
if (options.AutoSaveContent)
SaveContent();
- // Hide auto save popup and reset user closed
- _autoSavePopup.HidePopup();
- _autoSavePopup.UserClosed = false;
_autoSaveNow = false;
+
+ // Hide save now and cancel save buttons
+ if (_saveNowButton != null && _cancelSaveButton != null)
+ {
+ _saveNowButton.Visible = false;
+ _cancelSaveButton.Visible = false;
+ }
}
- else if (timeToNextSave < countDownDuration)
+ else if (timeToNextSave <= options.AutoSaveReminderTime)
{
msg = string.Format("Auto save in {0}s...", Mathf.CeilToInt(timeToNextSave));
+
+ // Create save now and cancel save buttons if needed
+ if (_saveNowButton == null)
+ {
+ _saveNowButton = new Button
+ {
+ Parent = UI.StatusBar,
+ Height = 14,
+ Width = 60,
+ AnchorPreset = AnchorPresets.MiddleLeft,
+ BackgroundColor = Color.Transparent,
+ BorderColor = Color.Transparent,
+ BackgroundColorHighlighted = Color.Transparent,
+ BackgroundColorSelected = Color.Transparent,
+ BorderColorHighlighted = Color.Transparent,
+ Text = "Save Now",
+ TooltipText = "Saves now and restarts the auto save timer."
+ };
+ _saveNowButton.LocalX += 120;
+ _saveNowButton.Clicked += () => _autoSaveNow = true;
+ _saveNowButton.HoverBegin += () => _saveNowButton.TextColor = Style.Current.BackgroundHighlighted;
+ _saveNowButton.HoverEnd += () => _saveNowButton.TextColor = UI.StatusBar.TextColor;
+ }
+
+ if (_cancelSaveButton == null)
+ {
+ _cancelSaveButton = new Button
+ {
+ Parent = UI.StatusBar,
+ Height = 14,
+ Width = 70,
+ AnchorPreset = AnchorPresets.MiddleLeft,
+ BackgroundColor = Color.Transparent,
+ BorderColor = Color.Transparent,
+ BackgroundColorHighlighted = Color.Transparent,
+ BackgroundColorSelected = Color.Transparent,
+ BorderColorHighlighted = Color.Transparent,
+ Text = "Cancel",
+ TooltipText = "Cancels this auto save."
+ };
+ _cancelSaveButton.LocalX += 180;
+ _cancelSaveButton.Clicked += () =>
+ {
+ Log("Auto save canceled");
+ _saveNowButton.Visible = false;
+ _cancelSaveButton.Visible = false;
+ _lastAutoSaveTimer = Time.UnscaledGameTime; // Reset timer
+ };
+ _cancelSaveButton.HoverBegin += () => _cancelSaveButton.TextColor = Style.Current.BackgroundHighlighted;
+ _cancelSaveButton.HoverEnd += () => _cancelSaveButton.TextColor = UI.StatusBar.TextColor;
+ }
+
+ // Show save now and cancel save buttons
+ if (!_saveNowButton.Visible || !_cancelSaveButton.Visible)
+ {
+ _saveNowButton.Visible = true;
+ _cancelSaveButton.Visible = true;
+ }
}
}
if (StateMachine.EditingSceneState.AutoSaveStatus != msg)
@@ -539,6 +580,18 @@ namespace FlaxEditor
StateMachine.EditingSceneState.AutoSaveStatus = msg;
UI.UpdateStatusBar();
}
+
+ if (!UI.StatusBar.Text.Contains("Auto"))
+ {
+ if (_saveNowButton != null && _cancelSaveButton != null)
+ {
+ if (_saveNowButton.Visible || _cancelSaveButton.Visible)
+ {
+ _saveNowButton.Visible = false;
+ _cancelSaveButton.Visible = false;
+ }
+ }
+ }
}
private void InitProject()
diff --git a/Source/Editor/GUI/Popups/AutoSavePopup.cs b/Source/Editor/GUI/Popups/AutoSavePopup.cs
deleted file mode 100644
index 0992def3e..000000000
--- a/Source/Editor/GUI/Popups/AutoSavePopup.cs
+++ /dev/null
@@ -1,169 +0,0 @@
-using FlaxEngine;
-using FlaxEngine.GUI;
-
-namespace FlaxEditor.GUI
-{
- ///
- /// Popup menu for reminding of an upcoming auto save.
- ///
- public class AutoSavePopup : ContainerControl
- {
- ///
- /// Gets or sets the value for if the user has manually closed this popup.
- ///
- public bool UserClosed { get; set; }
-
- ///
- /// The save now button. Used to skip the last remaining auto save time.
- ///
- public Button SaveNowButton => _saveNowButton;
-
- ///
- /// Button that should be used to cancel the auto save.
- ///
- public Button CancelSaveButton => _cancelSaveButton;
-
- private int _timeRemaining;
- private Panel _backgroundPanel;
- private Label _timeLabel;
- private Button _saveNowButton;
- private Button _cancelSaveButton;
- private Color _defaultTextColor;
- private bool _isMoved = false;
-
- ///
- /// Initialize the AutoSavePopup.
- ///
- /// The initial time to set the time label to.
- public AutoSavePopup(float initialTime)
- {
- UpdateTime(initialTime);
-
- _backgroundPanel = new Panel(ScrollBars.None)
- {
- Parent = this,
- AnchorPreset = AnchorPresets.StretchAll,
- BackgroundColor = Color.Transparent,
- };
-
- _timeLabel = new Label(0, 0, 25, 10)
- {
- Parent = _backgroundPanel,
- Text = _timeRemaining.ToString(),
- HorizontalAlignment = TextAlignment.Near,
- VerticalAlignment = TextAlignment.Near,
- AutoWidth = true,
- Height = 14,
- AnchorPreset = AnchorPresets.MiddleLeft,
- };
-
- _saveNowButton = new Button
- {
- Parent = _backgroundPanel,
- Height = 14,
- Width = 60,
- AnchorPreset = AnchorPresets.MiddleRight,
- BackgroundColor = Color.Transparent,
- BorderColor = Color.Transparent,
- BackgroundColorHighlighted = Color.Transparent,
- BackgroundColorSelected = Color.Transparent,
- BorderColorHighlighted = Color.Transparent,
- Text = "Save Now",
- TooltipText = "Saves now and restarts the auto save timer."
- };
- _saveNowButton.LocalX -= 85;
-
- _cancelSaveButton = new Button
- {
- Parent = _backgroundPanel,
- Height = 14,
- Width = 70,
- AnchorPreset = AnchorPresets.MiddleRight,
- BackgroundColor = Color.Transparent,
- BorderColor = Color.Transparent,
- BackgroundColorHighlighted = Color.Transparent,
- BackgroundColorSelected = Color.Transparent,
- BorderColorHighlighted = Color.Transparent,
- Text = "Cancel Save",
- TooltipText = "Cancels this auto save."
- };
- _cancelSaveButton.LocalX -= 5;
-
- _defaultTextColor = _saveNowButton.TextColor;
- }
-
- ///
- /// Updates the time label
- ///
- /// The time to change the label to.
- public void UpdateTime(float time)
- {
- _timeRemaining = Mathf.CeilToInt(time);
- if (_timeLabel != null)
- _timeLabel.Text = "Auto Save in: " + _timeRemaining;
- }
-
- ///
- public override void Update(float deltaTime)
- {
- if (IsMouseOver)
- {
- _saveNowButton.TextColor = _saveNowButton.IsMouseOver ? Style.Current.BackgroundHighlighted : _defaultTextColor;
- _cancelSaveButton.TextColor = _cancelSaveButton.IsMouseOver ? Style.Current.BackgroundHighlighted : _defaultTextColor;
- }
-
- // Move if the progress bar is visible
- if (Editor.Instance.UI.ProgressVisible && !_isMoved)
- {
- _isMoved = true;
- LocalX -= 280;
- }
- else if (!Editor.Instance.UI.ProgressVisible && _isMoved)
- {
- LocalX += 280;
- _isMoved = false;
- }
- base.Update(deltaTime);
- }
-
- ///
- /// Creates and shows the AutoSavePopup
- ///
- /// The parent control.
- /// The time to start at.
- ///
- public static AutoSavePopup Show(ContainerControl parentControl, float initialTime)
- {
- var popup = new AutoSavePopup(initialTime)
- {
- Parent = parentControl,
- Height = Editor.Instance.UI.StatusBar.Height,
- Width = 250,
- AnchorPreset = AnchorPresets.BottomRight,
- };
- popup.ShowPopup();
- return popup;
- }
-
- ///
- /// Shows the popup by changing its visibility
- ///
- public void ShowPopup()
- {
- Visible = true;
- UserClosed = false;
- _saveNowButton.TextColor = _defaultTextColor;
- _cancelSaveButton.TextColor = _defaultTextColor;
- }
-
- ///
- /// Hides the popup by changing its visibility
- ///
- public void HidePopup()
- {
- Visible = false;
- if (_containsFocus)
- Defocus();
- }
- }
-}