Beispiel #1
0
        void Init()
        {
            string   currentDate = DateTime.Now.ToString("MM.dd.yyyy HH:mm:ss tt");
            DateTime currentDateTime;

            DateTime.TryParse(currentDate, out currentDateTime);
            DateTime lastDateCheck;

            DateTime.TryParse(rdCals, out lastDateCheck);

            if ((currentDateTime - lastDateCheck).TotalHours > 16)
            {
                dailyCalories = 0;
                ModPrefs.SetInt(Plugin.alias, "dailyCalories", dailyCalories);
                ModPrefs.SetString(Plugin.alias, "date", currentDate);
            }
            //Init Current Session Counter #
            /////////////////////////////////////////////////////////////////////////
            CscText = this.gameObject.AddComponent <TextMeshPro>();
            CscText.renderer.enabled       = visibleCurrentCalories;
            CscText.text                   = Plugin.Instance.mainConfig.sessionCalories.ToString();
            CscText.fontSize               = 2;
            CscText.color                  = Color.cyan;
            CscText.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            CscText.alignment              = TextAlignmentOptions.Center;
            CscText.rectTransform.position = menuPosition + new Vector3(-1, -0.2f, 0);
            CscText.rectTransform.rotation = slantBottom;
            //Init Current Sesion Counter Label
            /////////////////////////////////////////////////////////////////////////
            countCSC = new GameObject("countCSClabel");
            Labelcsc = countCSC.AddComponent <TextMeshPro>();
            Labelcsc.renderer.enabled       = visibleCurrentCalories;
            Labelcsc.text                   = "Current Session Calories";
            Labelcsc.fontSize               = 1;
            Labelcsc.color                  = Color.white;
            Labelcsc.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            Labelcsc.alignment              = TextAlignmentOptions.Center;
            Labelcsc.rectTransform.position = menuPosition + new Vector3(-1f, 0, 0);
            Labelcsc.rectTransform.rotation = slantBottom;
            /////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////
            //Init Life Calories Counter #
            /////////////////////////////////////////////////////////////////////////
            LcText = new GameObject("lifeCalories").gameObject.AddComponent <TextMeshPro>();
            LcText.renderer.enabled       = visibleLifeCalories;
            LcText.text                   = Plugin.Instance.mainConfig.lifeCalories.ToString();
            LcText.fontSize               = 2;
            LcText.color                  = Color.cyan;
            LcText.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            LcText.alignment              = TextAlignmentOptions.Center;
            LcText.rectTransform.position = menuPosition + new Vector3(1, -0.2f, 0);
            LcText.rectTransform.rotation = slantBottom;
            //Init Life Calories Counter Label
            /////////////////////////////////////////////////////////////////////////
            countLC = new GameObject("countLClabel");
            LabelLC = countLC.AddComponent <TextMeshPro>();
            LabelLC.renderer.enabled       = visibleLifeCalories;
            LabelLC.text                   = "All Calories";
            LabelLC.fontSize               = 1;
            LabelLC.color                  = Color.white;
            LabelLC.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            LabelLC.alignment              = TextAlignmentOptions.Center;
            LabelLC.rectTransform.position = menuPosition + new Vector3(1, 0, 0);
            LabelLC.rectTransform.rotation = slantBottom;
            /////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////
            //Init Daily Calories Counter #
            /////////////////////////////////////////////////////////////////////////
            DcText = new GameObject("dailyCalories").gameObject.AddComponent <TextMeshPro>();
            DcText.renderer.enabled       = visibleDailyCalories;
            DcText.text                   = Plugin.Instance.mainConfig.dailyCalories.ToString();
            DcText.fontSize               = 2;
            DcText.color                  = Color.cyan;
            DcText.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            DcText.alignment              = TextAlignmentOptions.Center;
            DcText.rectTransform.position = menuPosition + new Vector3(0, -0.2f, 0);
            DcText.rectTransform.rotation = slantBottom;
            //Init Daily Calories Counter Label
            /////////////////////////////////////////////////////////////////////////
            countDC = new GameObject("countDClabel");
            LabelDC = countDC.AddComponent <TextMeshPro>();
            LabelDC.renderer.enabled       = visibleDailyCalories;
            LabelDC.text                   = "Daily Calories";
            LabelDC.fontSize               = 1;
            LabelDC.color                  = Color.white;
            LabelDC.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            LabelDC.alignment              = TextAlignmentOptions.Center;
            LabelDC.rectTransform.position = menuPosition + new Vector3(0, 0, 0);
            LabelDC.rectTransform.rotation = slantBottom;
            /////////////////////////////////////////////////////////////////////////
            //Init Last Game Calories Counter #
            /////////////////////////////////////////////////////////////////////////
            LgcText = new GameObject("dailyCalories").gameObject.AddComponent <TextMeshPro>();
            LgcText.renderer.enabled       = visibleLastGameCalories;
            LgcText.text                   = "";
            LgcText.fontSize               = 2;
            LgcText.color                  = Color.cyan;
            LgcText.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            LgcText.alignment              = TextAlignmentOptions.Center;
            LgcText.rectTransform.position = menuPosition + new Vector3(2.5f, -0.6f, 0f);
            LgcText.rectTransform.rotation = Quaternion.Euler(0, 60, 0);
            //Init Last Game Song name Label // Displays version number on launch
            /////////////////////////////////////////////////////////////////////////
            CountLGC = new GameObject("countLGClabel").gameObject.AddComponent <TextMeshPro>();
            CountLGC.renderer.enabled       = visibleLastGameCalories;
            CountLGC.text                   = "BeFit Mod " + version;
            CountLGC.fontSize               = 1.5f;
            CountLGC.color                  = Color.white;
            CountLGC.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            CountLGC.alignment              = TextAlignmentOptions.Center;
            CountLGC.rectTransform.position = menuPosition + new Vector3(2.5f, -0.4f, 0f);
            CountLGC.rectTransform.rotation = Quaternion.Euler(0, 60, 0);
            /////////////////////////////////////////////////////////////////////////
            //Init Last Game Calories Counter Label
            /////////////////////////////////////////////////////////////////////////
            if (!Plugin.Instance.mainConfig.displayWeightOnLaunch)
            {
                return;
            }
            string weight;

            if (unitMetric)
            {
                weight = Plugin.Instance.mainConfig.weightKGS + "<size=60%>kgs";
            }
            else
            {
                weight = Plugin.Instance.mainConfig.weightLBS + "<size=60%>lbs";
            }
            LabelLG = new GameObject("countLGClabel").gameObject.AddComponent <TextMeshPro>();
            LabelLG.renderer.enabled       = visibleLastGameCalories;
            LabelLG.text                   = "<size=100%>Current Weight Setting ~ " + weight;
            LabelLG.fontSize               = 2f;
            LabelLG.color                  = Color.white;
            LabelLG.font                   = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            LabelLG.alignment              = TextAlignmentOptions.Center;
            LabelLG.rectTransform.position = menuPosition + new Vector3(2.5f, -0.2f, 0f);
            LabelLG.rectTransform.rotation = Quaternion.Euler(0, 60, 0);
            /////////////////////////////////////////////////////////////////////////
        }
