示例#1
0
        private void Awake()
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);

            if (Config.SyncFollowingsFeed)
            {
                _beastSaberFeeds.Add("followings", $"https://bsaber.com/members/{Config.BeastSaberUsername}/wall/followings");
            }
            if (Config.SyncBookmarksFeed)
            {
                _beastSaberFeeds.Add("bookmarks", $"https://bsaber.com/members/{Config.BeastSaberUsername}/bookmarks");
            }
            if (Config.SyncCuratorRecommendedFeed)
            {
                _beastSaberFeeds.Add("curator recommended", $"https://bsaber.com/members/curatorrecommended/bookmarks");
            }

            _songBrowserInstalled            = Utilities.IsModInstalled("Song Browser");
            SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;

            _historyPath = Path.Combine(Environment.CurrentDirectory, "UserData", "SyncSaberHistory.txt");
            if (File.Exists(_historyPath + ".bak"))
            {
                // Something went wrong when the history file was being written previously, restore it from backup
                if (File.Exists(_historyPath))
                {
                    File.Delete(_historyPath);
                }
                File.Move(_historyPath + ".bak", _historyPath);
            }
            if (File.Exists(_historyPath))
            {
                _songDownloadHistory = File.ReadAllLines(_historyPath).ToList();
            }

            if (!Directory.Exists("CustomSongs"))
            {
                Directory.CreateDirectory("CustomSongs");
            }

            string favoriteMappersPath = Path.Combine(Environment.CurrentDirectory, "UserData", "FavoriteMappers.ini");

            if (!File.Exists(favoriteMappersPath))
            {
                File.WriteAllLines(favoriteMappersPath, new string[] { "" }); // "freeek", "purphoros", "bennydabeast", "rustic", "greatyazer"
            }
            foreach (string mapper in File.ReadAllLines(favoriteMappersPath))
            {
                Plugin.Log($"Mapper: {mapper}");
                _authorDownloadQueue.Push(mapper);
            }

            StartCoroutine(FinishInitialization());
        }
示例#2
0
        private IEnumerator DelayedStartup()
        {
            yield return(new WaitForSeconds(0.5f));

            if (Utilities.IsModInstalled("MapperFeed"))
            {
                File.Move("Plugins\\BeatSaberMapperFeed.dll", "Plugins\\BeatSaberMapperFeed.dll.delete-me");
                _mapperFeedNotification = Utilities.CreateNotificationText("Old version of MapperFeed detected! Restart the game now to enable SyncSaber!");
                Plugin.Log("Old MapperFeed detected!");

                yield break;
            }

            Config.Read();
            Config.Write();

            _syncSaber = new GameObject().AddComponent <SyncSaber>();
        }