Beispiel #1
0
        public static void LoadOrCreateConfig()
        {
            if (!Directory.Exists("UserData"))
            {
                Directory.CreateDirectory("UserData");
            }

            //EnablePlugin property
            if (!ModPrefs.HasKey("BeatSaverCustomExit", "EnablePlugin"))
            {
                ModPrefs.SetBool("BeatSaverCustomExit", "EnablePlugin", true);
                Console.WriteLine("Created config");
            }
            else
            {
                EnablePlugin = ModPrefs.GetBool("BeatSaverCustomExit", "EnablePlugin", true, true);
            }

            //TextContent property
            if (!ModPrefs.HasKey("BeatSaverCustomExit", "TextContent"))
            {
                ModPrefs.SetString("BeatSaverCustomExit", "TextContent", "Are you really sure to quit <b><color=#FF6060>Beat <color=#00B0FF>Saber</b><color=#FFFFFF> ?");
                Console.WriteLine("Created config");
            }
            else
            {
                TextContent = ModPrefs.GetString("BeatSaverCustomExit", "TextContent", "Are you really sure to quit <b><color=#FF6060>Beat <color=#00B0FF>Saber</b><color=#FFFFFF> ?", true);
            }
        }
Beispiel #2
0
        private void Start()
        {
            platforms = new PlatformLoader().CreateAllPlatforms(transform);

            // Retrieve saved path from player prefs if it exists
            if (ModPrefs.HasKey(CustomFloorPlugin.PluginName, "CustomPlatformPath"))
            {
                string savedPath = ModPrefs.GetString(CustomFloorPlugin.PluginName, "CustomPlatformPath");
                // Check if this path was loaded and update our platform index
                for (int i = 0; i < platforms.Length; i++)
                {
                    if (savedPath == platforms[i].platName + platforms[i].platAuthor)
                    {
                        platformIndex = i;
                        break;
                    }
                }
            }

            EnvironmentArranger.arrangement        = (EnvironmentArranger.Arrangement)ModPrefs.GetInt(CustomFloorPlugin.PluginName, "EnvironmentArrangement", 0, true);
            EnvironmentSceneOverrider.overrideMode = (EnvironmentSceneOverrider.EnvOverrideMode)ModPrefs.GetInt(CustomFloorPlugin.PluginName, "EnvironmentOverrideMode", 0, true);
            EnvironmentSceneOverrider.GetSceneInfos();
            EnvironmentSceneOverrider.OverrideEnvironmentScene();

            envHider = new EnvironmentHider();
            envHider.showFeetOverride = ModPrefs.GetBool(CustomFloorPlugin.PluginName, "AlwaysShowFeet", false, true);
            envHider.FindEnvironment();
            envHider.HideObjectsForPlatform(currentPlatform);

            currentPlatform.gameObject.SetActive(true);

            BSSceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;

            PlatformUI.OnLoad();
        }
Beispiel #3
0
 public override void OnLevelWasLoaded(int level)
 {
     if (!ModPrefs.HasKey("RandomSong", "RandomSongBagSize"))
     {
         CreateConfig();
     }
     else
     {
         LoadConfig();
     }
 }
Beispiel #4
0
 public override void OnLevelWasLoaded(int level)
 {
     if (!ModPrefs.HasKey("IntroSkip", "enabled"))
     {
         CreateConfig();
     }
     else
     {
         LoadConfig();
     }
 }
        public static void LoadDownloaderConfig()
        {
            if (File.Exists("UserData\\votedSongs.json"))
            {
                votedSongs = JsonConvert.DeserializeObject <Dictionary <string, SongVote> >(File.ReadAllText("UserData\\votedSongs.json", Encoding.UTF8));
            }

            if (File.Exists("UserData\\favoriteSongs.cfg"))
            {
                favoriteSongs.Clear();
                favoriteSongs.AddRange(File.ReadAllLines("UserData\\favoriteSongs.cfg", Encoding.UTF8));
            }

            if (ModPrefs.HasKey("BeatSaverDownloader", "apiAccessToken"))
            {
                apiAccessToken = ModPrefs.GetString("BeatSaverDownloader", "apiAccessToken");
            }
        }