Beispiel #2
0
        void Init()
        {
            string currentDate = DateTime.Now.ToString("dd.MM.yyyy");

            if (rdCals != currentDate)
            {
                Console.WriteLine("Current date being set to: " + currentDate + ". Setting daily calorie count to zero;");
                dailyCalories = 0;
                ModPrefs.SetInt("fitNessMod", "dailyCalories", dailyCalories);
            }
            //Init Current Session Counter #
            /////////////////////////////////////////////////////////////////////////
            cscText           = this.gameObject.AddComponent <TextMeshPro>();
            cscText.text      = ModPrefs.GetInt("fitNessMod", "sessionCalories", 0, true).ToString();
            cscText.fontSize  = 2;
            cscText.color     = Color.cyan;
            cscText.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            cscText.alignment = TextAlignmentOptions.Center;
            cscText.rectTransform.position = menuPosition + new Vector3(-1, -0.2f, 0);
            cscText.rectTransform.rotation = slantBottom;

            //Init Current Sesion Counter Label
            /////////////////////////////////////////////////////////////////////////
            countCSC = new GameObject("countCSClabel");
            TextMeshPro labelcsc = countCSC.AddComponent <TextMeshPro>();

            labelcsc.text      = "Current Session Calories";
            labelcsc.fontSize  = 1;
            labelcsc.color     = Color.white;
            labelcsc.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            labelcsc.alignment = TextAlignmentOptions.Center;
            labelcsc.rectTransform.position = menuPosition + new Vector3(-1f, 0, 0);
            labelcsc.rectTransform.rotation = slantBottom;
            /////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////
            //Init Life Calories Counter #
            /////////////////////////////////////////////////////////////////////////
            lcText           = new GameObject("lifeCalories").gameObject.AddComponent <TextMeshPro>();
            lcText.text      = ModPrefs.GetInt("fitNessMod", "lifeCalories", 0, true).ToString();
            lcText.fontSize  = 2;
            lcText.color     = Color.cyan;
            lcText.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            lcText.alignment = TextAlignmentOptions.Center;
            lcText.rectTransform.position = menuPosition + new Vector3(1, -0.2f, 0);
            lcText.rectTransform.rotation = slantBottom;

            //Init Life Calories Counter Label
            /////////////////////////////////////////////////////////////////////////
            countLC = new GameObject("countLClabel");
            TextMeshPro labelLC = countLC.AddComponent <TextMeshPro>();

            labelLC.text      = "All Calories";
            labelLC.fontSize  = 1;
            labelLC.color     = Color.white;
            labelLC.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            labelLC.alignment = TextAlignmentOptions.Center;
            labelLC.rectTransform.position = menuPosition + new Vector3(1, 0, 0);
            labelLC.rectTransform.rotation = slantBottom;
            /////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////
            //Init Daily Calories Counter #
            /////////////////////////////////////////////////////////////////////////
            dcText           = new GameObject("dailyCalories").gameObject.AddComponent <TextMeshPro>();
            dcText.text      = ModPrefs.GetInt("fitNessMod", "dailyCalories", 0, true).ToString();
            dcText.fontSize  = 2;
            dcText.color     = Color.cyan;
            dcText.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            dcText.alignment = TextAlignmentOptions.Center;
            dcText.rectTransform.position = menuPosition + new Vector3(0, -0.2f, 0);
            dcText.rectTransform.rotation = slantBottom;

            //Init Daily Calories Counter Label
            /////////////////////////////////////////////////////////////////////////
            countDC = new GameObject("countDClabel");
            TextMeshPro labelDC = countDC.AddComponent <TextMeshPro>();

            labelDC.text      = "Daily Calories";
            labelDC.fontSize  = 1;
            labelDC.color     = Color.white;
            labelDC.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            labelDC.alignment = TextAlignmentOptions.Center;
            labelDC.rectTransform.position = menuPosition + new Vector3(0, 0, 0);
            labelDC.rectTransform.rotation = slantBottom;
            /////////////////////////////////////////////////////////////////////////



            //Init Last Game Calories Counter #
            /////////////////////////////////////////////////////////////////////////
            lgcText           = new GameObject("dailyCalories").gameObject.AddComponent <TextMeshPro>();
            lgcText.text      = "";
            lgcText.fontSize  = 2;
            lgcText.color     = Color.cyan;
            lgcText.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            lgcText.alignment = TextAlignmentOptions.Center;
            lgcText.rectTransform.position = menuPosition + new Vector3(2.5f, -0.6f, 0f);
            lgcText.rectTransform.rotation = Quaternion.Euler(0, 60, 0);

            //Init Last Game Song name Label // Displays version number on launch
            /////////////////////////////////////////////////////////////////////////
            countLGC           = new GameObject("countLGClabel").gameObject.AddComponent <TextMeshPro>();
            countLGC.text      = version;
            countLGC.fontSize  = 1.5f;
            countLGC.color     = Color.white;
            countLGC.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            countLGC.alignment = TextAlignmentOptions.Center;
            countLGC.rectTransform.position = menuPosition + new Vector3(2.5f, -0.4f, 0f);
            countLGC.rectTransform.rotation = Quaternion.Euler(0, 60, 0);
            /////////////////////////////////////////////////////////////////////////
            //Init Last Game Calories Counter Label
            /////////////////////////////////////////////////////////////////////////
            labelLG           = new GameObject("countLGClabel").gameObject.AddComponent <TextMeshPro>();
            labelLG.text      = "BeFit Mod"; //I'm not set on the name
            labelLG.fontSize  = 2f;
            labelLG.color     = Color.white;
            labelLG.font      = Resources.Load <TMP_FontAsset>("Beon SDF No-Glow");
            labelLG.alignment = TextAlignmentOptions.Center;
            labelLG.rectTransform.position = menuPosition + new Vector3(2.5f, -0.2f, 0f);
            labelLG.rectTransform.rotation = Quaternion.Euler(0, 60, 0);
            /////////////////////////////////////////////////////////////////////////
        }
        public void OnActiveSceneChanged(Scene arg0, Scene scene)
        {
            if (scene.name == "MenuViewControllers")
            {
                activateDuringIsolated = false;
                Log("Switched to Menu");
                SharedCoroutineStarter.instance.StartCoroutine(GrabPP());

                var controllers = Resources.FindObjectsOfTypeAll <VRController>();
                if (controllers != null)
                {
                    foreach (VRController controller in controllers)
                    {
                        if (controller != null)
                        {
                            if (controller.ToString() == "ControllerLeft (VRController)")
                            {
                                leftController = controller;
                            }
                            if (controller.ToString() == "ControllerRight (VRController)")
                            {
                                rightController = controller;
                            }
                        }
                        //        Log(controller.ToString());
                    }
                    //                 Log("Left:" + leftController.ToString());
                    //                   Log("Right: " + rightController.ToString());
                }
            }



            if (scene.name == "GameCore")
            {
                RemovePatches();
            }
            if (_mainSettingsModel == null)
            {
                var menu = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().FirstOrDefault();
                if (menu != null)
                {
                    _mainSettingsModel = menu.GetField <MainSettingsModelSO>("_mainSettingsModel");
                    _mainSettingsModel.Load(true);
                    Log("RUMBLE: " + _mainSettingsModel.controllersRumbleEnabled.ToString());

                    if (!setDefaultRumble)
                    {
                        defaultRumble = _mainSettingsModel.controllersRumbleEnabled;
                        ModPrefs.SetInt("GameplayModifiersPlus", "GameRumbleSetting", _mainSettingsModel.controllersRumbleEnabled ? 1 : 0);
                        setDefaultRumble = true;
                        Log("Set Default Rumble Value");
                    }
                }
            }

            if (_mainSettingsModel != null)
            {
                defaultRumble = ModPrefs.GetInt("GameplayModifiersPlus", "GameRumbleSetting", -1, false) != 1 ? false : true;
                _mainSettingsModel.controllersRumbleEnabled.value = defaultRumble;
                _mainSettingsModel.Save();
            }


            paused = false;
            if (!customColorsInstalled)
            {
                if (colorA != null)
                {
                    colorA.SetColor(defColorA);
                }
                if (colorB != null)
                {
                    colorB.SetColor(defColorB);
                }
            }


            //        try
            //        {
            if (scene.name == "EmptyTransition")
            {
                Log("Resetting Chat Powers Object");
                if (chatPowers != null)
                {
                    GameObject.Destroy(chatPowers);
                }
            }
            if (chatPowers == null)
            {
                Log("Null Creation of Chat Powers Object");
                chatPowers = new GameObject("Chat Powers");
                GameObject.DontDestroyOnLoad(chatPowers);
                twitchPowers = chatPowers.AddComponent <TwitchPowers>();
            }

            //        }
            //        catch(Exception ex)
            //        {
            //           Log(ex.ToString());
            //        }

            GMPDisplay display = chatPowers.GetComponent <GMPDisplay>();

            if (display != null)
            {
                display.Destroy();
                GameObject.Destroy(display);
            }



            ReadPrefs();
            if (GMPUI.chatIntegration && twitchPluginInstalled)
            {
                if (twitchPowers != null)
                {
                    cooldowns.ResetCooldowns();
                    TwitchPowers.ResetPowers(false);
                    twitchPowers.StopAllCoroutines();
                }
                if (ChatConfig.resetChargesEachLevel)
                {
                    charges = 0;
                }
            }

            //    twitchCommands.StopAllCoroutines();
            haveSongNJS = false;
            if (soundIsPlaying == true)
            {
                gnomeSound.Stop();
            }
            soundIsPlaying = false;
            isValidScene   = false;
            playerInfo     = false;
            modifiersInit  = false;
            if (arg0.name == "EmpyTransition" && chatPowers != null)
            {
                GameObject.Destroy(chatPowers);
            }

            if (scene.name == "GameCore")
            {
                Log("Isolated: " + BS_Utils.Gameplay.Gamemode.IsIsolatedLevel);
                isValidScene = true;
                if (BS_Utils.Gameplay.Gamemode.IsIsolatedLevel && !activateDuringIsolated)
                {
                    Log("Isolated Level, not activating");
                    return;
                }
                //     Log("Pre GrabGrab");
                GameObject.Destroy(GameObject.Find("Color Setter"));
                soundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault();
                spawnController    = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault();
                energyCounter      = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().First();
                energyPanel        = Resources.FindObjectsOfTypeAll <GameEnergyUIPanel>().First();
                ColorManager       = Resources.FindObjectsOfTypeAll <ColorManager>().First();
                levelData          = BS_Utils.Plugin.LevelData;
                //    Log("Post GrabGrab");
                if (spawnController != null)
                {
                    spawnController.noteDidStartJumpEvent += SpawnController_ModifiedJump;
                    spawnController.noteWasCutEvent       += SpawnController_ScaleRemoveCut;
                    spawnController.noteWasMissedEvent    += SpawnController_ScaleRemoveMiss;
                }
                else
                {
                    Log("Spawn Controller Null");
                }
                //   Log("Post GrabGrab 2");
                currentSongSpeed = levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul;

                BS_Utils.Plugin.LevelDidFinishEvent += LevelData_didFinishEvent;
                //   Log("Post GrabGrab 3");
                if (!Multiplayer.MultiMain.multiActive.Value)
                {
                    if (GMPUI.chatIntegration && ChatConfig.maxCharges > 0 && twitchPluginInstalled)
                    {
                        chatPowers.AddComponent <GMPDisplay>();
                    }
                    if (GMPUI.chatIntegration && ChatConfig.timeForCharges > 0 && twitchPluginInstalled)
                    {
                        twitchPowers.StartCoroutine(TwitchPowers.ChargeOverTime());
                    }
                }
                //   Log("Post GrabGrab 4");


                pauseManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().First();
                var colors = Resources.FindObjectsOfTypeAll <SimpleColorSO>();
                //    Log("Pre Color");
                foreach (SimpleColorSO color in colors)
                {
                    //     Log(color.name);
                    if (color.name == "BaseNoteColor1")
                    {
                        colorA = color;
                    }
                    if (color.name == "BaseNoteColor0")
                    {
                        colorB = color;
                    }
                }
                oldColorA.SetColor(colorA);
                oldColorB.SetColor(colorB);
                //      Log("Pre ChatInt");

                //      Log(colorA.color.ToString());
                if (GMPUI.chatIntegration && charges <= ChatConfig.maxCharges && twitchPluginInstalled)
                {
                    charges += ChatConfig.chargesPerLevel;
                    if (charges > ChatConfig.maxCharges)
                    {
                        charges = ChatConfig.maxCharges;
                    }
                    //          TryAsyncMessage("Current Charges: " + charges);
                }


                //  Log("Pre Audio/Player");
                //   ReflectionUtil.SetProperty(typeof(PracticePlugin.Plugin), "TimeScale", 1f);
                AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                if (AudioTimeSync != null)
                {
                    songAudio = AudioTimeSync.GetField <AudioSource>("_audioSource");
                    if (songAudio == null)
                    {
                        Log("Audio null");
                    }
                    //              Log("Object Found");
                }
                //Get Sabers
                player = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault();
                if (player != null)
                {
                    playerInfo = true;
                }
                else
                {
                    playerInfo = false;
                    Log("Player is null");
                }
                CheckGMPModifiers();
            }
        }
