private void SaveChromaXml()
    {
        config = new ChromaConfig();

        config.chromaKey        = chromaKey.color;
        config.hueThreshold     = hueThreshold.sliderValue;
        config.minShadeDarkness = minShadeDarkness.sliderValue;
        config.maxShadeDarkness = maxShadeDarkness.sliderValue;
        config.minSaturation    = minSaturation.sliderValue;
        config.maxSaturation    = maxSaturation.sliderValue;
        config.minLightness     = minLightness.sliderValue;
        config.maxLightness     = maxLightness.sliderValue;

        PlayerPrefs.SetString("ChromaConfig", config.ToString());

        Debug.Log("Chroma configuration saved.");
    }
Beispiel #2
0
        public void OnUpdate()
        {
            if (doRefreshLights && SceneManager.GetActiveScene() != null && SceneManager.GetActiveScene().name == "MenuCore")
            {
                ColourManager.RefreshLights();
                doRefreshLights = false;
            }

            if (Input.GetKeyDown(KeyCode.Backslash))
            {
                ChromaConfig.LoadSettings(ChromaConfig.LoadSettingsType.MANUAL);
            }

            if (Input.GetKeyDown(KeyCode.Period) && ChromaConfig.DebugMode)
            {
                if (Input.GetKey(KeyCode.Alpha1))
                {
                    ColourManager.RecolourNeonSign(ColourManager.SignA, ColourManager.SignB);
                }
                else if (Input.GetKey(KeyCode.Alpha2))
                {
                    ColourManager.RefreshLights();
                }
                else if (Input.GetKey(KeyCode.Alpha3))
                {
                    ChromaTesting.Test();
                }
                else
                {
                    ChromaLogger.Log(" [[ Debug Info ]]");

                    if (ChromaConfig.TechnicolourEnabled)
                    {
                        ChromaLogger.Log("TechnicolourStyles (Lights | Walls | Notes | Sabers) : " + ChromaConfig.TechnicolourLightsStyle + " | " + ChromaConfig.TechnicolourWallsStyle + " | " + ChromaConfig.TechnicolourBlocksStyle + " | " + ChromaConfig.TechnicolourSabersStyle);
                        ChromaLogger.Log("Technicolour (Lights | Walls | Notes | Sabers) : " + ColourManager.TechnicolourLights + " | " + ColourManager.TechnicolourBarriers + " | " + ColourManager.TechnicolourBlocks + " | " + ColourManager.TechnicolourSabers);
                    }

                    DebugButtonPressedEvent?.Invoke();
                }
            }
        }
    private void LoadChromaConfig()
    {
        string configData = PlayerPrefs.GetString("ChromaConfig", "");

        if (!String.IsNullOrEmpty(configData))
        {
            try {
                XmlSerializer s = new XmlSerializer(typeof(ChromaConfig));
                byte[]        encodedDataAsBytes = System.Convert.FromBase64String(configData);
                config = (ChromaConfig)s.Deserialize(new StringReader(System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes)));

                chromaKey.color              = config.chromaKey;
                hueThreshold.sliderValue     = config.hueThreshold;
                minShadeDarkness.sliderValue = config.minShadeDarkness;
                maxShadeDarkness.sliderValue = config.maxShadeDarkness;
                minSaturation.sliderValue    = config.minSaturation;
                maxSaturation.sliderValue    = config.maxSaturation;
                minLightness.sliderValue     = config.minLightness;
                maxLightness.sliderValue     = config.maxLightness;

                Debug.Log("Chroma configuration loaded.");
            } catch (Exception e) {
                Debug.LogError(e.Message);
            }
        }
        else
        {
            chromaKey.color              = Color.green;
            hueThreshold.sliderValue     = 0.2f;
            minShadeDarkness.sliderValue = 0;
            maxShadeDarkness.sliderValue = 1;
            minSaturation.sliderValue    = 0;
            maxSaturation.sliderValue    = 1;
            minLightness.sliderValue     = 0;
            maxLightness.sliderValue     = 1;

            Debug.Log("Chroma default configuration loaded.");
        }

        EndLoad();
    }
