/// <summary> /// Load Configuration /// </summary> internal static void Load() { BS_Utils.Utilities.Config oldConfig = new BS_Utils.Utilities.Config("modprefs"); if (oldConfig.HasKey(Plugin.PluginName, "GripLeftPosition") && !oldConfig.GetBool(Plugin.PluginName, "IsExportedToNewConfig", false)) { // Import SaberTailor's settings from the old configuration (ModPrefs) try { PluginConfig importedConfig = ConfigurationImporter.ImportSettingsFromModPrefs(oldConfig); 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); } } LoadConfig(); UpdateConfig(); Logger.log.Debug("Configuration has been set"); // Update variables used by mod logic UpdateModVariables(); }
public void Init(IPALogger logger) { Logger.logger = logger; Logger.Log("Logger initialized"); config = new BS_Utils.Utilities.Config(configName); Logger.Log("Config initialized"); }
public void OnApplicationStart() { BSEvents.OnLoad(); BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; config = new BS_Utils.Utilities.Config("MVP"); Base64Sprites.ConvertToSprites(); }
internal static void LoadSettings(LoadSettingsType type) { string iniName = ModPrefs.GetString("Chroma", "ConfigProfile", "default", true); //TODO get the thing IniProfile = new BS_Utils.Utilities.Config("Chroma/Preferences/" + iniName); LoadSettingsEvent?.Invoke(IniProfile, type); }
public void OnApplicationStart() { // TODO: Remove this migration path at some point var songCoreIniPath = Path.Combine(UnityGame.UserDataPath, nameof(SongCore), "SongCore.ini"); if (File.Exists(songCoreIniPath)) { var modPrefs = new BS_Utils.Utilities.Config("SongCore/SongCore"); Configuration.CustomSongColors = modPrefs.GetBool("SongCore", "customSongColors", true, true); Configuration.CustomSongPlatforms = modPrefs.GetBool("SongCore", "customSongPlatforms", true, true); Configuration.DisplayDiffLabels = modPrefs.GetBool("SongCore", "displayDiffLabels", true, true); Configuration.ForceLongPreviews = modPrefs.GetBool("SongCore", "forceLongPreviews", false, true); //Delete Old Config try { File.Delete(songCoreIniPath); } catch { Logging.Logger.Warn("Failed to delete old config file!"); } } BSMLSettings.instance.AddSettingsMenu("SongCore", "SongCore.UI.settings.bsml", new SCSettingsController()); SceneManager.activeSceneChanged += OnActiveSceneChanged; _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.kyle1413.BeatSaber.SongCore"); BasicUI.GetIcons(); BS_Utils.Utilities.BSEvents.levelSelected += BSEvents_levelSelected; BS_Utils.Utilities.BSEvents.gameSceneLoaded += BSEvents_gameSceneLoaded; BS_Utils.Utilities.BSEvents.lateMenuSceneLoadedFresh += BSEvents_menuSceneLoadedFresh; if (!File.Exists(Collections.DataPath)) { File.Create(Collections.DataPath); } else { Collections.LoadExtraSongData(); } Collections.RegisterCustomCharacteristic(BasicUI.MissingCharIcon !, "Missing Characteristic", "Missing Characteristic", "MissingCharacteristic", "MissingCharacteristic", false, false, 1000); Collections.RegisterCustomCharacteristic(BasicUI.LightshowIcon !, "Lightshow", "Lightshow", "Lightshow", "Lightshow", false, false, 100); Collections.RegisterCustomCharacteristic(BasicUI.ExtraDiffsIcon !, "Lawless", "Lawless - Anything Goes", "Lawless", "Lawless", false, false, 101); var foldersXmlFilePath = Path.Combine(UnityGame.UserDataPath, nameof(SongCore), "folders.xml"); if (!File.Exists(foldersXmlFilePath)) { File.WriteAllBytes(foldersXmlFilePath, Utilities.Utils.GetResource(Assembly.GetExecutingAssembly(), "SongCore.Data.folders.xml")); } Loader.SeperateSongFolders.InsertRange(0, Data.SeperateSongFolder.ReadSeperateFoldersFromFile(foldersXmlFilePath)); }
private void OnMenuSceneLoadedFresh() { if (!init) { init = true; config = new BS_Utils.Utilities.Config("Custom Platforms"); PlatformManager.OnLoad(); } }
public static void Read() { if (!File.Exists(ConfigPath)) { if (CheckForOldConfig()) { var oldConfig = new BS_Utils.Utilities.Config("NjsFixer"); UserConfig = new NjsFixerConfig(); UserConfig.njs = oldConfig.GetFloat("NjsFixer", "njs", 0, true); UserConfig.bpm = oldConfig.GetFloat("NjsFixer", "bpm", 0, true); UserConfig.spawnOffset = oldConfig.GetFloat("NjsFixer", "spawnOffset", 0, true); UserConfig.enabled = oldConfig.GetBool("NjsFixer", "Enabled", false, true); UserConfig.dontForceNJS = oldConfig.GetBool("NjsFixer", "DontForceNJS", false, true); UserConfig.jumpDistance = oldConfig.GetFloat("NjsFixer", "DesiredJumpDistance", 24f, true); UserConfig.minJumpDistance = oldConfig.GetInt("NjsFixer", "minJumpDistance", 20, true); UserConfig.maxJumpDistance = oldConfig.GetInt("NjsFixer", "maxJumpDistance", 30, true); try { File.Delete(Path.Combine(IPA.Utilities.UnityGame.UserDataPath, "NjsFixer.ini")); } catch (Exception ex) { Logger.log.Warn($"Failed to delete old NjsFixer Config file {ex}"); } } else { UserConfig = new NjsFixerConfig(); } Write(); } else { UserConfig = JsonConvert.DeserializeObject <NjsFixerConfig>(File.ReadAllText(ConfigPath)); } UserConfig.preferredValues = UserConfig.preferredValues.OrderByDescending(x => x.njs).ToList(); /* * njs = ModPrefs.GetFloat("NjsFixer", "njs", 0, true); * bpm = ModPrefs.GetFloat("NjsFixer", "bpm", 0, true); * spawnOffset = ModPrefs.GetFloat("NjsFixer", "spawnOffset", 0, true); * enabled = ModPrefs.GetBool("NjsFixer", "Enabled", false, true); * dontForceNJS = ModPrefs.GetBool("NjsFixer", "DontForceNJS", false, true); * jumpDistance = ModPrefs.GetFloat("NjsFixer", "DesiredJumpDistance", 24f, true); */ }
public void OnApplicationStart() { BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh; config = new BS_Utils.Utilities.Config("ScoreboardStylist"); hexMap = new Dictionary <string, string>(); hexMap.Add("#FFFFFF", config.GetString("Colors", "default", "#FFFFFF", true)); hexMap.Add("#F96854", config.GetString("Colors", "patron", "#F96854", true)); hexMap.Add("#1ABC9C", config.GetString("Colors", "rankingTeam", "#1ABC9C", true)); hexMap.Add("#FF03E3", config.GetString("Colors", "staff", "#FF03E3", true)); hexMap.Add("#FFD42A", config.GetString("Colors", "percent", "#FFD42A", true)); hexMap.Add("#6772E5", config.GetString("Colors", "pp", "#6772E5", true)); rankColor = config.GetString("Colors", "rank", "#FFFFFF", true); scoreColor = config.GetString("Colors", "score", "#FFFFFF", true); var harmony = HarmonyInstance.Create("com.rolo.BeatSaber.ScoreboardStylist"); harmony.PatchAll(Assembly.GetExecutingAssembly()); }
public void Init(IPALogger logger) { Logger.logger = logger; _config = new BS_Utils.Utilities.Config("Deviation Counter"); LoadConfig(); }
/// <summary> /// Called before Start or Updates by Unity infrastructure /// </summary> public void Awake() { config = new BS_Utils.Utilities.Config(Name); NoArrowsOption = config.GetBool(Name, Option, false, true); }
public void OnApplicationStart() { harmony = HarmonyInstance.Create(id); config = new BS_Utils.Utilities.Config("Accurate Hit Scores"); isEnabled = config.GetBool("Settings", "Enabled", false, true); }
private static void OnLoadSettingsEvent(BS_Utils.Utilities.Config iniProfile, LoadSettingsType type) { try { ChromaLogger.Log("Loading settings [" + type.ToString() + "]", ChromaLogger.Level.INFO); string iniName = ModPrefs.GetString("Chroma", "ConfigProfile", "default", true); //TODO get the thing IniProfile = new BS_Utils.Utilities.Config("Chroma/Preferences/" + iniName); ChromaLogger.Log("--- From file " + iniName); BS_Utils.Gameplay.GetUserInfo.UpdateUserInfo(); Username = BS_Utils.Gameplay.GetUserInfo.GetUserName(); UserID = BS_Utils.Gameplay.GetUserInfo.GetUserID(); ChromaLogger.Log(Greetings.GetGreeting(UserID, Username), ChromaLogger.Level.INFO); if (DebugMode) { ChromaLogger.Log("=== YOUR ID : " + UserID.ToString()); } if (type == LoadSettingsType.INITIAL) { timesLaunched = ChromaConfig.GetInt("Other", "timesLaunched", timesLaunched + 1); ChromaConfig.SetInt("Other", "timesLaunched", timesLaunched); } /* * MAP */ customMapCheckingEnabled = ChromaConfig.GetBool("Map", "customMapCheckingEnabled", true); customColourEventsEnabled = ChromaConfig.GetBool("Map", "customColourEventsEnabled", true); customSpecialEventsEnabled = ChromaConfig.GetBool("Map", "customSpecialEventsEnabled", true); /* * AUDIO */ masterVolume = Mathf.Clamp01(ChromaConfig.GetFloat("Audio", "masterVolume", 1)); AudioUtil.Instance.SetVolume(masterVolume); /* * TECHNICOLOUR */ if (type == LoadSettingsType.INITIAL) { technicolourEnabled = ChromaConfig.GetBool("Technicolour", "technicolourEnabled", false); technicolourLightsStyle = (TechnicolourStyle)ChromaConfig.GetInt("Technicolour", "technicolourLightsStyle", 1); //technicolourLightsIndividual = GetBool("Technicolour", "technicolourLightsIndividual", technicolourLightsIndividual); technicolourLightsGrouping = (TechnicolourLightsGrouping)ChromaConfig.GetInt("Technicolour", "technicolourLightsGrouping", 1); if (technicolourLightsGrouping == TechnicolourLightsGrouping.ISOLATED) { TechnicolourLightsGrouping = TechnicolourLightsGrouping.ISOLATED_GROUP; } technicolourLightsFrequency = GetFloat("Technicolour", "technicolourLightsFrequency", technicolourLightsFrequency); technicolourSabersStyle = (TechnicolourStyle)ChromaConfig.GetInt("Technicolour", "technicolourSabersStyle", 0); technicolourBlocksStyle = (TechnicolourStyle)ChromaConfig.GetInt("Technicolour", "technicolourBlocksStyle", 0); technicolourWallsStyle = (TechnicolourStyle)ChromaConfig.GetInt("Technicolour", "technicolourWallsStyle", 0); matchTechnicolourSabers = ChromaConfig.GetBool("Technicolour", "matchTechnicolourSabers", false); } string[] technicolourColdString = ChromaConfig.GetString("Technicolour", "technicolourB", "0;128;255;255-0;255;0;255-0;0;255;255-0;255;204;255").Split('-'); string[] technicolourWarmString = ChromaConfig.GetString("Technicolour", "technicolourA", "255;0;0;255-255;0;255;255-255;153;0;255-255;0;102;255").Split('-'); Color[] technicolourCold = new Color[technicolourColdString.Length]; Color[] technicolourWarm = new Color[technicolourWarmString.Length]; for (int i = 0; i < Mathf.Max(technicolourCold.Length, technicolourWarm.Length); i++) { if (i < technicolourCold.Length) { technicolourCold[i] = ColourManager.ColourFromString(technicolourColdString[i]); } if (i < technicolourWarm.Length) { technicolourWarm[i] = ColourManager.ColourFromString(technicolourWarmString[i]); } } ColourManager.TechnicolourWarmPalette = technicolourWarm; ColourManager.TechnicolourColdPalette = technicolourCold; /* * NOTES */ ColourManager.A = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Notes", "colourA", "DEFAULT"), ColourManager.DefaultA); ColourManager.B = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Notes", "colourB", "DEFAULT"), ColourManager.DefaultB); ColourManager.AltA = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Notes", "colourAltA", "Notes Magenta"), ColourManager.DefaultAltA); ColourManager.AltB = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Notes", "colourAltB", "Notes Green"), ColourManager.DefaultAltB); ColourManager.NonColoured = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Notes", "colourNonColoured", "Notes White"), ColourManager.DefaultNonColoured); ColourManager.DoubleHit = ColourManager.DoubleHit = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Notes", "colourDuochrome", "Notes Purple")); ColourManager.Super = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Notes", "colourSuper", "Notes Gold"), ColourManager.DefaultSuper); /* * LIGHTS */ ColourManager.LightAmbient = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Lights", "lightAmbient", "DEFAULT"), ColourManager.DefaultLightAmbient); ColourManager.LightA = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Lights", "lightColourA", "DEFAULT"), ColourManager.DefaultLightA); ColourManager.LightB = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Lights", "lightColourB", "DEFAULT"), ColourManager.DefaultLightB); ColourManager.LightAltA = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Lights", "lightColourAltA", "Light Magenta"), ColourManager.DefaultLightAltA); ColourManager.LightAltB = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Lights", "lightColourAltB", "Light Green"), ColourManager.DefaultLightAltB); ColourManager.LightWhite = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Lights", "lightColourWhite", "Light White"), ColourManager.DefaultLightWhite); ColourManager.LightGrey = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Lights", "lightColourGrey", "Light Grey"), ColourManager.DefaultLightGrey); /* * AESTHETICS */ ColourManager.BarrierColour = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Aesthetics", "barrierColour", "Barrier Red"), ColourManager.DefaultBarrierColour); ColourManager.LaserPointerColour = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Aesthetics", "laserPointerColour", "DEFAULT"), ColourManager.DefaultB); ColourManager.SignA = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Aesthetics", "signColourA", "DEFAULT"), ColourManager.DefaultA); ColourManager.SignB = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Aesthetics", "signColourB", "DEFAULT"), ColourManager.DefaultB); ColourManager.Platform = ChromaSettingsUI.GetColor(ChromaConfig.GetString("Aesthetics", "platformAccoutrements", "DEFAULT"), ColourManager.DefaultB); ColourManager.barrierColourCorrectionScale = ChromaConfig.GetFloat("Aesthetics", "barrierColourCorrectionScale", 1f); ChromaConfig.saberTrailStrength = ChromaConfig.GetFloat("Aesthetics", "saberTrailStrength", 1f); /* * MODIFIERS */ lightshowModifier = ChromaConfig.GetBool("Modifiers", "lightshowModifier", false); /* * OTHER */ legacyLighting = ChromaConfig.GetBool("Other", "legacyLighting", false); debugMode = ChromaConfig.GetBool("Other", "debugMode", false); hideSubMenus = ChromaConfig.GetBool("Other", "hideSubMenus", false); waiverRead = ChromaConfig.GetInt("Other", "safetyWaiver", 0) == 51228; /*string waiverFilePath = Environment.CurrentDirectory.Replace('\\', '/') + "/UserData/ChromaToggle/waiver_411.txt"; * if (File.Exists(waiverFilePath)) { * waiverRead = true; * ChromaLogger.Log("Waiver found."); * }*/ ColourManager.RefreshLights(); if (type == LoadSettingsType.MANUAL) { AudioUtil.Instance.PlayOneShotSound("ConfigReload.wav"); } } catch (Exception e) { ChromaLogger.Log("Error loading Chroma configs! Waduhek", ChromaLogger.Level.ERROR); ChromaLogger.Log(e); } }
internal static void Init() { config = new BS_Utils.Utilities.Config(configName); }
internal static void Init() { config = new BS_Utils.Utilities.Config(Plugin.PluginName); }