Beispiel #4
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", "maxSimultaneousDownloads"))
            {
                ModPrefs.SetInt("BeatSaverDownloader", "maxSimultaneousDownloads", 3);
                Logger.Log("Created config");
            }
            else
            {
                maxSimultaneousDownloads = ModPrefs.GetInt("BeatSaverDownloader", "maxSimultaneousDownloads", 3, 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));

            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");
            }

            if (!disableSongListTweaks)
            {
                LoadSongBrowserConfig();
            }
        }
Beispiel #5
0
 public void Resolution3()
 {
     SetResolution(ModPrefs.GetInt(ModCategory, Resolution3Pref));
 }
Beispiel #6
0
 async void Awake()
 {
     ModPrefs.SetString("fitNessMod", "date", DateTime.Now.ToString("dd.MM.yyyy"));
     await GetCalories();
 }
Beispiel #7
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 #8
0
        //protected virtual void ToggleRotationLock()
        //{
        //    if(lockRotation)
        //    {
        //        lockRotation = false;
        //        CreateInfoMsg("Rotation released");
        //    }
        //    else
        //    {
        //        lockRotation = true;
        //        //lastTargetAngle = CameraAdjustedEulerAngles(lockOnTarget, CameraTransform);
        //        CreateInfoMsg("Rotation locked");
        //    }
        //}

        protected virtual void GamepadControls()
        {
            if (!controllerEnabled)
            {
                return;
            }
            gamepadStatePrev = gamepadState;
            gamepadState     = GamePad.GetState(controllerIndex, GamePadDeadZone.Circular);
            if (!gamepadState.IsConnected)
            {
                return;
            }
            animSwitched = false;

            if (gamepadStatePrev.Buttons.A == ButtonState.Released && gamepadState.Buttons.A == ButtonState.Pressed)
            {
                LockOn();
            }

            if (gamepadStatePrev.Buttons.B == ButtonState.Released && gamepadState.Buttons.B == ButtonState.Pressed)
            {
                LockOnRelease();
            }

            if (gamepadStatePrev.Buttons.Y == ButtonState.Released && gamepadState.Buttons.Y == ButtonState.Pressed)
            {
                CharaSwitch(true);
            }

            if (gamepadStatePrev.Buttons.X == ButtonState.Released && gamepadState.Buttons.X == ButtonState.Pressed)
            {
                int next = animMoveSetCurrent + 1 > animMoveSets.Count - 1 ? 0 : animMoveSetCurrent + 1;
                animMoveSetCurrent = next;
                ModPrefs.SetInt("LockOnPlugin.Misc", "MovementAnimSet", next);
                animSwitched = true;
            }

            if (gamepadStatePrev.Buttons.RightStick == ButtonState.Released && gamepadState.Buttons.RightStick == ButtonState.Pressed)
            {
                if (FileManager.PluginInstalled("TogglePOVNeo") || FileManager.PluginInstalled("TogglePOV"))
                {
                    Utils.InvokePluginMethod("TogglePOV.HSPluginBase", "TogglePOV");
                }
            }

            if (gamepadStatePrev.Buttons.LeftStick == ButtonState.Released && gamepadState.Buttons.LeftStick == ButtonState.Pressed)
            {
                LockOn(CameraTargetManager.MOVEMENTPOINT_NAME);
            }

            if (gamepadState.DPad.Right == ButtonState.Pressed)
            {
                Guitime.angle = 1f;
                float newAngle = CameraAngle.z - 1f * Time.deltaTime * 60f;
                newAngle    = Mathf.Repeat(newAngle, 360f);
                CameraAngle = new Vector3(CameraAngle.x, CameraAngle.y, newAngle);
            }
            else if (gamepadState.DPad.Left == ButtonState.Pressed)
            {
                Guitime.angle = 1f;
                float newAngle = CameraAngle.z + 1f * Time.deltaTime * 60f;
                newAngle    = Mathf.Repeat(newAngle, 360f);
                CameraAngle = new Vector3(CameraAngle.x, CameraAngle.y, newAngle);
            }
            else if (gamepadState.DPad.Up == ButtonState.Pressed)
            {
                if (gamepadState.Buttons.LeftShoulder == ButtonState.Pressed)
                {
                    Guitime.fov = 1f;
                    float newFov = CameraFov - 1f * Time.deltaTime * 60f;
                    CameraFov = Mathf.Clamp(newFov, 1f, 160f);
                }
                else
                {
                    float newDir = CameraDir.z + 1f * CameraZoomSpeed;
                    newDir       = Mathf.Clamp(newDir, float.MinValue, 0f);
                    CameraDir    = new Vector3(0f, 0f, newDir);
                    reduceOffset = false;
                }
            }
            else if (gamepadState.DPad.Down == ButtonState.Pressed)
            {
                if (gamepadState.Buttons.LeftShoulder == ButtonState.Pressed)
                {
                    Guitime.fov = 1f;
                    float newFov = CameraFov + 1f * Time.deltaTime * 60f;
                    CameraFov = Mathf.Clamp(newFov, 1f, 160f);
                }
                else
                {
                    float newDir = CameraDir.z - 1f * CameraZoomSpeed;
                    newDir       = Mathf.Clamp(newDir, float.MinValue, 0f);
                    CameraDir    = new Vector3(0f, 0f, newDir);
                    reduceOffset = false;
                }
            }

            Vector2 leftStick  = new Vector2(gamepadState.ThumbSticks.Left.X, -gamepadState.ThumbSticks.Left.Y);
            Vector2 rightStick = new Vector2(gamepadState.ThumbSticks.Right.X, -gamepadState.ThumbSticks.Right.Y);

            if (controllerSwapSticks)
            {
                GamepadMovement(rightStick);
                GamepadCamera(leftStick);
            }
            else
            {
                GamepadMovement(leftStick);
                GamepadCamera(rightStick);
            }
        }