Beispiel #4
0
        private void Initialize()
        {
            try {
                try {
                    Directory.CreateDirectory(Environment.CurrentDirectory.Replace('\\', '/') + "/UserData/Chroma");
                } catch (Exception e) {
                    ChromaLogger.Log("Error " + e.Message + " while trying to create Chroma directory", ChromaLogger.Level.WARNING);
                }

                ChromaLogger.Init();

                ChromaLogger.Log("************************************", ChromaLogger.Level.INFO);
                ChromaLogger.Log("Initializing Chroma [" + ChromaPlugin.Version.ToString() + "]", ChromaLogger.Level.INFO);
                ChromaLogger.Log("************************************", ChromaLogger.Level.INFO);

                //Used for getting gamemode data mostly
                try {
                    ChromaLogger.Log("Initializing Coordinators");
                    BaseGameMode.InitializeCoordinators();
                } catch (Exception e) {
                    ChromaLogger.Log("Error initializing coordinators", ChromaLogger.Level.ERROR);
                    throw e;
                }

                ChromaLogger.Log("Registering scenechange events");
                SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
                SceneManager.sceneLoaded        += SceneManager_sceneLoaded;

                //Getting and starting all the extension plugins
                try {
                    ChromaLogger.Log("Checking for extensions.");
                    foreach (PluginLoader.PluginInfo pluginInfo in PluginManager.AllPlugins)
                    {
                        //We can't get IBeatSaberPlugin references

                        /*if (plugin is IChromaExtension chromaExtension) {
                         *  chromaExtension.ChromaApplicationStarted(this);
                         *  chromaExtensions.Add(chromaExtension);
                         * }*/
                    }
                } catch (Exception) {
                    ChromaLogger.Log("Error adding all Extension plugins!  Extension registration interrupted.", ChromaLogger.Level.ERROR);
                }

                //Harmony & extension Harmony patches
                ChromaLogger.Log("Patching with Harmony.");
                try {
                    coreHarmony.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());
                    harmonyInstances.Add(coreHarmony);
                    foreach (IChromaExtension extension in chromaExtensions)
                    {
                        HarmonyInstance newPatch = extension.PatchHarmony();
                        if (newPatch != null)
                        {
                            harmonyInstances.Add(newPatch);
                        }
                    }
                } catch (Exception e) {
                    ChromaLogger.Log(e);
                    ChromaLogger.Log("This plugin requires Harmony.  Either you do not have it installed, or there was an error.", ChromaLogger.Level.ERROR);
                }

                ChromaLogger.Log("Creating AudioUtil");
                AudioUtil ab = AudioUtil.Instance;

                //Configuration Files
                try {
                    ChromaLogger.Log("Initializing Configuration");
                    ChromaConfig.Init();
                    ChromaConfig.LoadSettings(ChromaConfig.LoadSettingsType.INITIAL);
                } catch (Exception e) {
                    ChromaLogger.Log("Error loading Chroma configuration", ChromaLogger.Level.ERROR);
                    throw e;
                }

                ChromaLogger.Log("Refreshing Lights");
                ColourManager.RefreshLights();

                //Side panel
                try {
                    ChromaLogger.Log("Stealing Patch Notes Panel");
                    Greetings.RegisterChromaSideMenu();
                    SidePanelUtil.ReleaseInfoEnabledEvent += ReleaseInfoEnabled;
                } catch (Exception e) {
                    ChromaLogger.Log("Error handling UI side panel", ChromaLogger.Level.ERROR);
                    throw e;
                }
            } catch (Exception e) {
                ChromaLogger.Log("Failed to initialize ChromaPlugin!  Major error!", ChromaLogger.Level.ERROR);
                ChromaLogger.Log(e);
            }

            ChromaLogger.Log("Chroma finished initializing.  " + chromaExtensions.Count + " extensions found.", ChromaLogger.Level.INFO);

            try {
                SongCore.Collections.RegisterCapability("Chroma");
                SongCore.Collections.RegisterCapability("ChromaLite");
            } catch (Exception) {
                // This version of SongLoader doesn't support capabilities
            }
        }