Beispiel #6
0
        /// <summary>
        /// Load Configuration
        /// </summary>
        internal static void Load()
        {
            // Yeet this once ModPrefs support is dropped by BSIPA.
#pragma warning disable CS0618 // ModPrefs is obsolete
            if (ModPrefs.HasKey(Plugin.PluginName, "GripLeftPosition") && !ModPrefs.GetBool(Plugin.PluginName, "IsExportedToNewConfig", false))
#pragma warning restore CS0618 // ModPrefs is obsolete
            {
                // Import SaberTailor's settings from the old configuration (ModPrefs)
                try
                {
                    PluginConfig importedConfig = ConfigurationImporter.ImportSettingsFromModPrefs();
                    PluginConfig.Instance = importedConfig;

                    // Store configuration in the new format immediately
                    PluginConfig.Instance.Changed();
                    Logger.log.Info("Configuration loaded from ModPrefs.");
                }
                catch (Exception ex)
                {
                    Logger.log.Warn("Failed to import ModPrefs configuration. Loading default BSIPA configuration instead.");
                    Logger.log.Warn(ex);
                }
            }

            try
            {
                LoadConfig();
            }
            catch (Exception ex)
            {
                Logger.log.Warn("Failed to load config file. Generating new default configuration...");
                PluginConfig.Instance = new PluginConfig();
                LoadConfig();
            }
            UpdateConfig();
            Logger.log.Debug("Configuration has been set");

            // Update variables used by mod logic
            UpdateModVariables();
        }
        private void Start()
        {
            envHider   = new EnvironmentHider();
            matSwapper = new MaterialSwapper();
            matSwapper.GetMaterials();

            CreateAllPlatforms();

            // Retrieve saved path from player prefs if it exists
            if (ModPrefs.HasKey(CustomFloorPlugin.PluginName, "CustomPlatformPath"))
            {
                string savedPath = ModPrefs.GetString(CustomFloorPlugin.PluginName, "CustomPlatformPath");
                // Check if this path was loaded and update our platform index
                for (int i = 0; i < bundlePaths.Count; i++)
                {
                    if (savedPath == bundlePaths.ElementAt(i))
                    {
                        platformIndex = i;
                    }
                }
            }
            PlatformUI.OnLoad();
            HideEnvironment();
        }