Beispiel #9
0
        PHIBL()
        {
            disableLightMap = ModPrefs.GetBool("PHIBL", "DisableLightMap", false, true);
            dollyZoom       = ModPrefs.GetBool("PHIBL", "DollyZoom", true, true);
            shortcut        = EnumUtils.ToEnum(ModPrefs.GetString("PHIBL", "Shortcut", "F5", true), KeyCode.F5);
            autoSetting     = ModPrefs.GetBool("PHIBL", "AutoSetting", false, true);
            asyncLoad       = ModPrefs.GetBool("PHIBL", "AsyncLoad", true, true);
            vSyncCount      = ModPrefs.GetInt("PHIBL", "VSync", 1, true);
            phong           = ModPrefs.GetFloat("PHIBL", "Tessellation.Phong", 0, true);
            edgelength      = ModPrefs.GetFloat("PHIBL", "Tessellation.EdgeLength", 30, true);
            nippleSSS       = ModPrefs.GetFloat("PHIBL", "NippleSSS", 0.5f, true);
            phong           = Mathf.Clamp01(phong);
            nippleSSS       = Mathf.Clamp01(nippleSSS);
            edgelength      = Mathf.Clamp(edgelength, 2f, 50f);
            deferredShading = DeferredShadingUtils.Instance;
            deferredShading.InitDeferredShading(Camera.main);
            SetTessellation(phong, edgelength);
            Shader.SetGlobalFloat(_AlphaSSS, nippleSSS);
            var cubemapbundle = AssetBundle.LoadFromFile(Application.dataPath + "/../plugins/PHIBL/procedural.cube");

            ProceduralSkybox.Proceduralsky = cubemapbundle.LoadAsset <Material>("Procedural Skybox");
            cubemapbundle.Unload(false);
            probeGameObject                    = new GameObject("RealtimeReflectionProbe");
            probeComponent                     = probeGameObject.AddComponent <ReflectionProbe>();
            probeComponent.mode                = ReflectionProbeMode.Realtime;
            probeComponent.boxProjection       = false;
            probeComponent.intensity           = 1f;
            probeComponent.importance          = 100;
            probeComponent.resolution          = 512;
            probeComponent.hdr                 = true;
            probeComponent.cullingMask         = 1 | ~Camera.main.cullingMask;
            probeComponent.clearFlags          = ReflectionProbeClearFlags.Skybox;
            probeComponent.size                = new Vector3(50, 20, 50);
            probeGameObject.transform.position = new Vector3(0, 1.6f, 0);
            probeComponent.refreshMode         = ReflectionProbeRefreshMode.ViaScripting;
            probeComponent.timeSlicingMode     = ReflectionProbeTimeSlicingMode.NoTimeSlicing;
            SceneFolder = new FolderAssist();
            SceneFolder.CreateFolderInfo(Application.dataPath + "/../Scenes/", "*.scene", true, true);
            SceneFileNames = new string[SceneFolder.GetFileCount()];
            SceneFileNames = SceneFolder.GetFilenames();

            CubemapFolder = new FolderAssist();
            CubemapFolder.CreateFolderInfo(Application.dataPath + "/../Cubemaps/", "*.cube", true, true);
            CubemapFolder.lstFile.Insert(0, new FolderAssist.FileInfo(Application.dataPath + "/../plugins/PHIBL/procedural.cube"));
            CubemapFileNames = CubemapFolder.GetFilenames();

            if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Studio")
            {
                StudioMode = true;
                Singleton <Studio.Info> .Instance.dicLightLoadInfo[0] = new Studio.Info.LightLoadInfo()
                {
                    no         = 0,
                    name       = "Directional Light",
                    manifest   = "studio00",
                    bundlePath = "lightsource",
                    fileName   = "Directional light",
                    target     = 0
                };
                Singleton <Studio.Info> .Instance.dicLightLoadInfo[1] = new Studio.Info.LightLoadInfo()
                {
                    no         = 1,
                    name       = "Point Light",
                    manifest   = "studio00",
                    bundlePath = "lightsource",
                    fileName   = "Point light",
                    target     = 0
                };
                Singleton <Studio.Info> .Instance.dicLightLoadInfo[2] = new Studio.Info.LightLoadInfo()
                {
                    no         = 2,
                    name       = "Spot Light",
                    manifest   = "studio00",
                    bundlePath = "lightsource",
                    fileName   = "Spot light",
                    target     = 0
                };
            }
            else
            {
                StudioMode = false;
            }
        }
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 ReadPrefs()
 {
     ShowNoteCounter = ModPrefs.GetBool("NotesLeftCounter", "showNoteCounter", true, true);
 }
 void LoadPrefs()   // more settings
 {
     gunname = ModPrefs.GetString(BuildInfo.Name, "gunname").ToLower();
     gunname = gunname == "any" ? "" : gunname;
 }
Beispiel #13
0
        //Initialize GUI style
        internal static void InitStyle()
        {
            scale.y = UnityEngine.Screen.height / Screen.height;
            scale.x = scale.y;
            scale.z = 1f;

            customscale = ModPrefs.GetFloat("BoneManager", "Window.customScale", 1f, true);
            customscale = Mathf.Clamp(customscale, 0.5f / scale.y, 2f);
            ModPrefs.SetFloat("BoneManager", "Window.customScale", customscale);
            screenBound = new Vector2(UnityEngine.Screen.width / scale.x / customscale, Screen.height / customscale);

            myfont      = Font.CreateDynamicFontFromOSFont(new string[] { "Segeo UI", "Microsoft YaHei UI", "Microsoft YaHei" }, 20);
            windowtitle = new GUIStyle(GUI.skin.label)
            {
                //border = new RectOffset(1,1,1,1),
                fontSize  = 24,
                padding   = new RectOffset(10, 10, 6, 12),
                fontStyle = FontStyle.Bold,
                alignment = TextAnchor.MiddleCenter,
                font      = myfont
            };
            toggleButtonOn = new GUIStyle(GUI.skin.button)
            {
                fontStyle     = FontStyle.Bold,
                stretchHeight = false,
                stretchWidth  = false,
                alignment     = TextAnchor.MiddleCenter,
                wordWrap      = false,
                font          = myfont,
                margin        = new RectOffset(4, 4, 4, 4),
                padding       = new RectOffset(6, 6, 6, 12),
                fontSize      = 22
            };
            toggleButtonOff = new GUIStyle(GUI.skin.button)
            {
                fontStyle     = FontStyle.Bold,
                stretchHeight = false,
                stretchWidth  = false,
                alignment     = TextAnchor.MiddleCenter,
                wordWrap      = false,
                font          = myfont,
                margin        = new RectOffset(4, 4, 4, 4),
                padding       = new RectOffset(6, 6, 6, 12),
                fontSize      = 22
            };
            toggleButtonOn.onNormal.textColor = selected;
            toggleButtonOn.onHover.textColor  = selectedOnHover;
            toggleButtonOn.normal             = toggleButtonOn.onNormal;
            toggleButtonOn.hover = toggleButtonOn.onHover;
            boxstyle             = new GUIStyle(GUI.skin.box)
            {
                stretchHeight = false,
                stretchWidth  = true,
                alignment     = TextAnchor.MiddleLeft,
                wordWrap      = true,
                font          = myfont,
                fontSize      = 22,
                padding       = new RectOffset(6, 6, 6, 12)
            };
            windowstyle = new GUIStyle(GUI.skin.window);
            selectstyle = new GUIStyle(GUI.skin.button)
            {
                fontStyle = FontStyle.Bold,
                alignment = TextAnchor.MiddleCenter,
                fontSize  = 22,
                padding   = new RectOffset(6, 6, 6, 12),
                margin    = new RectOffset(4, 4, 4, 4),
                font      = myfont
            };
            selectstyle.onNormal.textColor = selected;
            selectstyle.onHover.textColor  = selectedOnHover;
            buttonstyleNoStretch           = new GUIStyle(GUI.skin.button)
            {
                fontStyle     = FontStyle.Bold,
                stretchHeight = false,
                stretchWidth  = false,
                alignment     = TextAnchor.MiddleCenter,
                wordWrap      = false,
                font          = myfont,
                padding       = new RectOffset(6, 6, 6, 12),
                margin        = new RectOffset(4, 4, 4, 4),
                fontSize      = 22
            };

            sliderstyle = new GUIStyle(GUI.skin.horizontalSlider)
            {
                padding     = new RectOffset(-10, -10, -4, -4),
                fixedHeight = 16f,
                margin      = new RectOffset(22, 22, 22, 22)
            };
            thumbstyle = new GUIStyle(GUI.skin.horizontalSliderThumb)
            {
                fixedHeight = 24f,
                padding     = new RectOffset(14, 14, 12, 12)
            };
            labelstyle2 = new GUIStyle(GUI.skin.label)
            {
                font     = myfont,
                fontSize = 20,
                margin   = new RectOffset(16, 16, 8, 8)
            };
            titlestyle = new GUIStyle(GUI.skin.button)
            {
                fontStyle = FontStyle.Bold,
                font      = myfont,
                fontSize  = 30,
                padding   = new RectOffset(6, 6, 6, 12),
                margin    = new RectOffset(4, 4, 4, 4),
                alignment = TextAnchor.MiddleCenter
            };
            titlestyle.onNormal.textColor = selected;
            titlestyle.onHover.textColor  = selectedOnHover;
            titlestyle2 = new GUIStyle(GUI.skin.label)
            {
                fontStyle = FontStyle.Bold,
                font      = myfont,
                fontSize  = 30,
                padding   = new RectOffset(6, 6, 6, 12),
            };
            labelstyle = new GUIStyle(GUI.skin.label)
            {
                font      = myfont,
                fontSize  = 24,
                padding   = new RectOffset(6, 6, 6, 12),
                alignment = TextAnchor.MiddleLeft
            };
            buttonstyleStrechWidth = new GUIStyle(GUI.skin.button)
            {
                stretchHeight = false,
                stretchWidth  = true,
                wordWrap      = true,
                fontStyle     = FontStyle.Bold,
                font          = myfont,
                fontSize      = 22,
                margin        = new RectOffset(10, 10, 5, 5),
                padding       = new RectOffset(6, 6, 6, 12)
            };
            buttonstyleStrechWidth.onNormal.textColor = selected;
            buttonstyleStrechWidth.onHover.textColor  = selectedOnHover;
            labelstyle3 = new GUIStyle(GUI.skin.label)
            {
                wordWrap = true,
                fontSize = 22
            };

            space            = 12f;
            minwidth         = Mathf.Round(0.333f * Screen.width);
            styleInitialized = true;

            windowRect.x      = ModPrefs.GetFloat("BoneManager", "Window.x", windowRect.x, true);
            windowRect.y      = ModPrefs.GetFloat("BoneManager", "Window.y", windowRect.y, true);
            windowRect.width  = Mathf.Min(Screen.width - 10f, ModPrefs.GetFloat("BoneManager", "Window.width", windowRect.width, true));
            windowRect.height = Mathf.Min(Screen.height - 10f, ModPrefs.GetFloat("BoneManager", "Window.height", windowRect.height, true));
        }
