Exemple #1
0
        private string GetLastLoadedScene(string defaultImage = null)
        {
            if (!LastLoadedScenes.TryGetValue(_currentSceneFolder, out var nextImage))
            {
                nextImage = defaultImage.IsNullOrEmpty() ? ScenePaths.FirstOrDefault() : defaultImage;
            }

            return(string.IsNullOrEmpty(nextImage)
                ? nextImage
                : PathUtils.NormalizePath(Path.Combine(_currentSceneFolder, nextImage)));
        }
Exemple #2
0
        private void TrackLastLoadedScene()
        {
            if (_currentScenePath.IsNullOrEmpty())
            {
                return;
            }
            var key = PathUtils.NormalizePath(Path.GetDirectoryName(_currentScenePath));

            if (!LastLoadedScenes.TryGetValue(key, out var current))
            {
                current = string.Empty;
            }
            var currentValue = Path.GetFileName(_currentScenePath);

            if (currentValue.Compare(current, StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }
            LastLoadedScenes[key] = currentValue;
            SavePending           = true;
        }
Exemple #3
0
        /// <summary>Loads the last loaded scene from the currently active folder</summary>
        /// <returns>`true` if scene was loaded, otherwise `false`</returns>
        private bool LoadLastLoadedScene()
        {
            var navigated       = false;
            var clearNavigation = !_navigationInProgress;

            _navigationInProgress = true;
            try
            {
                if (!LastLoadedScenes.TryGetValue(_currentSceneFolder, out var nextImage))
                {
                    nextImage = ScenePaths.LastOrDefault();
                }

                if (nextImage != default)
                {
                    nextImage = PathUtils.NormalizePath(Path.Combine(_currentSceneFolder, nextImage));

                    if (File.Exists(nextImage))
                    {
                        _currentScenePathCandidate = nextImage;
                        StartCoroutine(Singleton <Studio.Studio> .Instance.LoadSceneCoroutine(nextImage));
                        navigated = true;
                    }
                }
            }
            finally
            {
                if (!navigated)
                {
                    Logger.Log(BepInLogLevel.Message | BepInLogLevel.Error,
                               $"Error loading last scene from {_currentSceneFolder}");
                    if (clearNavigation)
                    {
                        _navigationInProgress = false;
                    }
                }
            }

            return(navigated);
        }