static void Postfix(ref GameOptionsMenu __instance)
            {
                var lowestY = GetLowestConfigY(__instance);

                var countOption = UnityEngine.Object.Instantiate(__instance.GetComponentsInChildren <NumberOption>()[1],
                                                                 __instance.transform);

                countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x, lowestY - 0.5f,
                                                                  countOption.transform.localPosition.z);
                countOption.Title = maxPlayerAdminTitle;
                countOption.Value = maxPlayerAdmin;
                var str = "";

                TranslationController_GetString.Prefix(countOption.Title, ref str);
                countOption.TitleText.Text = str;
                countOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                countOption.gameObject.AddComponent <OptionBehaviour>();
                countOption.ValidRange.max = 10;
                countOption.ValidRange.min = 3;

                countOption = UnityEngine.Object.Instantiate(__instance.GetComponentsInChildren <NumberOption>()[1],
                                                             __instance.transform);
                countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x, lowestY - 1.0f,
                                                                  countOption.transform.localPosition.z);
                countOption.Title = maxPlayerCamsTitle;
                countOption.Value = maxPlayerCams;
                str = "";
                TranslationController_GetString.Prefix(countOption.Title, ref str);
                countOption.TitleText.Text = str;
                countOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                countOption.gameObject.AddComponent <OptionBehaviour>();
                countOption.ValidRange.max = 10;
                countOption.ValidRange.min = 3;

                countOption = UnityEngine.Object.Instantiate(__instance.GetComponentsInChildren <NumberOption>()[1],
                                                             __instance.transform);
                countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x, lowestY - 1.5f,
                                                                  countOption.transform.localPosition.z);
                countOption.Title = maxPlayerVitalsTitle;
                countOption.Value = maxPlayerVitals;
                str = "";
                TranslationController_GetString.Prefix(countOption.Title, ref str);
                countOption.TitleText.Text = str;
                countOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                countOption.gameObject.AddComponent <OptionBehaviour>();
                countOption.ValidRange.max = 10;
                countOption.ValidRange.min = 3;

                __instance.GetComponentInParent <Scroller>().YBounds.max += 0.6f;
            }
Exemple #2
0
        private static void GameOptionsMenuStart(GameOptionsMenu __instance)
        {
            List <OptionBehaviour> customOptions = GetGameOptions(__instance.GetComponentsInChildren <OptionBehaviour>().Min(option => option.transform.localPosition.y));

            OptionBehaviour[] defaultOptions = __instance.Children;

            defaultGameOptionsCount = defaultOptions.Length;

            __instance.Children = defaultOptions.Concat(customOptions).ToArray();
        }
            public static void Postfix(GameOptionsMenu __instance)
            {
                var customOptions = GetGameOptions(__instance
                                                   .GetComponentsInChildren <OptionBehaviour>().Min(option => option.transform.localPosition.y));
                var defaultOptions = __instance.Children;

                var options = defaultOptions.Concat(customOptions).ToArray();

                __instance.Children = new Il2CppReferenceArray <OptionBehaviour>(options);
            }
Exemple #4
0
            static void Postfix(ref GameOptionsMenu __instance)
            {
                var thisPos  = -8.35f;
                var killCool = __instance.GetComponentsInChildren <NumberOption>()[1];

                foreach (NumberOption num in __instance.GetComponentsInChildren <NumberOption>())
                {
                    if (num.name == "KillCooldown")
                    {
                        killCool = num;
                    }
                }

                foreach (CustomNumberOption custom in numOpts)
                {
                    var countOption = UnityEngine.Object.Instantiate(killCool, __instance.transform);
                    countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x, thisPos, countOption.transform.localPosition.z);
                    countOption.Title = custom.numOptionTitle;
                    countOption.Value = custom.value;
                    var str = "";
                    customTranslationController.Prefix(countOption.Title, ref str);
                    countOption.TitleText.text = str;
                    countOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                    countOption.gameObject.AddComponent <OptionBehaviour>();
                    __instance.GetComponentInParent <Scroller>().YBounds.max += 0.3f;
                    thisPos -= 0.50f;
                }

                foreach (CustomBoolOption custom in boolOpts)
                {
                    var toggleOption = UnityEngine.Object.Instantiate(__instance.GetComponentsInChildren <ToggleOption>()[1], __instance.transform);
                    toggleOption.transform.localPosition = new Vector3(toggleOption.transform.localPosition.x, thisPos, toggleOption.transform.localPosition.z);
                    toggleOption.Title             = custom.boolOptionTitle;
                    toggleOption.CheckMark.enabled = custom.value;
                    var str2 = "";
                    customTranslationController.Prefix(toggleOption.Title, ref str2);
                    toggleOption.TitleText.text = str2;
                    toggleOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                    toggleOption.gameObject.AddComponent <OptionBehaviour>();
                    __instance.GetComponentInParent <Scroller>().YBounds.max += 0.3f;
                    thisPos -= 0.50f;
                }
            }
        public override void Start(GameOptionsMenu __instance, float lowestY, float offset,
                                   Action <OptionBehaviour> callback)
        {
            var toggleOption = UnityEngine.Object.Instantiate(
                __instance.GetComponentsInChildren <ToggleOption>()[1],
                __instance.transform);

            toggleOption.transform.localPosition = new Vector3(toggleOption.transform.localPosition.x,
                                                               lowestY - offset, toggleOption.transform.localPosition.z);
            toggleOption.Title             = optionTitleName;
            toggleOption.CheckMark.enabled = value;
            toggleOption.TitleText.Text    = optionTitle;
            toggleOption.OnValueChanged    = new Action <OptionBehaviour>(callback);
            toggleOption.gameObject.AddComponent <OptionBehaviour>();
        }
            public static void Postfix(GameOptionsMenu __instance)
            {
                List <OptionBehaviour> customOptions = GetGameOptions(__instance.GetComponentsInChildren <OptionBehaviour>().Min(option => option.transform.localPosition.y));
                Il2CppReferenceArray <OptionBehaviour> defaultOptions = __instance.Children;

                OptionBehaviour[] options = defaultOptions.Concat(customOptions).ToArray();

                //EssentialsPlugin.Logger.LogInfo($"__instance.Children.Count {__instance.Children.Count}");

                __instance.Children = new Il2CppReferenceArray <OptionBehaviour>(options);

                //__instance.GetComponentInParent<Scroller>().YBounds.max = options.Length * /*0.3455F*/0.4F;
                //__instance.GetComponentInParent<Scroller>().YBounds.max = -0.5F + options.Length * 0.4F;

                //EssentialsPlugin.Logger.LogInfo($"__instance.Children.Count2 {__instance.Children.Count}");
            }