Beispiel #8
0
        public static void LoadOrCreateConfig()
        {
            if (IllusionInjector.PluginManager.Plugins.Any(x => x.Name == "Song Browser"))
            {
                Logger.Log("Song Browser installed, disabling Song List Tweaks");
                disableSongListTweaks = true;
            }

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

            if (!ModPrefs.HasKey("BeatSaverDownloader", "beatsaverURL"))
            {
                ModPrefs.SetString("BeatSaverDownloader", "beatsaverURL", "https://beatsaver.com");
                Logger.Log("Created config");
            }
            else
            {
                beatsaverURL = ModPrefs.GetString("BeatSaverDownloader", "beatsaverURL");
                if (string.IsNullOrEmpty(beatsaverURL))
                {
                    ModPrefs.SetString("BeatSaverDownloader", "beatsaverURL", "https://beatsaver.com");
                    beatsaverURL = "https://beatsaver.com";
                    Logger.Log("Created config");
                }
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "apiAccessToken"))
            {
                ModPrefs.SetString("BeatSaverDownloader", "apiAccessToken", apiTokenPlaceholder);
            }
            else
            {
                apiAccessToken = ModPrefs.GetString("BeatSaverDownloader", "apiAccessToken");
                if (string.IsNullOrEmpty(apiAccessToken) || apiAccessToken == apiTokenPlaceholder)
                {
                    ModPrefs.SetString("BeatSaverDownloader", "apiAccessToken", apiTokenPlaceholder);
                    apiAccessToken = apiTokenPlaceholder;
                }
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "disableDeleteButton"))
            {
                ModPrefs.SetBool("BeatSaverDownloader", "disableDeleteButton", false);
            }
            else
            {
                disableDeleteButton = ModPrefs.GetBool("BeatSaverDownloader", "disableDeleteButton", false, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "deleteToRecycleBin"))
            {
                ModPrefs.SetBool("BeatSaverDownloader", "deleteToRecycleBin", true);
            }
            else
            {
                deleteToRecycleBin = ModPrefs.GetBool("BeatSaverDownloader", "deleteToRecycleBin", true, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "enableSongIcons"))
            {
                ModPrefs.SetBool("BeatSaverDownloader", "enableSongIcons", true);
            }
            else
            {
                enableSongIcons = ModPrefs.GetBool("BeatSaverDownloader", "enableSongIcons", true, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "maxSimultaneousDownloads"))
            {
                ModPrefs.SetInt("BeatSaverDownloader", "maxSimultaneousDownloads", 3);
            }
            else
            {
                maxSimultaneousDownloads = ModPrefs.GetInt("BeatSaverDownloader", "maxSimultaneousDownloads", 3, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "fastScrollSpeed"))
            {
                ModPrefs.SetInt("BeatSaverDownloader", "fastScrollSpeed", 5);
                Logger.Log("Created config");
            }
            else
            {
                fastScrollSpeed = ModPrefs.GetInt("BeatSaverDownloader", "fastScrollSpeed", 5, true);
            }

            if (File.Exists(oldConfigPath) && !File.Exists(configPath))
            {
                File.Move(oldConfigPath, configPath);
            }

            if (!File.Exists(configPath))
            {
                File.Create(configPath).Close();
            }

            favoriteSongs.AddRange(File.ReadAllLines(configPath, Encoding.UTF8));

            if (!File.Exists(votedSongsPath))
            {
                File.WriteAllText(votedSongsPath, JsonConvert.SerializeObject(votedSongs), Encoding.UTF8);
            }
            else
            {
                votedSongs = JsonConvert.DeserializeObject <Dictionary <string, SongVote> >(File.ReadAllText(votedSongsPath, Encoding.UTF8));
            }

            if (!File.Exists(reviewedSongsPath))
            {
                File.WriteAllText(reviewedSongsPath, JsonConvert.SerializeObject(reviewedSongs), Encoding.UTF8);
            }
            else
            {
                reviewedSongs = JsonConvert.DeserializeObject <Dictionary <string, SongReview> >(File.ReadAllText(reviewedSongsPath, Encoding.UTF8));
            }

            try
            {
                if (Registry.CurrentUser.OpenSubKey(@"Software").GetSubKeyNames().Contains("178eef3d-4cea-5a1b-bfd0-07a21d068990"))
                {
                    beatDropPlaylistsLocation = (string)Registry.CurrentUser.OpenSubKey(@"Software\178eef3d-4cea-5a1b-bfd0-07a21d068990").GetValue("InstallLocation", "");
                    if (Directory.Exists(beatDropPlaylistsLocation))
                    {
                        beatDropInstalled = true;
                    }
                    else if (Directory.Exists("%LocalAppData%\\Programs\\BeatDrop\\playlists"))
                    {
                        beatDropInstalled         = true;
                        beatDropPlaylistsLocation = "%LocalAppData%\\Programs\\BeatDrop\\playlists";
                    }
                    else
                    {
                        beatDropInstalled         = false;
                        beatDropPlaylistsLocation = "";
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Log($"Can't open registry key! Exception: {e}");
                if (Directory.Exists("%LocalAppData%\\Programs\\BeatDrop\\playlists"))
                {
                    beatDropInstalled         = true;
                    beatDropPlaylistsLocation = "%LocalAppData%\\Programs\\BeatDrop\\playlists";
                }
                else
                {
                    Logger.Log("Unable to find BeatDrop installation folder!");
                }
            }

            if (!Directory.Exists("Playlists"))
            {
                Directory.CreateDirectory("Playlists");
            }
        }
Beispiel #9
0
        public static bool LoadOldIni()
        {
            if (!ModPrefs.HasKey("BeatSaverDownloader", "beatsaverURL"))
            {
                return(false);
            }
            else
            {
                beatsaverURL = ModPrefs.GetString("BeatSaverDownloader", "beatsaverURL");
                if (string.IsNullOrEmpty(beatsaverURL))
                {
                    beatsaverURL = "https://beatsaver.com";
                }
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "apiAccessToken"))
            {
                return(false);
            }
            else
            {
                apiAccessToken = ModPrefs.GetString("BeatSaverDownloader", "apiAccessToken");
                if (string.IsNullOrEmpty(apiAccessToken) || apiAccessToken == apiTokenPlaceholder)
                {
                    apiAccessToken = apiTokenPlaceholder;
                }
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "disableDeleteButton"))
            {
                return(false);
            }
            else
            {
                disableDeleteButton = ModPrefs.GetBool("BeatSaverDownloader", "disableDeleteButton", false, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "deleteToRecycleBin"))
            {
                return(false);
            }
            else
            {
                deleteToRecycleBin = ModPrefs.GetBool("BeatSaverDownloader", "deleteToRecycleBin", true, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "enableSongIcons"))
            {
                return(false);
            }
            else
            {
                enableSongIcons = ModPrefs.GetBool("BeatSaverDownloader", "enableSongIcons", true, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "rememberLastPackAndSong"))
            {
                return(false);
            }
            else
            {
                rememberLastPackAndSong = ModPrefs.GetBool("BeatSaverDownloader", "rememberLastPackAndSong", true, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "lastSelectedSong"))
            {
                return(false);
            }
            else
            {
                lastSelectedSong = ModPrefs.GetString("BeatSaverDownloader", "lastSelectedSong");
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "lastSelectedPack"))
            {
                return(false);
            }
            else
            {
                lastSelectedPack = ModPrefs.GetString("BeatSaverDownloader", "lastSelectedPack");
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "lastSelectedSortMode"))
            {
                return(false);
            }
            else
            {
                lastSelectedSortMode = (SortMode)ModPrefs.GetInt("BeatSaverDownloader", "lastSelectedSortMode");
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "maxSimultaneousDownloads"))
            {
                return(false);
            }
            else
            {
                maxSimultaneousDownloads = ModPrefs.GetInt("BeatSaverDownloader", "maxSimultaneousDownloads", 3, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "fastScrollSpeed"))
            {
                return(false);
            }
            else
            {
                fastScrollSpeed = ModPrefs.GetInt("BeatSaverDownloader", "fastScrollSpeed", 5, true);
            }

            return(true);
        }