Beispiel #14
0
        private IEnumerator Missed()
        {
            if (!startedDelete)
            {
                startedDelete = true;

                string mode = Plugin.effects[ModPrefs.GetInt("FCDisplay", "MissEffect", 1)];

                if (mode == "FlyOut")
                {
                    img.CrossFadeAlpha(0, 0.5f, false);
                    for (int i = 0; i < 20; i++)
                    {
                        g.transform.Translate(new Vector3(0, 0, 0.5f));
                        yield return(new WaitForSeconds(0.025f));
                    }
                }
                else if (mode == "Fade")
                {
                    img.CrossFadeAlpha(0, 0.5f, false);
                    yield return(new WaitForSeconds(0.5f));
                }
                else if (mode == "Shrink")
                {
                    img.CrossFadeAlpha(0, 0.4f, false);
                    for (int i = 0; i < 20; i++)
                    {
                        g2.transform.localScale = new Vector3(
                            g2.transform.localScale.x - 0.125f,
                            g2.transform.localScale.y - 0.125f,
                            g2.transform.localScale.z - 0.125f);
                        yield return(new WaitForSeconds(0.02f));
                    }
                }
                else if (mode == "Flicker")
                {
                    img.CrossFadeAlpha(0, 0.01f, false);
                    yield return(new WaitForSeconds(0.1f));

                    img.CrossFadeAlpha(1, 0.01f, false);
                    yield return(new WaitForSeconds(0.08f));

                    img.CrossFadeAlpha(0, 0.01f, false);
                    yield return(new WaitForSeconds(0.05f));

                    img.CrossFadeAlpha(1, 0.01f, false);
                    yield return(new WaitForSeconds(0.05f));

                    img.CrossFadeAlpha(0, 0.01f, false);
                    yield return(new WaitForSeconds(0.05f));

                    img.CrossFadeAlpha(1, 0.01f, false);
                    yield return(new WaitForSeconds(0.03f));

                    img.CrossFadeAlpha(0, 0.01f, false);
                    yield return(new WaitForSeconds(0.02f));

                    img.CrossFadeAlpha(1, 0.01f, false);
                    yield return(new WaitForSeconds(0.02f));

                    img.CrossFadeAlpha(0, 0.01f, false);
                }

                score.noteWasCutEvent    -= OnNoteCut;
                score.noteWasMissedEvent -= OnNoteMiss;

                Destroy(g);
                Destroy(this);
            }
        }
Beispiel #15
0
        private void MirrorHelperwindow(int id)
        {
            if (Event.current.type == EventType.MouseDown)
            {
                GUI.FocusWindow(windowID);
                windowdragflag = true;
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                windowdragflag = false;
            }

            GUILayout.BeginVertical();
            if (Mirror == null)
            {
                window = false;
                return;
            }
            texturesize = Mirror.m_TextureSize;
            int selected;

            if (texturesize <= 1024)
            {
                selected = 0;
            }
            else if (texturesize <= 2048)
            {
                selected = 1;
            }
            else
            {
                selected = 2;
            }
            GUILayout.Label("Mirror Resolution", UIUtils.labelstyle);
            GUILayout.Space(UIUtils.space);
            selected = GUILayout.SelectionGrid(selected, new string[] { "1024", "2048", "4096" }, 3, UIUtils.selectstyle);
            switch (selected)
            {
            default:
            case 0:
                texturesize = 1024;
                break;

            case 1:
                texturesize = 2048;
                break;

            case 2:
                texturesize = 4096;
                break;
            }
            Mirror.m_TextureSize     = texturesize;
            clipplaneoffset          = UIUtils.SliderGUI(clipplaneoffset, 0f, 1f, 0.01f, "Clip plane offset", "N3");
            Mirror.m_ClipPlaneOffset = clipplaneoffset;
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Close Window", UIUtils.buttonstyle))
            {
                window = false;
            }
            if (GUILayout.Button("Save", UIUtils.buttonstyle))
            {
                ModPrefs.SetInt("MirrorHelper", "Resolution", texturesize);
                ModPrefs.SetFloat("MirrorHelper", "ClipPlaneOffset", clipplaneoffset);
            }
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Beispiel #16
0
 private void CreateConfig()
 {
     ModPrefs.RegisterPrefBool("IntroSkip", "enabled", false);
 }
Beispiel #17
0
 private void LoadModPrefs() => allowPerformanceScanner = !ModPrefs.GetBool("NoPerformanceStats", "DisablePerformanceStats");
Beispiel #18
0
 private void LoadConfig()
 {
     introSkip = ModPrefs.GetBool("IntroSkip", "enabled");
     //MelonModLogger.Log("Loaded config!: " + "IntroSkip is " + (introSkip ? "enabled" : "disabled"));
 }
Beispiel #19
0
        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);
            }
        }
