////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Prefix
        /// </summary>
        /// <param name="__instance">PlayerSettingsPanelController instance</param>
        internal static void Prefix(ref PlayerSettingsPanelController __instance,
                                    ref Toggle ____leftHandedToggle,
                                    ref Toggle ____staticLightsToggle,
                                    ref Toggle ____reduceDebrisToggle,
                                    ref Toggle ____noTextsAndHudsToggle,
                                    ref Toggle ____advanceHudToggle,
                                    ref PlayerHeightSettingsController ____playerHeightSettingsController,
                                    ref Toggle ____automaticPlayerHeightToggle,
                                    ref FormattedFloatListSettingsController ____sfxVolumeSettingsController,
                                    ref FormattedFloatListSettingsController ____saberTrailIntensitySettingsController,
                                    ref NoteJumpStartBeatOffsetDropdown ____noteJumpStartBeatOffsetDropdown,
                                    ref Toggle ____hideNoteSpawnEffectToggle,
                                    ref Toggle ____adaptiveSfxToggle)
        {
            m_LeftHandedToggle                      = ____leftHandedToggle;
            m_StaticLightsToggle                    = ____staticLightsToggle;
            m_ReduceDebrisToggle                    = ____reduceDebrisToggle;
            m_NoTextsAndHudsToggle                  = ____noTextsAndHudsToggle;
            m_AdvanceHudToggle                      = ____advanceHudToggle;
            m_PlayerHeightSettingsController        = ____playerHeightSettingsController;
            m_AutomaticPlayerHeightToggle           = ____automaticPlayerHeightToggle;
            m_SfxVolumeSettingsController           = ____sfxVolumeSettingsController;
            m_SaberTrailIntensitySettingsController = ____saberTrailIntensitySettingsController;
            m_NoteJumpStartBeatOffsetDropdown       = ____noteJumpStartBeatOffsetDropdown;
            m_HideNoteSpawnEffectToggle             = ____hideNoteSpawnEffectToggle;
            m_AdaptiveSfxToggle                     = ____adaptiveSfxToggle;

            /// Apply
            if (Config.GameTweaker.Enabled)
            {
                SetReorderEnabled(Config.GameTweaker.ReorderPlayerSettings, Config.GameTweaker.AddOverrideLightIntensityOption);
            }
        }
        internal static void Prefix(CreateServerFormController __instance, ref FormattedFloatListSettingsController ____maxPlayersList)
        {
            int maxPlayers = MPState.CurrentMasterServer.isOfficial ? 5 : Plugin.Config.MaxPlayers;

            float[] playerValues = Enumerable.Range(2, maxPlayers - 1).Select(x => (float)x).ToArray();
            ____maxPlayersList.values = playerValues;
        }
Ejemplo n.º 3
0
        private void AddMultiSelectOption(string optionName, Dictionary <float, string> options, Transform parent, GameObject destinationObject, Action <float> onSet = null, Vector2?position = null)
        {
            if (position == null)
            {
                position = Vector2.zero;
            }

            destinationObject.SetActive(false);

            FormattedFloatListSettingsController formattedFloatListSettingsController = Resources.FindObjectsOfTypeAll <FormattedFloatListSettingsController>().FirstOrDefault <FormattedFloatListSettingsController>();
            var multiSelectGameObject = Instantiate(formattedFloatListSettingsController.gameObject, parent);

            multiSelectGameObject.name = optionName;
            multiSelectGameObject.GetComponentInChildren <TMP_Text>().text = optionName;
            var oldListSettingsController = multiSelectGameObject.GetComponent <ListSettingsController>();
            var newListViewController     = (ListViewController)ReflectionUtil.CopyComponent(oldListSettingsController, typeof(ListSettingsController), typeof(ListViewController), multiSelectGameObject);

            DestroyImmediate(oldListSettingsController);

            newListViewController.applyImmediately = true;
            newListViewController.values           = options.Keys.ToList();
            newListViewController.SetValue         = onSet;
            newListViewController.GetValue         = () => options.Keys.ElementAt(0);
            newListViewController.GetTextForValue  = (float v) =>
            {
                if (!options.ContainsKey(v))
                {
                    return("UNKNOWN");
                }
                if (options[v] == null)
                {
                    return(v.ToString());
                }
                return(options[v]);
            };

            Polyglot.LocalizedTextMeshProUGUI localizer = newListViewController.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>();
            if (localizer != null)
            {
                Destroy(localizer);
            }

            var valueTextTransform = newListViewController.gameObject.transform.Find("Value");
            var valueTextComponent = valueTextTransform.Find("ValueText").GetComponent <TMP_Text>();

            valueTextComponent.lineSpacing = -50f;
            valueTextComponent.alignment   = TextAlignmentOptions.CenterGeoAligned;

            var nameTextTransform = newListViewController.gameObject.transform.Find("NameText");

            nameTextTransform.localScale     = new Vector3(0.85f, 0.85f, 0.85f);
            nameTextTransform.localPosition += new Vector3(2f, 5f);
            (nameTextTransform as RectTransform).sizeDelta = new Vector2(47f, 8f);
            valueTextTransform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
            valueTextTransform.Find("DecButton").transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
            valueTextTransform.Find("IncButton").transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
            newListViewController.transform.localPosition             = (Vector2)position;
            newListViewController.Init();

            destinationObject.SetActive(true);
        }