Esempio n. 1
0
        public static void CreateSettingsButton(OptionsMenu optionsMenu)
        {
            string toggleText = "OFF";

            if (config.activated)
            {
                toggleText = "ON";
            }

            optionsMenu.AddHeader(0, "Trippy Menu");

            toggleButton = optionsMenu.AddButton
                               (0,
                               toggleText,
                               new Action(() =>
            {
                if (config.activated)
                {
                    config.activated        = false;
                    playPsychadelia         = false;
                    toggleButton.label.text = "OFF";
                    SaveConfig();
                    GameplayModifiers.I.mPsychedeliaPhase = 0.00000001f;
                    timer = 0;
                }
                else
                {
                    config.activated        = true;
                    playPsychadelia         = true;
                    toggleButton.label.text = "ON";
                    SaveConfig();
                }
            }),
                               null,
                               "Turns Trippy Menu on or off");

            speedSlider = optionsMenu.AddSlider
                          (
                0,
                "Trippy Menu Cycle Speed",
                "P",
                new Action <float>((float n) =>
            {
                config.speed = Mathf.Round((config.speed + n) * 1000.0f) / 1000.0f;
                UpdateSlider(speedSlider, "Speed : " + config.speed.ToString());
            }),
                null,
                null,
                "Changes color cycle speed"
                          );
            speedSlider.label.text = "Speed : " + config.speed.ToString();

            //MelonModLogger.Log("Buttons created");
            menuSpawned = true;
        }
Esempio n. 2
0
    private static void CreateCategoryPage(MelonPreferences_Category category)
    {
        WipeScroller();
        displayState = DisplayState.Prefs;
        var categoryHeader = modMenuOM.AddHeader(0, category.DisplayName);

        modMenuOM.scrollable.AddRow(categoryHeader);

        int buttonIndex = 0;

        Il2CppGeneric.List <GameObject> row = new Il2CppGeneric.List <GameObject>();
        foreach (var pref in category.Entries)
        {
            switch (pref.BoxedValue)
            {
            case int value:
                MinMaxStepDefaultInt rangesInt = ParseMinMaxStepInt(pref.DisplayName);
                if (rangesInt.Equals(default(MinMaxStepDefaultInt)))
                {
                    break;
                }
                var intSlider = modMenuOM.AddSlider(buttonIndex % 2,
                                                    AddWhitespace(pref.Identifier),
                                                    null,
                                                    new Action <float>((amount) =>
                {
                    int currentVal = MelonPreferences.GetEntryValue <int>(pref.Category.Identifier, pref.Identifier);
                    int increment  = (int)amount * rangesInt.step;
                    int newVal     = currentVal + increment;
                    if (newVal > rangesInt.max)
                    {
                        MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, rangesInt.max);
                    }
                    else if (newVal < rangesInt.min)
                    {
                        MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, rangesInt.min);
                    }
                    else
                    {
                        MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, newVal);
                    }
                }),
                                                    new Func <float>(() => { return(MelonPreferences.GetEntryValue <int>(pref.Category.Identifier, pref.Identifier)); }),
                                                    new Action(() => { MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, rangesInt.prefDefault); }),
                                                    RemoveTags(pref.DisplayName),
                                                    new Func <float, string>((amount) => { return(amount.ToString()); }));
                buttonIndex++;
                row.Add(intSlider.gameObject);
                break;

            case bool value:
                var checkbox = modMenuOM.AddButton(buttonIndex % 2,
                                                   AddWhitespace(pref.Identifier),
                                                   new Action(() =>
                {
                    bool currentVal = MelonPreferences.GetEntryValue <bool>(pref.Category.Identifier, pref.Identifier);
                    MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, !currentVal);
                }),
                                                   new Func <bool>(() => { return(MelonPreferences.GetEntryValue <bool>(pref.Category.Identifier, pref.Identifier)); }),
                                                   pref.DisplayName);

                row.Add(checkbox.gameObject);
                buttonIndex++;
                break;

            case float value:
                MinMaxStepDefault rangesFloat = ParseMinMaxStep(pref.DisplayName);
                if (rangesFloat.Equals(default(MinMaxStepDefault)))
                {
                    break;
                }
                var customSpecifier = GetFormatSpecifier(pref.DisplayName);
                if (customSpecifier == "")
                {
                    customSpecifier = "N2";                            //Default to N2 if specifier is missing
                }
                var floatSlider = modMenuOM.AddSlider(buttonIndex % 2,
                                                      AddWhitespace(pref.Identifier),
                                                      "N2",
                                                      new Action <float>((amount) =>
                {
                    float currentVal = MelonPreferences.GetEntryValue <float>(pref.Category.Identifier, pref.Identifier);
                    float increment  = rangesFloat.step * amount;        //(amount * Mathf.Floor(currentVal * 10f));
                    float newVal     = currentVal + increment;
                    if (newVal > rangesFloat.max)
                    {
                        MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, rangesFloat.max);
                    }
                    else if (newVal < rangesFloat.min)
                    {
                        MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, rangesFloat.min);
                    }
                    else
                    {
                        MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, currentVal + increment);
                    }
                }),
                                                      new Func <float>(() => { return(MelonPreferences.GetEntryValue <float>(pref.Category.Identifier, pref.Identifier)); }),
                                                      new Action(() => { MelonPreferences.SetEntryValue(pref.Category.Identifier, pref.Identifier, rangesFloat.prefDefault); }),
                                                      RemoveTags(pref.DisplayName),
                                                      new Func <float, string>((amount) => { return(amount.ToString(customSpecifier)); }));
                row.Add(floatSlider.gameObject);
                buttonIndex++;
                break;

            case string value:
                if (pref.DisplayName.ToLower().Contains("[header]"))
                {
                    if (row.Count == 1)
                    {
                        modMenuOM.scrollable.AddRow(row[0]);
                        row.Clear();
                    }
                    var header = modMenuOM.AddHeader(0, RemoveTags(pref.DisplayName));
                    modMenuOM.scrollable.AddRow(header);
                    buttonIndex = 0;
                }
                break;

            default:
                break;
            }
            if (row.Count == 2)
            {
                //This is the dumbest code I've ever wrote.
                Il2CppGeneric.List <GameObject> tempRow = new Il2CppGeneric.List <GameObject>();
                tempRow.Add(row[0]);
                tempRow.Add(row[1]);
                modMenuOM.scrollable.AddRow(tempRow);
                row.Clear();
            }
            else if (buttonIndex == category.Entries.Count && buttonIndex % 2 == 1) // This might be obsolete
            {
                modMenuOM.scrollable.AddRow(row[0]);
                row.Clear();
            }
        }
    }