Beispiel #20
0
 private void SaveConfig()
 {
     ModPrefs.SetBool("IntroSkip", "enabled", introSkip);
     //MelonModLogger.Log("Config saved");
 }
        void ReadPreferences()
        {
            _overrideCustomSabers  = ModPrefs.GetBool(Name, "OverrideCustomSabers", true, true);
            allowEnvironmentColors = ModPrefs.GetBool(Plugin.Name, "allowEnvironmentColors", true, true);
            if (disablePlugin == false)
            {
                disablePlugin = ModPrefs.GetBool(Name, "disablePlugin", false, true);
                if (disablePlugin)
                {
                    queuedDisable = true;
                }
            }

            if (queuedDisable)
            {
                ColorLeft = new Color(
                    ModPrefs.GetInt(Name, "LeftRed", 255, true) / 255f,
                    ModPrefs.GetInt(Name, "LeftGreen", 4, true) / 255f,
                    ModPrefs.GetInt(Name, "LeftBlue", 4, true) / 255f
                    );
                ColorRight = new Color(
                    ModPrefs.GetInt(Name, "RightRed", 0, true) / 255f,
                    ModPrefs.GetInt(Name, "RightGreen", 192, true) / 255f,
                    ModPrefs.GetInt(Name, "RightBlue", 255, true) / 255f
                    );
                ColorLeftLight  = new Color(1, 4 / 255f, 4 / 255f);
                ColorRightLight = new Color(0, 192 / 255f, 1);
                wallColorPreset = 0;
            }

            if (disablePlugin == false)
            {
                userIncrement    = ModPrefs.GetInt(Name, "userIncrement", 10, true);
                leftColorPreset  = ModPrefs.GetInt(Name, "leftColorPreset", 0, true);
                rightColorPreset = ModPrefs.GetInt(Name, "rightColorPreset", 0, true);
                wallColorPreset  = ModPrefs.GetInt(Name, "wallColorPreset", 0, true);
                leftLightPreset  = ModPrefs.GetInt(Name, "leftLightPreset", 1, true);
                rightLightPreset = ModPrefs.GetInt(Name, "rightLightPreset", 2, true);

                brightness  = ModPrefs.GetFloat(Name, "Brightness", 1, true);
                rainbowWall = ModPrefs.GetBool(Name, "rainbowWalls", false, true);
                //Make sure preset exists, else default to user
                if (leftColorPreset > ColorsUI.ColorPresets.Count)
                {
                    leftColorPreset = 0;
                }
                if (rightColorPreset > ColorsUI.ColorPresets.Count)
                {
                    rightColorPreset = 0;
                }
                if (leftLightPreset > ColorsUI.OtherPresets.Count)
                {
                    leftLightPreset = 0;
                }
                if (rightLightPreset > ColorsUI.OtherPresets.Count)
                {
                    rightLightPreset = 0;
                }
                if (wallColorPreset > ColorsUI.OtherPresets.Count)
                {
                    wallColorPreset = 0;
                }

                //If preset is user get modprefs for colors, otherwise use preset
                if (leftColorPreset == 0)
                {
                    ColorLeft = new Color(
                        ModPrefs.GetInt(Name, "LeftRed", 255, true) / 255f,
                        ModPrefs.GetInt(Name, "LeftGreen", 4, true) / 255f,
                        ModPrefs.GetInt(Name, "LeftBlue", 4, true) / 255f
                        );
                }
                else
                {
                    ColorLeft = ColorsUI.ColorPresets[leftColorPreset].Item1;
                }

                if (rightColorPreset == 0)
                {
                    ColorRight = new Color(
                        ModPrefs.GetInt(Name, "RightRed", 0, true) / 255f,
                        ModPrefs.GetInt(Name, "RightGreen", 192, true) / 255f,
                        ModPrefs.GetInt(Name, "RightBlue", 255, true) / 255f
                        );
                }
                else
                {
                    ColorRight = ColorsUI.ColorPresets[rightColorPreset].Item1;
                }

                //Set Light colors
                switch (leftLightPreset)
                {
                case 0:
                    ColorLeftLight = new Color(1, 4 / 255f, 4 / 255f);
                    break;

                case 1:
                    ColorLeftLight = ColorLeft;
                    if (leftColorPreset != 1 && leftColorPreset != 2)
                    {
                        ColorLeftLight *= .8f;
                    }
                    break;

                case 2:
                    ColorLeftLight = ColorRight;
                    if (rightColorPreset != 1 && rightColorPreset != 2)
                    {
                        ColorLeftLight *= .8f;
                    }
                    break;

                case 3:
                    ColorLeftLight = new Color(
                        ModPrefs.GetInt(Name, "LeftRed", 255, true) / 255f,
                        ModPrefs.GetInt(Name, "LeftGreen", 4, true) / 255f,
                        ModPrefs.GetInt(Name, "LeftBlue", 4, true) / 255f
                        );
                    ColorLeftLight *= .8f;
                    break;

                case 4:
                    ColorLeftLight = new Color(
                        ModPrefs.GetInt(Name, "RightRed", 0, true) / 255f,
                        ModPrefs.GetInt(Name, "RightGreen", 192, true) / 255f,
                        ModPrefs.GetInt(Name, "RightBlue", 255, true) / 255f
                        );
                    ColorLeftLight *= .8f;
                    break;

                default:
                    ColorLeftLight  = ColorsUI.OtherPresets[leftLightPreset].Item1;
                    ColorLeftLight *= .8f;
                    break;
                }
                switch (rightLightPreset)
                {
                case 0:
                    ColorRightLight = new Color(0, 192 / 255f, 1);
                    break;

                case 1:
                    ColorRightLight = ColorLeft;
                    if (leftColorPreset != 1 && leftColorPreset != 2)
                    {
                        ColorRightLight *= .8f;
                    }
                    break;

                case 2:
                    ColorRightLight = ColorRight;
                    if (rightColorPreset != 1 && rightColorPreset != 2)
                    {
                        ColorRightLight *= .8f;
                    }
                    break;

                case 3:
                    ColorRightLight = new Color(
                        ModPrefs.GetInt(Name, "LeftRed", 255, true) / 255f,
                        ModPrefs.GetInt(Name, "LeftGreen", 4, true) / 255f,
                        ModPrefs.GetInt(Name, "LeftBlue", 4, true) / 255f
                        );
                    ColorRightLight *= .8f;
                    break;

                case 4:
                    ColorRightLight = new Color(
                        ModPrefs.GetInt(Name, "RightRed", 0, true) / 255f,
                        ModPrefs.GetInt(Name, "RightGreen", 192, true) / 255f,
                        ModPrefs.GetInt(Name, "RightBlue", 255, true) / 255f
                        );
                    ColorRightLight *= .8f;
                    break;

                default:
                    ColorRightLight  = ColorsUI.OtherPresets[rightLightPreset].Item1;
                    ColorRightLight *= .8f;
                    break;
                }
                ColorLeftLight  *= brightness;
                ColorRightLight *= brightness;
                GetWallColor();
            }
            CCSettingsChanged?.Invoke();
        }
        public static void CreateSettingsUI()
        {
            var subMenu = SettingsUI.CreateSubMenu("Progress Counter");

            //Time Left Bool
            {
                var timeLeft = subMenu.AddBool("Time Left");

                timeLeft.GetValue = () => Plugin.progressTimeLeft;

                timeLeft.SetValue = (bool value) =>
                {
                    Plugin.progressTimeLeft = value;
                    ModPrefs.SetBool("BeatSaberProgressCounter", "progressTimeLeft", Plugin.progressTimeLeft);
                };
            }


            //Decimal Precision
            {
                int[] precisionValues = { 1, 2, 3, 4 };
                var   precisionMenu   = subMenu.AddListSetting <DecimalSettingsViewController>("Decimal Precision");
                precisionMenu.values = precisionValues.ToList();

                precisionMenu.GetValue = () => Plugin.progressCounterDecimalPrecision;

                precisionMenu.SetValue = (int value) =>
                {
                    Plugin.progressCounterDecimalPrecision = (int)value;

                    ModPrefs.SetFloat("BeatSaberProgressCounter", "progressCounterDecimalPrecision", value);
                };

                precisionMenu.GetTextForValue = (int value) => value + " Place" + ((value == 1) ? "s" : "");
            }

            // Score Counter Position Preset
            {
                var scorePositions = new List <Tuple <Vector3, string> >
                {
                    { Plugin.scoreCounterPosition, "Current" },
                    { new Vector3(3.25f, 0.5f, 7.0f), "Default" },
                    { new Vector3(-3.25f, -0.3f, 7.0f), "Left" },
                };

                var scorePositionPresetMenu = subMenu.AddListSetting <PositionSettingsViewController>("Score Counter Position");
                scorePositionPresetMenu.values = scorePositions;

                scorePositionPresetMenu.GetValue        = () => scorePositions[0];
                scorePositionPresetMenu.GetTextForValue = (value) => value.Item2;
                scorePositionPresetMenu.SetValue        = (v) =>
                {
                    Plugin.scoreCounterPosition = v.Item1;
                    ModPrefs.SetString("BeatSaberProgressCounter", "scorePosition",
                                       FormattableString.Invariant(
                                           $"{Plugin.scoreCounterPosition.x:0.00},{Plugin.scoreCounterPosition.y:0.00},{Plugin.scoreCounterPosition.z:0.00}"));
                };
            }

            //Timer Position Preset
            {
                var timerPositions = new List <Tuple <Vector3, string> >
                {
                    { Plugin.progressCounterPosition, "Current" },
                    { new Vector3(.25f, -2.0f, 7.5f), "Default" },
                    { new Vector3(.25f, 3.4f, 7.5f), "Top" },
                    { new Vector3(-3.0f, 3.4f, 7f), "Top Left" },
                    { new Vector3(3.5f, 3.4f, 7f), "Top Right" },
                    { new Vector3(-3.0f, -1.75f, 7f), "Bottom Left" },
                    { new Vector3(3.5f, -1.6f, 7f), "Bottom Right" },
                };

                var timerPositionMenu = subMenu.AddListSetting <PositionSettingsViewController>("Timer Position");
                timerPositionMenu.values = timerPositions;

                timerPositionMenu.GetValue        = () => timerPositions[0];
                timerPositionMenu.GetTextForValue = (value) => value.Item2;
                timerPositionMenu.SetValue        = (v) =>
                {
                    Plugin.progressCounterPosition = v.Item1;
                    ModPrefs.SetString("BeatSaberProgressCounter", "progressPosition",
                                       FormattableString.Invariant(
                                           $"{Plugin.progressCounterPosition.x:0.00},{Plugin.progressCounterPosition.y:0.00},{Plugin.progressCounterPosition.z:0.00}"));
                };
            }
        }
        private static Tuple <IEnumerable <BSPluginMeta>, IEnumerable <IPlugin> > LoadPluginsFromFile(string file, string exeName)
        {
            List <BSPluginMeta> bsPlugins  = new List <BSPluginMeta>();
            List <IPlugin>      ipaPlugins = new List <IPlugin>();

            if (!File.Exists(file) || !file.EndsWith(".dll", true, null))
            {
                return(new Tuple <IEnumerable <BSPluginMeta>, IEnumerable <IPlugin> >(bsPlugins, ipaPlugins));
            }

            T OptionalGetPlugin <T>(Type t) where T : class
            {
                // use typeof() to allow for easier renaming (in an ideal world this compiles to a string, but ¯\_(ツ)_/¯)
                if (t.GetInterface(typeof(T).Name) != null)
                {
                    try
                    {
                        T        pluginInstance = Activator.CreateInstance(t) as T;
                        string[] filter         = null;

                        if (pluginInstance is IGenericEnhancedPlugin)
                        {
                            filter = ((IGenericEnhancedPlugin)pluginInstance).Filter;
                        }

                        if (filter == null || filter.Contains(exeName, StringComparer.OrdinalIgnoreCase))
                        {
                            return(pluginInstance);
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.log.Error($"Could not load plugin {t.FullName} in {Path.GetFileName(file)}! {e}");
                    }
                }

                return(null);
            }

            try
            {
                Assembly assembly = Assembly.LoadFrom(file);

                foreach (Type t in assembly.GetTypes())
                {
                    IBeatSaberPlugin bsPlugin = OptionalGetPlugin <IBeatSaberPlugin>(t);
                    if (bsPlugin != null)
                    {
                        try
                        {
                            var init = t.GetMethod("Init", BindingFlags.Instance | BindingFlags.Public);
                            if (init != null)
                            {
                                var initArgs   = new List <object>();
                                var initParams = init.GetParameters();

                                LoggerBase modLogger = null;
                                IModPrefs  modPrefs  = null;

                                foreach (var param in initParams)
                                {
                                    var ptype = param.ParameterType;
                                    if (ptype.IsAssignableFrom(typeof(LoggerBase)))
                                    {
                                        if (modLogger == null)
                                        {
                                            modLogger = new StandardLogger(bsPlugin.Name);
                                        }
                                        initArgs.Add(modLogger);
                                    }
                                    else if (ptype.IsAssignableFrom(typeof(IModPrefs)))
                                    {
                                        if (modPrefs == null)
                                        {
                                            modPrefs = new ModPrefs(bsPlugin);
                                        }
                                        initArgs.Add(modPrefs);
                                    }
                                    else
                                    {
                                        initArgs.Add(ptype.GetDefault());
                                    }
                                }

                                init.Invoke(bsPlugin, initArgs.ToArray());
                            }

                            bsPlugins.Add(new BSPluginMeta
                            {
                                Plugin       = bsPlugin,
                                Filename     = file.Replace("\\.cache", ""), // quick and dirty fix
                                ModsaberInfo = bsPlugin.ModInfo
                            });
                        }
                        catch (AmbiguousMatchException)
                        {
                            Logger.log.Error($"Only one Init allowed per plugin");
                        }
                    }
                    else
                    {
                        IPlugin ipaPlugin = OptionalGetPlugin <IPlugin>(t);
                        if (ipaPlugin != null)
                        {
                            ipaPlugins.Add(ipaPlugin);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.log.Error($"Could not load {Path.GetFileName(file)}! {e}");
            }

            return(new Tuple <IEnumerable <BSPluginMeta>, IEnumerable <IPlugin> >(bsPlugins, ipaPlugins));
        }
        private void reloadIni()
        {
            // Create the UserData folder if it doesn't exist
            System.IO.Directory.CreateDirectory(Path.Combine(System.Environment.CurrentDirectory, "UserData"));

            const string invalidPresetKey = "";
            const float  invalidPresetVal = -1000f;
            const int    maxPresets       = 100;

            _worldScaleStep     = ModPrefs.GetFloat("ShortcutPluginVars", "WorldScaleStepSize", 0.01f, true);
            _worldScaleMin      = ModPrefs.GetFloat("ShortcutPluginVars", "WorldScaleMin", 0.01f, true);
            _worldScaleMax      = ModPrefs.GetFloat("ShortcutPluginVars", "WorldScaleMax", 10.0f, true);
            _timeScaleStep      = ModPrefs.GetFloat("ShortcutPluginVars", "TimeScaleStepSize", 0.01f, true);
            _timeScaleMin       = ModPrefs.GetFloat("ShortcutPluginVars", "TimeScaleMin", 0.1f, true);
            _timeScaleMax       = ModPrefs.GetFloat("ShortcutPluginVars", "TimeScaleMax", 1.0f, true);
            _animationSpeedStep = ModPrefs.GetFloat("ShortcutPluginVars", "AnimationSpeedStepSize", 0.05f, true);
            _animationSpeedMin  = ModPrefs.GetFloat("ShortcutPluginVars", "AnimationSpeedMin", -1.0f, true);
            _animationSpeedMax  = ModPrefs.GetFloat("ShortcutPluginVars", "AnimationSpeedMax", 5.0f, true);
            _shiftMultiplier    = ModPrefs.GetFloat("ShortcutPluginVars", "ShiftKeyMultiplier", 5.0f, true);

            _swapTimeAndAnim = false;

            // Put some sample presets in the INI
            ModPrefs.GetFloat("ShortcutPluginVars", "TimeScalePreset0", 1.0f, true);
            ModPrefs.GetFloat("ShortcutPluginVars", "TimeScalePreset1", 0.5f, true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetTimeScalePreset0", ";", true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetTimeScalePreset1", "'", true);

            ModPrefs.GetFloat("ShortcutPluginVars", "WorldScalePreset0", 1.0f, true);
            ModPrefs.GetFloat("ShortcutPluginVars", "WorldScalePreset1", 1.15f, true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetWorldScalePreset0", "[", true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetWorldScalePreset1", "]", true);

            ModPrefs.GetFloat("ShortcutPluginVars", "WorldScalePreset0", 1.0f, true);
            ModPrefs.GetFloat("ShortcutPluginVars", "WorldScalePreset1", 1.15f, true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetWorldScalePreset0", "[", true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetWorldScalePreset1", "]", true);

            ModPrefs.GetFloat("ShortcutPluginVars", "AnimationSpeedPreset0", 1.0f, true);
            ModPrefs.GetFloat("ShortcutPluginVars", "AnimationSpeedPreset1", 0.0f, true);
            ModPrefs.GetFloat("ShortcutPluginVars", "AnimationSpeedPreset2", -1.0f, true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetAnimationSpeedPreset0", "0", true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetAnimationSpeedPreset1", "9", true);
            ModPrefs.GetString("ShortcutPluginKeys", "SetAnimationSpeedPreset2", "8", true);

            _shortcuts = new Dictionary <string, ActionFunction>()
            {
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "MoveSelToCam", "\\", true).ToLower(),
                    () => MoveSelectedAtomToCamera()
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "IncWorldScale", "p", true).ToLower(),
                    () => ChangeWorldScale(_worldScaleStep)
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "DecWorldScale", "o", true).ToLower(),
                    () => ChangeWorldScale(-_worldScaleStep)
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "IncTimeScale", "l", true).ToLower(),
                    () => {
                        if (_swapTimeAndAnim)
                        {
                            ChangeAnimationSpeed(_animationSpeedStep);
                        }
                        else
                        {
                            ChangeTimeScale(_timeScaleStep);
                        }
                    }
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "DecTimeScale", "k", true).ToLower(),
                    () => {
                        if (_swapTimeAndAnim)
                        {
                            ChangeAnimationSpeed(-_animationSpeedStep);
                        }
                        else
                        {
                            ChangeTimeScale(-_timeScaleStep);
                        }
                    }
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "TogglePause", "j", true).ToLower(),
                    () => TogglePause()
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "IncAnimationSpeed", "7", true).ToLower(),
                    () => {
                        if (_swapTimeAndAnim)
                        {
                            ChangeTimeScale(_timeScaleStep);
                        }
                        else
                        {
                            ChangeAnimationSpeed(_animationSpeedStep);
                        }
                    }
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "DecAnimationSpeed", "6", true).ToLower(),
                    () => {
                        if (_swapTimeAndAnim)
                        {
                            ChangeTimeScale(-_timeScaleStep);
                        }
                        else
                        {
                            ChangeAnimationSpeed(-_animationSpeedStep);
                        }
                    }
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "SwapTimeAndAnim", "5", true).ToLower(),
                    () =>
                    {
                        _swapTimeAndAnim = !_swapTimeAndAnim;
                    }
                },
                {
                    ModPrefs.GetString("ShortcutPluginKeys", "ReloadIni", "q", true).ToLower(),
                    () => reloadIni()
                },
            };

            // Add presets
            for (int i = 0; i < maxPresets; ++i)
            {
                var  tsPresetKey = ModPrefs.GetString("ShortcutPluginKeys", "SetTimeScalePreset" + i.ToString(), invalidPresetKey, false).ToLower();
                var  tsPresetVal = ModPrefs.GetFloat("ShortcutPluginVars", "TimeScalePreset" + i.ToString(), invalidPresetVal, false);
                bool tsSet       = tsPresetKey != invalidPresetKey && tsPresetVal != invalidPresetVal;

                var  asPresetKey = ModPrefs.GetString("ShortcutPluginKeys", "SetAnimationSpeedPreset" + i.ToString(), invalidPresetKey, false).ToLower();
                var  asPresetVal = ModPrefs.GetFloat("ShortcutPluginVars", "AnimationSpeedPreset" + i.ToString(), invalidPresetVal, false);
                bool asSet       = asPresetKey != invalidPresetKey && asPresetVal != invalidPresetVal;

                var wsPresetKey = ModPrefs.GetString("ShortcutPluginKeys", "SetWorldScalePreset" + i.ToString(), invalidPresetKey, false).ToLower();
                var wsPresetVal = ModPrefs.GetFloat("ShortcutPluginVars", "WorldScalePreset" + i.ToString(), invalidPresetVal, false);


                if (tsSet && !asSet)
                {
                    _shortcuts.Add(tsPresetKey, () => SetTimeScale(tsPresetVal));
                }
                if (asSet && !tsSet)
                {
                    _shortcuts.Add(asPresetKey, () => SetAnimationSpeed(asPresetVal));
                }
                if (tsSet && asSet)
                {
                    _shortcuts.Add(asPresetKey, () => {
                        if (_swapTimeAndAnim)
                        {
                            SetTimeScale(tsPresetVal);
                        }
                        else
                        {
                            SetAnimationSpeed(asPresetVal);
                        }
                    });

                    _shortcuts.Add(tsPresetKey, () => {
                        if (_swapTimeAndAnim)
                        {
                            SetAnimationSpeed(asPresetVal);
                        }
                        else
                        {
                            SetTimeScale(tsPresetVal);
                        }
                    });
                }
                if (wsPresetKey != invalidPresetKey && wsPresetVal != invalidPresetVal)
                {
                    _shortcuts.Add(wsPresetKey, () => SetWorldScale(wsPresetVal));
                }
            }
        }