Exemple #7
0
            public static void Postfix(GameOptionsMenu __instance)
            {
                var customOptions = CreateOptions(__instance);
                var y             = __instance.GetComponentsInChildren <OptionBehaviour>()
                                    .Max(option => option.transform.localPosition.y);
                var x = __instance.Children[1].transform.localPosition.x;
                var z = __instance.Children[1].transform.localPosition.z;
                var i = 0;

                foreach (var option in customOptions)
                {
                    option.transform.localPosition = new Vector3(x, y - i++ *0.5f, z);
                }

                __instance.Children = new Il2CppReferenceArray <OptionBehaviour>(customOptions.ToArray());
            }
        public override void Start(GameOptionsMenu __instance, float lowestY, float offset,
                                   Action <OptionBehaviour> callback)
        {
            var countOption = UnityEngine.Object.Instantiate(
                __instance.GetComponentsInChildren <NumberOption>()[1],
                __instance.transform);

            countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x,
                                                              lowestY - offset,
                                                              countOption.transform.localPosition.z);
            countOption.Title          = optionTitleName;
            countOption.Value          = value;
            countOption.TitleText.Text = optionTitle;
            countOption.OnValueChanged = new Action <OptionBehaviour>(callback);
            countOption.gameObject.AddComponent <OptionBehaviour>();
            countOption.ValidRange.max = max;
            countOption.ValidRange.min = min;
            countOption.Increment      = step;
            countOption.FormatString   = format;
        }
            public static void Postfix(ref GameOptionsMenu __instance)
            {
                float        lowestY      = __instance.GetComponentsInChildren <OptionBehaviour>().Min(o => o.transform.position.y) - 0.2f;
                ToggleOption togglePrefab = __instance.Children.Where(o => o.TryCast <ToggleOption>() != null).First(o => o.Title != StringNames.GameRecommendedSettings).Cast <ToggleOption>(); // GameRecommendedSettings has a specific design
                NumberOption numberPrefab = __instance.GetComponentInChildren <NumberOption>();
                StringOption stringPrefab = __instance.GetComponentInChildren <StringOption>();
                byte         optionsAdded = 0;

                foreach (var baseOption in
                         OptionsManager.LimitOptions.Values
                         .Concat(OptionsManager.CustomOptions.SelectMany(p => p.Value))
                         )
                {
                    var option = Object.Instantiate <OptionBehaviour>(
                        baseOption switch
                    {
                        CustomToggleOption => togglePrefab,
                        CustomNumberOption => numberPrefab,
                        CustomStringOption => stringPrefab,
                        _ => throw new InvalidCastException($"{nameof(baseOption)} was unknown type")
                    },
Exemple #10
0
            public static void Postfix(GameOptionsMenu __instance)
            {
                var y = __instance.GetComponentsInChildren <OptionBehaviour>()
                        .Max(option => option.transform.localPosition.y);
                float x, z;

                if (__instance.Children.Length == 1)
                {
                    x = __instance.Children[0].transform.localPosition.x;
                    z = __instance.Children[0].transform.localPosition.z;
                }
                else
                {
                    x = __instance.Children[1].transform.localPosition.x;
                    z = __instance.Children[1].transform.localPosition.z;
                }

                var i = 0;

                foreach (var option in __instance.Children)
                {
                    option.transform.localPosition = new Vector3(x, y - i++ *0.5f, z);
                }
            }
 static float GetLowestConfigY(GameOptionsMenu __instance)
 {
     return(__instance.GetComponentsInChildren <OptionBehaviour>()
            .Min(option => option.transform.localPosition.y));
 }
Exemple #12
0
 static void Postfix(ref GameOptionsMenu __instance)
 {
     __instance.GetComponentsInChildren <NumberOption>()
     .First(o => o.Title == StringNames.GameNumImpostors)
     .ValidRange = new FloatRange(1, (int)(CreateGameOptionsPatches.CreateOptionsPicker_Start.maxPlayers - 0.5f) / 2);
 }