Esempio n. 3
0
        private static void AddButtons(OptionsMenu optionsMenu)
        {
            optionsMenu.AddHeader(0, "Skybox controls");

            var RotationSlider = optionsMenu.AddSlider(0, "Skybox Rotation", "P",
                                                       new Action <float>(x => { ArenaLoaderMod.RotateSkybox(x * 5); }),
                                                       null);

            RotationSlider.label.text = "Rotation";

            var ExposureSlider = optionsMenu.AddSlider(1, "Skybox Exposure", "P",
                                                       new Action <float>(x => { ArenaLoaderMod.ChangeExposure(x * 0.05f); }),
                                                       null);

            ExposureSlider.label.text = "Brightness";

            var ReflectionSlider = optionsMenu.AddSlider(0, "Skybox Reflection", "P",
                                                         new Action <float>(x => { ArenaLoaderMod.ChangeReflectionStrength(x * 0.05f); }),
                                                         null);

            ReflectionSlider.label.text = "Reflection";

            optionsMenu.AddTextBlock(0, "These settings will reset when you enter a new arena. A way to save current arena settings will be added in a future update");

            optionsMenu.AddHeader(0, "Custom skybox");
            OptionsMenuSlider skyboxSlider = optionsMenu.AddSlider(0, "Custom Skybox", null, new Action <float>((amount) => { ArenaLoaderMod.skyboxLoader.Index += (int)amount; }), new Func <float>(() => { return((float)ArenaLoaderMod.skyboxLoader.Index); }), new Action(() => { ArenaLoaderMod.skyboxLoader.Index = 0; }), "Skybox to load", new Func <float, string>((amount) =>
            {
                if (ArenaLoaderMod.skyboxLoader.skyboxes.Count == 0)
                {
                    return("Skybox folder is empty");
                }
                Material currentSkybox = ArenaLoaderMod.skyboxLoader.skyboxes[ArenaLoaderMod.skyboxLoader.Index];
                if (currentSkybox != null)
                {
                    return(currentSkybox.name);
                }
                else
                {
                    return("Skybox folder is empty");
                }
            }), optionsMenu.sliderCustomModelPrefab);

            skyboxSlider.transform.Find("reload").gameObject.SetActive(false);             // Disables the reload icon.

            optionsMenu.AddButton(0, "Apply skybox", new Action(() =>
            {
                if (ArenaLoaderMod.skyboxLoader.skyboxes.Count == 0)
                {
                    return;
                }
                var newSkybox = ArenaLoaderMod.skyboxLoader.skyboxes[ArenaLoaderMod.skyboxLoader.Index];
                if (newSkybox != null)
                {
                    ArenaLoaderMod.UpdateSkybox(newSkybox);
                }
            }), null, "Apply the currently selected skybox");

            optionsMenu.AddButton(0, "Reload skybox folder", new Action(() =>
            {
                ArenaLoaderMod.skyboxLoader.LoadSkyboxes();
            }), null, "Deletes the currently loaded skyboxes and reloads the folder.\n<color=red>Only use this for working on skyboxes</color>");
            optionsMenu.AddTextBlock(0, "Create your own custom skyboxes from images in Audica\\Mods\\Arenas\\Skyboxes\nTo reset a custom skybox, load a different arena.");
        }