Beispiel #10
0
        public static void LoadOrCreateConfig()
        {
            if (!Directory.Exists("UserData"))
            {
                Directory.CreateDirectory("UserData");
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "beatsaverURL"))
            {
                ModPrefs.SetString("BeatSaverDownloader", "beatsaverURL", "https://beatsaver.com");
                Logger.Log("Created config");
            }
            else
            {
                beatsaverURL = ModPrefs.GetString("BeatSaverDownloader", "beatsaverURL");
                if (string.IsNullOrEmpty(beatsaverURL))
                {
                    ModPrefs.SetString("BeatSaverDownloader", "beatsaverURL", "https://beatsaver.com");
                    beatsaverURL = "https://beatsaver.com";
                    Logger.Log("Created config");
                }
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "disableDeleteButton"))
            {
                ModPrefs.SetBool("BeatSaverDownloader", "disableDeleteButton", false);
            }
            else
            {
                disableDeleteButton = ModPrefs.GetBool("BeatSaverDownloader", "disableDeleteButton", false, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "deleteToRecycleBin"))
            {
                ModPrefs.SetBool("BeatSaverDownloader", "deleteToRecycleBin", true);
            }
            else
            {
                deleteToRecycleBin = ModPrefs.GetBool("BeatSaverDownloader", "deleteToRecycleBin", true, true);
            }

            if (!ModPrefs.HasKey("BeatSaverDownloader", "maxSimultaneousDownloads"))
            {
                ModPrefs.SetInt("BeatSaverDownloader", "maxSimultaneousDownloads", 3);
            }
            else
            {
                maxSimultaneousDownloads = ModPrefs.GetInt("BeatSaverDownloader", "maxSimultaneousDownloads", 3, true);
            }

            /*if (!File.Exists(configPath))
             * {
             *  File.Create(configPath).Close();
             * }
             *
             * favoriteSongs.AddRange(File.ReadAllLines(configPath, Encoding.UTF8));   */

            try
            {
                if (Registry.CurrentUser.OpenSubKey(@"Software").GetSubKeyNames().Contains("178eef3d-4cea-5a1b-bfd0-07a21d068990"))
                {
                    beatDropPlaylistsLocation = (string)Registry.CurrentUser.OpenSubKey(@"Software\178eef3d-4cea-5a1b-bfd0-07a21d068990").GetValue("InstallLocation", "");
                    if (Directory.Exists(beatDropPlaylistsLocation))
                    {
                        beatDropInstalled = true;
                    }
                    else if (Directory.Exists("%LocalAppData%\\Programs\\BeatDrop\\playlists"))
                    {
                        beatDropInstalled         = true;
                        beatDropPlaylistsLocation = "%LocalAppData%\\Programs\\BeatDrop\\playlists";
                    }
                    else
                    {
                        beatDropInstalled         = false;
                        beatDropPlaylistsLocation = "";
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Log($"Can't open registry key! Exception: {e}");
                if (Directory.Exists("%LocalAppData%\\Programs\\BeatDrop\\playlists"))
                {
                    beatDropInstalled         = true;
                    beatDropPlaylistsLocation = "%LocalAppData%\\Programs\\BeatDrop\\playlists";
                }
                else
                {
                    Logger.Log("Unable to find BeatDrop installation folder!");
                }
            }

            if (!Directory.Exists("Playlists"))
            {
                Directory.CreateDirectory("Playlists");
            }
        }
        public static void LoadOrCreateConfig()
        {
            if (!Directory.Exists("UserData"))
            {
                Directory.CreateDirectory("UserData");
            }

            //EnablePlugin property
            if (!ModPrefs.HasKey("BeatSaberDrinkWater", "EnablePlugin"))
            {
                ModPrefs.SetBool("BeatSaberDrinkWater", "EnablePlugin", true);
                Console.WriteLine("Created config");
            }
            else
            {
                EnablePlugin = ModPrefs.GetBool("BeatSaberDrinkWater", "EnablePlugin", true, true);
            }

            //ShowGIFs property
            if (!ModPrefs.HasKey("BeatSaberDrinkWater", "ShowGIFs"))
            {
                ModPrefs.SetBool("BeatSaberDrinkWater", "ShowGIFs", true);
                Console.WriteLine("Created config");
            }
            else
            {
                EnablePlugin = ModPrefs.GetBool("BeatSaberDrinkWater", "ShowGIFs", true, true);
            }

            //WaitDuration property
            if (!ModPrefs.HasKey("BeatSaberDrinkWater", "WaitDuration"))
            {
                ModPrefs.SetInt("BeatSaberDrinkWater", "WaitDuration", 5);
                Console.WriteLine("Created config");
            }
            else
            {
                WaitDuration = ModPrefs.GetInt("BeatSaberDrinkWater", "WaitDuration", 5, true);
            }

            //EnableByPlaytime property
            if (!ModPrefs.HasKey("BeatSaberDrinkWater", "EnableByPlaytime"))
            {
                ModPrefs.SetBool("BeatSaberDrinkWater", "EnableByPlaytime", true);
                Console.WriteLine("Created config");
            }
            else
            {
                EnableByPlaytime = ModPrefs.GetBool("BeatSaberDrinkWater", "EnableByPlaytime", true, true);
            }

            //EnableByPlaycount property
            if (!ModPrefs.HasKey("BeatSaberDrinkWater", "EnableByPlaycount"))
            {
                ModPrefs.SetBool("BeatSaberDrinkWater", "EnableByPlaycount", false);
                Console.WriteLine("Created config");
            }
            else
            {
                EnableByPlaycount = ModPrefs.GetBool("BeatSaberDrinkWater", "EnableByPlaycount", false, true);
            }

            //PlaytimeBeforeWarning property
            if (!ModPrefs.HasKey("BeatSaberDrinkWater", "PlaytimeBeforeWarning"))
            {
                ModPrefs.SetInt("BeatSaberDrinkWater", "PlaytimeBeforeWarning", 5);
                Console.WriteLine("Created config");
            }
            else
            {
                PlaytimeBeforeWarning = ModPrefs.GetInt("BeatSaberDrinkWater", "PlaytimeBeforeWarning", 5, true);
            }

            //PlaycountBeforeWarning property
            if (!ModPrefs.HasKey("BeatSaberDrinkWater", "PlaycountBeforeWarning"))
            {
                ModPrefs.SetInt("BeatSaberDrinkWater", "PlaycountBeforeWarning", 2);
                Console.WriteLine("Created config");
            }
            else
            {
                PlaycountBeforeWarning = ModPrefs.GetInt("BeatSaberDrinkWater", "PlaycountBeforeWarning", 2, true);
            }
        }