Beispiel #25
0
 public virtual void HandleNoEnergyToggleDidSwitch(HMUI.Toggle toggle, bool isOn)
 {
     this.Value = isOn;
     ModPrefs.SetBool(Plugin.PluginName, _prefKey, isOn);
     OnToggle?.Invoke(isOn);
 }
        public static void CreateUI()
        {
            GetIcons();
            string disableScoreString = "<size=120%><color=#ff0000ff><b><u>Disables Score Submission</u> </b></color></size> \r\n<size=100%> ";

            var gmp1Menu = GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.ModifiersRight, "GamePlayModifiersPlus", "MainMenu", "GMP1", "GameplayModifiersPlus Options", _GMPIcon);

            //GMP1 Options
            //      var backOption = GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.ModifiersRight, "Back", "GMP1", "MainMenu", "Return from GamePlayModifiersOptions", _BackButton);

            var twitchStuffOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Chat Integration", "GMP1", disableScoreString + "Allows Chat to mess with your game if connected. !gm help", _TwitchIcon);

            twitchStuffOption.GetValue  = chatIntegration;
            twitchStuffOption.OnToggle += (value) => { chatIntegration = value; Plugin.Log("Changed value"); };

            var chatDeltaOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Chat Delta", "GMP1", "Display Change in Performance Points / Rank in Twitch Chat if Connected", _ChatDeltaIcon);

            chatDeltaOption.GetValue  = ModPrefs.GetBool("GameplayModifiersPlus", "chatDelta", false, true);
            chatDeltaOption.OnToggle += (chatDelta) => { ModPrefs.SetBool("GameplayModifiersPlus", "chatDelta", chatDelta); Plugin.Log("Changed value"); };

            //GMP2 Options
            var gmp2Menu = GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.ModifiersRight, "Additional Modifiers", "GMP1", "GMP2", "Additional Modifiers", _GMPIcon);
            //      var backOption2 = GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.ModifiersRight, "Back", "GMP2", "GMP1", "Return from Additional Modifiers", _BackButton);

            var repeatOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Repeat", "GMP2", disableScoreString + "Restarts song on song end", _RepeatIcon);

            repeatOption.GetValue  = repeatSong;
            repeatOption.OnToggle += (value) => { repeatSong = value; Plugin.Log("Changed value"); };

            var gnomeOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Gnome on miss", "GMP2", "Probably try not to miss.", _GnomeIcon);

            gnomeOption.GetValue  = gnomeOnMiss;
            gnomeOption.OnToggle += (value) => { gnomeOnMiss = value; Plugin.Log("Changed value"); };
            gnomeOption.AddConflict("Chat Integration");
            gnomeOption.AddConflict("Faster Song");
            gnomeOption.AddConflict("Slower Song");


            var bulletTimeOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Bullet Time", "GMP2", disableScoreString + "Slow down time by pressing the triggers on your controllers.", _BulletTimeIcon);

            bulletTimeOption.GetValue  = bulletTime;
            bulletTimeOption.OnToggle += (value) => { bulletTime = value; Plugin.Log("Changed value"); };
            bulletTimeOption.AddConflict("Faster Song");
            bulletTimeOption.AddConflict("Slower Song");
            bulletTimeOption.AddConflict("Chat Integration");


            var noteSizeOption = GameplaySettingsUI.CreateListOption(GameplaySettingsPanels.ModifiersRight, "Note Size", "GMP2", disableScoreString + "Change the size of the notes. Overwritten by Chat Integration and any other size changing options");

            for (float i = 10; i <= 200; i += 10)
            {
                noteSizeOption.AddOption(i / 100);
            }
            noteSizeOption.GetValue = (() =>
            {
                float num = fixedNoteScale;
                if (num % 0.1f != 0)
                {
                    num = (float)Math.Round(num, 1);
                }

                num = Mathf.Clamp(num, 0.1f, 2f);
                return(num);
            });
            noteSizeOption.OnChange += (value) => { fixedNoteScale = value;  Plugin.Log("Changed Value"); };

            var swapSabersOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Testing Ground", "GMP2", disableScoreString + "Currently Used To test Random stuff", _SwapSabersIcon);

            swapSabersOption.GetValue  = swapSabers;
            swapSabersOption.OnToggle += (value) => { swapSabers = value; Plugin.Log("Changed value"); };
            swapSabersOption.AddConflict("Chat Integration");

            var njsRandomOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Random NJS", "GMP2", disableScoreString + "Randomizes Note Jump Speed", _RandomIcon);

            njsRandomOption.GetValue  = njsRandom;
            njsRandomOption.OnToggle += (value) => { njsRandom = value; Plugin.Log("Changed value"); };
            njsRandomOption.AddConflict("Chat Integration");

            var randomSizeOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Random Note Size", "GMP2", disableScoreString + "Randomizes Note Size", _RandomIcon);

            randomSizeOption.GetValue  = njsRandom;
            randomSizeOption.OnToggle += (value) => { randomSize = value; Plugin.Log("Changed value"); };
            randomSizeOption.AddConflict("Chat Integration");

            var rainbowOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Rainbow", "GMP2", disableScoreString + "Rainbow Notes", _RainbowIcon);

            rainbowOption.GetValue  = rainbow;
            rainbowOption.OnToggle += (value) => { rainbow = value; Plugin.Log("Changed value"); };
            rainbowOption.AddConflict("Chat Integration");

            var funkyOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "Funky", "GMP2", disableScoreString + "Funky Notes", _FunkyIcon);

            funkyOption.GetValue  = funky;
            funkyOption.OnToggle += (value) => { funky = value; Plugin.Log("Changed value"); };
            funkyOption.AddConflict("Chat Integration");

            var noArrowsOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "No Arrows", "GMP2", disableScoreString + "No arrows but without the color randomization", _NoArrowsIcon);

            noArrowsOption.GetValue  = noArrows;
            noArrowsOption.OnToggle += (value) => { noArrows = value; Plugin.Log("Changed value"); };
            noArrowsOption.AddConflict("Chat Integration");
        }