Esempio n. 4
0
        public static void AddOptionsButtons(OptionsMenu optionsMenu)
        {
            void UpdateSlider(OptionsMenuSlider slider, string text)
            {
                if (slider == null)
                {
                    return;
                }
                else
                {
                    slider.label.text = text;
                    SaveConfig();
                }
            }

            OptionsMenuSlider MakeSlider(string label, OptionsMenuSlider.AdjustActionDelegate action, string helpText)
            {
                OptionsMenuSlider slider = optionsMenu.AddSlider
                                           (
                    0,
                    label,
                    "P",
                    action,
                    null,
                    null,
                    helpText
                                           );

                return(slider);
            }

            string positionSmoothingLabel = "Position Smoothing";

            OptionsMenuSlider.AdjustActionDelegate positionSmoothingAction = new Action <float>((float n) =>
            {
                positionSmoothing = Mathf.Round((positionSmoothing + (n * 0.001f)) * 1000.0f) / 1000.0f;
                UpdateSlider(positionSmoothingSlider, positionSmoothingLabel + " : " + positionSmoothing.ToString());
            });
            positionSmoothingSlider            = MakeSlider(positionSmoothingLabel, positionSmoothingAction, "Changes how smooth positioning will be");
            positionSmoothingSlider.label.text = positionSmoothingLabel + " : " + positionSmoothing.ToString();

            string rotationSmoothingLabel = "Rotation Smoothing";

            OptionsMenuSlider.AdjustActionDelegate rotationSmoothingAction = new Action <float>((float n) =>
            {
                rotationSmoothing = Mathf.Round((rotationSmoothing + (n * 0.001f)) * 1000.0f) / 1000.0f;
                UpdateSlider(rotationSmoothingSlider, rotationSmoothingLabel + " : " + rotationSmoothing.ToString());
            });
            rotationSmoothingSlider            = MakeSlider(rotationSmoothingLabel, rotationSmoothingAction, "Changes how smooth rotation will be");
            rotationSmoothingSlider.label.text = rotationSmoothingLabel + " : " + rotationSmoothing.ToString();

            string camOffsetLabel = "Horizontal Offset";

            OptionsMenuSlider.AdjustActionDelegate camOffsetAction = new Action <float>((float n) =>
            {
                camOffset = Mathf.Round((camOffset + (n * 0.1f)) * 10.0f) / 10.0f;
                UpdateSlider(camOffsetSlider, camOffsetLabel + " : " + camOffset.ToString());
            });
            camOffsetSlider            = MakeSlider(camOffsetLabel, camOffsetAction, "Changes horizontal position");
            camOffsetSlider.label.text = camOffsetLabel + " : " + camOffset.ToString();

            string camHeightLabel = "Vertical Offset";

            OptionsMenuSlider.AdjustActionDelegate camHeightAction = new Action <float>((float n) =>
            {
                camHeight = Mathf.Round((camHeight + (n * 0.1f)) * 10.0f) / 10.0f;
                UpdateSlider(camHeightSlider, camHeightLabel + " : " + camHeight.ToString());
            });
            camHeightSlider            = MakeSlider(camHeightLabel, camHeightAction, "Changes vertical position");
            camHeightSlider.label.text = camHeightLabel + " : " + camHeight.ToString();

            string camDistanceLabel = "Distance";

            OptionsMenuSlider.AdjustActionDelegate camDistanceAction = new Action <float>((float n) =>
            {
                camDistance = Mathf.Round((camDistance + (n * 0.1f)) * 10.0f) / 10.0f;
                UpdateSlider(camDistanceSlider, camDistanceLabel + " : " + camDistance.ToString());
            });
            camDistanceSlider            = MakeSlider(camDistanceLabel, camDistanceAction, "Changes the distance");
            camDistanceSlider.label.text = camDistanceLabel + " : " + camDistance.ToString();

            string camRotationLabel = "Rotation";

            OptionsMenuSlider.AdjustActionDelegate camRotationAction = new Action <float>((float n) =>
            {
                camRotation = Mathf.Round((camRotation + (n * 0.1f)) * 10.0f) / 10.0f;
                UpdateSlider(camRotationSlider, camRotationLabel + " : " + camRotation.ToString());
            });
            camRotationSlider            = MakeSlider(camRotationLabel, camRotationAction, "Changes the rotation");
            camRotationSlider.label.text = camRotationLabel + " : " + camRotation.ToString();

            optionsMenu.scrollable.AddRow(optionsMenu.AddHeader(0, "Follow Camera <size=5>Must be set to 3rd person static</size>"));

            optionsMenu.scrollable.AddRow(positionSmoothingSlider.gameObject);
            optionsMenu.scrollable.AddRow(rotationSmoothingSlider.gameObject);
            optionsMenu.scrollable.AddRow(camOffsetSlider.gameObject);
            optionsMenu.scrollable.AddRow(camHeightSlider.gameObject);
            optionsMenu.scrollable.AddRow(camDistanceSlider.gameObject);
            optionsMenu.scrollable.AddRow(camRotationSlider.gameObject);

            if (activated)
            {
                spectatorCam.previewCam.gameObject.SetActive(true);
                spectatorCam.previewCamDisplay.SetActive(true);
            }
        }
