()
| 520 | } |
| 521 | |
| 522 | private void UpdateAutoSave() |
| 523 | { |
| 524 | string msg = null; |
| 525 | var options = Options.Options.General; |
| 526 | var canSave = StateMachine.IsEditMode && options.EnableAutoSave; |
| 527 | if (canSave) |
| 528 | { |
| 529 | var timeSinceLastSave = Time.UnscaledGameTime - _lastAutoSaveTimer; |
| 530 | var timeToNextSave = options.AutoSaveFrequency * 60.0f - timeSinceLastSave; |
| 531 | |
| 532 | if (timeToNextSave <= 0.0f && GetWindows().Any(x => x.GUI.Children.Any(c => c is GUI.ContextMenu.ContextMenuBase))) |
| 533 | { |
| 534 | // Skip aut-save if any context menu is opened to wait for user to end interaction |
| 535 | } |
| 536 | else if (timeToNextSave <= 0.0f || _autoSaveNow) |
| 537 | { |
| 538 | Log("Auto save"); |
| 539 | _lastAutoSaveTimer = Time.UnscaledGameTime; |
| 540 | if (options.AutoSaveScenes) |
| 541 | Scene.SaveScenes(); |
| 542 | if (options.AutoSaveContent) |
| 543 | SaveContent(); |
| 544 | |
| 545 | _autoSaveNow = false; |
| 546 | |
| 547 | // Hide save now and cancel save buttons |
| 548 | if (_saveNowButton != null && _cancelSaveButton != null) |
| 549 | { |
| 550 | _saveNowButton.Visible = false; |
| 551 | _cancelSaveButton.Visible = false; |
| 552 | } |
| 553 | } |
| 554 | else if (timeToNextSave <= options.AutoSaveReminderTime) |
| 555 | { |
| 556 | msg = string.Format("Auto save in {0}s...", Mathf.CeilToInt(timeToNextSave)); |
| 557 | |
| 558 | // Create save now and cancel save buttons if needed |
| 559 | if (_saveNowButton == null) |
| 560 | { |
| 561 | _saveNowButton = new Button |
| 562 | { |
| 563 | Parent = UI.StatusBar, |
| 564 | Height = 14, |
| 565 | Width = 60, |
| 566 | AnchorPreset = AnchorPresets.MiddleLeft, |
| 567 | BackgroundColor = Color.Transparent, |
| 568 | BorderColor = Color.Transparent, |
| 569 | BackgroundColorHighlighted = Color.Transparent, |
| 570 | BackgroundColorSelected = Color.Transparent, |
| 571 | BorderColorHighlighted = Color.Transparent, |
| 572 | Text = "Save Now", |
| 573 | TooltipText = "Saves now and restarts the auto save timer." |
| 574 | }; |
| 575 | _saveNowButton.LocalX += 120; |
| 576 | _saveNowButton.Clicked += () => _autoSaveNow = true; |
| 577 | _saveNowButton.HoverBegin += () => _saveNowButton.TextColor = Style.Current.BackgroundHighlighted; |
| 578 | _saveNowButton.HoverEnd += () => _saveNowButton.TextColor = UI.StatusBar.TextColor; |
| 579 | } |
nothing calls this directly
no test coverage detected