Beispiel #27
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 #28
0
        public static IEnumerator PopulateSettingsPanel(RectTransform settingsContentRoot)
        {
            yield return(null);

            yield return(null);

            yield return(null);

            var categoryPrefab = ourStuffBundle.SettingsCategory;
            var boolPrefab     = ourStuffBundle.SettingsBool;
            var textPrefab     = ourStuffBundle.SettingsText;

            settingsContentRoot.DestroyChildren();

            var pinnedSettings = ExpansionKitSettings.ListPinnedPrefs(false).ToList();

            foreach (var keyValuePair in ModPrefs.GetPrefs())
            {
                var categoryId = keyValuePair.Key;
                var prefDict   = keyValuePair.Value;

                if (ExpansionKitApi.CustomCategoryUIs.TryGetValue(categoryId, out var specificPrefab))
                {
                    Object.Instantiate(specificPrefab, settingsContentRoot, false);
                    continue;
                }

                var prefsToPopulate = prefDict.Where(it => !it.Value.Hidden).ToList();

                if (prefsToPopulate.Count == 0)
                {
                    continue;
                }

                var categoryUi = Object.Instantiate(categoryPrefab, settingsContentRoot, false);
                categoryUi.GetComponentInChildren <Text>().text = ModPrefs.GetCategoryDisplayName(categoryId);
                var categoryUiContent = categoryUi.transform.Find("CategoryEntries");

                foreach (var valuePair in prefsToPopulate)
                {
                    var prefId   = valuePair.Key;
                    var prefDesc = valuePair.Value;

                    switch (prefDesc.Type)
                    {
                    case ModPrefs.PrefType.STRING:
                    {
                        var textSetting = Object.Instantiate(textPrefab, categoryUiContent, false);
                        textSetting.GetComponentInChildren <Text>().text = prefDesc.DisplayText ?? prefId;
                        var textField = textSetting.GetComponentInChildren <InputField>();
                        textField.text = ModPrefs.GetString(categoryId, prefId);
                        textField.onValueChanged.AddListener(new Action <string>(value =>
                            {
                                prefDesc.ValueEdited = value;
                            }));
                        textSetting.GetComponentInChildren <Button>().onClick.AddListener(new Action(() =>
                            {
                                BuiltinUiUtils.ShowInputPopup(prefDesc.DisplayText ?? prefId, textField.text,
                                                              InputField.InputType.Standard, false, "Done",
                                                              (result, _, __) => prefDesc.ValueEdited = textField.text = result);
                            }));
                        break;
                    }

                    case ModPrefs.PrefType.BOOL:
                        var boolSetting = Object.Instantiate(boolPrefab, categoryUiContent, false);
                        boolSetting.GetComponentInChildren <Text>().text = prefDesc.DisplayText ?? prefId;
                        var mainToggle = boolSetting.transform.Find("Toggle").GetComponent <Toggle>();
                        mainToggle.isOn = ModPrefs.GetBool(categoryId, prefId);
                        mainToggle.onValueChanged.AddListener(new Action <bool>(
                                                                  isSet =>
                        {
                            prefDesc.ValueEdited = isSet.ToString().ToLowerInvariant();
                        }));
                        var pinToggle = boolSetting.transform.Find("PinToggle").GetComponent <Toggle>();
                        pinToggle.isOn = pinnedSettings.Contains((categoryId, prefId));
                        pinToggle.onValueChanged.AddListener(new Action <bool>(isSet =>
                        {
                            if (isSet)
                            {
                                ExpansionKitSettings.PinPref(categoryId, prefId);
                            }
                            else
                            {
                                ExpansionKitSettings.UnpinPref(categoryId, prefId);
                            }
                        }));
                        break;

                    case ModPrefs.PrefType.INT:
                    case ModPrefs.PrefType.FLOAT:
                    {
                        var textSetting = Object.Instantiate(textPrefab, categoryUiContent, false);
                        textSetting.GetComponentInChildren <Text>().text = prefDesc.DisplayText ?? prefId;
                        var textField = textSetting.GetComponentInChildren <InputField>();
                        textField.text        = ModPrefs.GetString(categoryId, prefId);
                        textField.contentType = prefDesc.Type == ModPrefs.PrefType.INT
                                ? InputField.ContentType.IntegerNumber
                                : InputField.ContentType.DecimalNumber;
                        textField.onValueChanged.AddListener(new Action <string>(value =>
                            {
                                prefDesc.ValueEdited = value;
                            }));
                        textSetting.GetComponentInChildren <Button>().onClick.AddListener(new Action(() =>
                            {
                                BuiltinUiUtils.ShowInputPopup(prefDesc.DisplayText ?? prefId, textField.text,
                                                              InputField.InputType.Standard, prefDesc.Type == ModPrefs.PrefType.INT, "Done",
                                                              (result, _, __) => prefDesc.ValueEdited = textField.text = result);
                            }));
                        break;
                    }

                    default:
                        MelonModLogger.LogError($"Unknown mod pref type {prefDesc.Type}");
                        break;
                    }
                }
            }
        }
Beispiel #29
0
 public static void SaveConfig()
 {
     ModPrefs.SetBool("BeatSaverCustomExit", "EnablePlugin", EnablePlugin);
     ModPrefs.SetString("BeatSaverCustomExit", "TextContent", TextContent);
 }
Beispiel #30
0
 public void OnApplicationStart()
 {
     ModPrefs.SetString("BodySliders", "Unity3D_KeyCodes", "https://docs.unity3d.com/ScriptReference/KeyCode.html");
     ModPrefs.GetString("BodySliders", "enable|disable", "KeypadPeriod", true);
 }