Esempio n. 5
0
        public static void ShowPage(OptionsMenu optionsMenu, OptionsMenu.Page page)
        {
            if (page == OptionsMenu.Page.SpectatorCam && !menuCreated)
            {
                /*string toggleText = "OFF";
                 *
                 * if (config.activated)
                 * {
                 *  toggleText = "ON";
                 * }
                 *
                 * toggleButton = optionsMenu.AddButton
                 *  (0,
                 *  toggleText,
                 *  new Action(() => {
                 *      if (config.activated)
                 *      {
                 *          config.activated = false;
                 *          toggleButton.label.text = "OFF";
                 *          SaveConfig();
                 *      }
                 *      else
                 *      {
                 *          config.activated = true;
                 *          toggleButton.label.text = "ON";
                 *          SaveConfig();
                 *      }
                 *  }),
                 *  null,
                 *  "Turns the follow camera on or off");
                 */

                positionSmoothingSlider = optionsMenu.AddSlider
                                          (
                    0,
                    "Position Speed",
                    "P",
                    new Action <float>((float n) => {
                    config.positionSmoothing = Mathf.Round((config.positionSmoothing + (n * 0.001f)) * 1000.0f) / 1000.0f;
                    UpdateSlider(positionSmoothingSlider, "Position Smoothing : " + config.positionSmoothing.ToString());
                }),
                    null,
                    null,
                    "Changes how smooth position will be"
                                          );
                positionSmoothingSlider.label.text = "Position Smoothing : " + config.positionSmoothing.ToString();

                rotationSmoothingSlider = optionsMenu.AddSlider
                                          (
                    0,
                    "Rotation Speed",
                    "P",
                    new Action <float>((float n) => {
                    config.rotationSmoothing = Mathf.Round((config.rotationSmoothing + (n * 0.001f)) * 1000.0f) / 1000.0f;
                    UpdateSlider(rotationSmoothingSlider, "Rotation Smoothing : " + config.rotationSmoothing.ToString());
                }),
                    null,
                    null,
                    "Changes how smooth rotation will be"
                                          );
                rotationSmoothingSlider.label.text = "Rotation Smoothing : " + config.rotationSmoothing.ToString();

                camOffsetSlider = optionsMenu.AddSlider
                                  (
                    0,
                    "Horizontal Offset",
                    "P",
                    new Action <float>((float n) => {
                    config.camOffset = Mathf.Round((config.camOffset + (n * 0.1f)) * 10.0f) / 10.0f;
                    UpdateSlider(camOffsetSlider, "Horizontal Offset : " + config.camOffset.ToString());
                }),
                    null,
                    null,
                    "Changes horizontal position"
                                  );
                camOffsetSlider.label.text = "Horizontal Offset : " + config.camOffset.ToString();

                camHeightSlider = optionsMenu.AddSlider
                                  (
                    0,
                    "Vertical Offset",
                    "P",
                    new Action <float>((float n) => {
                    config.camHeight = Mathf.Round((config.camHeight + (n * 0.1f)) * 10.0f) / 10.0f;
                    UpdateSlider(camHeightSlider, "Vertical Offset : " + config.camHeight.ToString());
                }),
                    null,
                    null,
                    "Changes vertical position"
                                  );
                camHeightSlider.label.text = "Vertical Offset : " + config.camHeight.ToString();

                camDistanceSlider = optionsMenu.AddSlider
                                    (
                    0,
                    "Distance",
                    "P",
                    new Action <float>((float n) => {
                    config.camDistance = Mathf.Round((config.camDistance + (n * 0.1f)) * 10.0f) / 10.0f;
                    UpdateSlider(camDistanceSlider, "Distance : " + config.camDistance.ToString());
                }),
                    null,
                    null,
                    "Changes the distance"
                                    );
                camDistanceSlider.label.text = "Distance : " + config.camDistance.ToString();

                camRotationSlider = optionsMenu.AddSlider
                                    (
                    0,
                    "Tilt",
                    "P",
                    new Action <float>((float n) => {
                    config.camRotation = Mathf.Round((config.camRotation + (n * 0.1f)) * 10.0f) / 10.0f;
                    UpdateSlider(camRotationSlider, "Rotation : " + config.camRotation.ToString());
                }),
                    null,
                    null,
                    "Changes the rotation"
                                    );
                camRotationSlider.label.text = "Rotation : " + config.camRotation.ToString();

                optionsMenu.scrollable.AddRow(optionsMenu.AddHeader(0, "Follow Camera <size=5>Must be set to 3rd person static</size>"));

                //optionsMenu.scrollable.AddRow(toggleButton.gameObject);
                optionsMenu.scrollable.AddRow(positionSmoothingSlider.gameObject);
                optionsMenu.scrollable.AddRow(rotationSmoothingSlider.gameObject);
                optionsMenu.scrollable.AddRow(camOffsetSlider.gameObject);
                optionsMenu.scrollable.AddRow(camHeightSlider.gameObject);
                optionsMenu.scrollable.AddRow(camDistanceSlider.gameObject);
                optionsMenu.scrollable.AddRow(camRotationSlider.gameObject);

                if (config.activated)
                {
                    spectatorCam.previewCam.gameObject.SetActive(true);
                    spectatorCam.previewCamDisplay.SetActive(true);
                }

                menuCreated = true;
            }
            else
            {
                menuCreated = false;
            }
        }