Ejemplo n.º 1
0
        private IEnumerator ChangeClipSetting()
        {
            float nearclip = -1;
            float farclip  = -1;

            BuiltinUiUtils.ShowInputPopup("Near Clipping point", "0.01", InputField.InputType.Standard, false, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                if (!float.TryParse(s, out nearclip) || nearclip < 0)
                {
                    nearclip = 0.01f;
                }
            }, null, "Near Clipping Point", true, null);
            while (nearclip == -1)
            {
                yield return(new WaitForEndOfFrame());
            }
            BuiltinUiUtils.ShowInputPopup("Far Clipping point", "2500", InputField.InputType.Standard, false, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                if (!float.TryParse(s, out farclip) || farclip < 0)
                {
                    nearclip = 2500f;
                }
            }, null, "Near Clipping Point", true, null);
            while (farclip == -1)
            {
                yield return(new WaitForEndOfFrame());
            }
            settings.NearClip = nearclip;
            settings.FarClip  = farclip;
            writeConfig();
            MelonCoroutines.Start(CamClipping());
        }
Ejemplo n.º 2
0
 protected override void SearchButtonClicked()
 {
     BuiltinUiUtils.ShowInputPopup("Local Search (Avatar)", "", InputField.InputType.Standard, false,
                                   "Search!", (s, list, arg3) =>
     {
         SetSearchListHeaderAndScrollToIt("Search running...");
         LastSearchRequest = s;
         FavCatMod.Database.RunBackgroundAvatarSearch(s, AcceptSearchResult);
     });
 }
Ejemplo n.º 3
0
        private IEnumerator removeCam()
        {
            string name  = "";
            int    index = -1;
            bool   flag  = false;

            BuiltinUiUtils.ShowInputPopup("Delete Resolution:", "", InputField.InputType.Standard, false, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                if (!int.TryParse(s, out index))
                {
                    name = s;
                    flag = true;
                }
                else
                {
                    index -= 1;
                }
            }, null, "Name or Index (starting at 1)", true, null);
            while (name.Equals("") & index == -1)
            {
                yield return(new WaitForEndOfFrame());
            }
            if (flag)
            {
                for (int i = 0; i < settings.Resolutions.Count; i++)
                {
                    if (name.ToLower().Equals(settings.Resolutions[i].Name.ToLower()))
                    {
                        settings.Resolutions.RemoveAt(i);
                    }
                }
            }
            else
            {
                try
                {
                    settings.Resolutions.RemoveAt(index);
                }
                catch { }
            }
            writeConfig();
            loadCamMenu();

            yield break;
        }
Ejemplo n.º 4
0
        private IEnumerator addCam()
        {
            string name   = "";
            int    height = -2;
            int    width  = -2;

            BuiltinUiUtils.ShowInputPopup("Enter Resolution Name:", "", InputField.InputType.Standard, false, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                name = s;
            }, null, "Name...", true, null);
            while (name.Equals(""))
            {
                yield return(new WaitForEndOfFrame());
            }

            BuiltinUiUtils.ShowInputPopup("Enter Resolution Height:", "", InputField.InputType.Standard, true, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                if (!int.TryParse(s, out height) || height < 1)
                {
                    height = 1080;
                }
            }, null, "Height...", true, null);
            while (height == -2)
            {
                yield return(new WaitForEndOfFrame());
            }

            BuiltinUiUtils.ShowInputPopup("Enter Resolution Width:", "-1", InputField.InputType.Standard, true, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                if (!int.TryParse(s, out width) || width < 1)
                {
                    width = -1;
                }
            }, null, "Width...", true, null);
            while (width == -2)
            {
                yield return(new WaitForEndOfFrame());
            }

            settings.Resolutions.Add(new Resolution(name, height, width));
            writeConfig();
            loadCamMenu();

            yield break;
        }
Ejemplo n.º 5
0
        private IEnumerator ChangeDefaultRes()
        {
            int defaultRes = -1;

            BuiltinUiUtils.ShowInputPopup("Default Mode:", "1", InputField.InputType.Standard, true, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                if (!int.TryParse(s, out defaultRes) || !(defaultRes > 0 && defaultRes < settings.Resolutions.Count))
                {
                    defaultRes = 1;
                }
            }, null, "Default mode (starts at 1)", true, null);
            while (defaultRes == -1)
            {
                yield return(new WaitForEndOfFrame());
            }

            settings.DefaultRes = defaultRes;
            writeConfig();
            SetResolution(settings.Resolutions[settings.DefaultRes - 1].ImageHeight, settings.Resolutions[settings.DefaultRes - 1].ImageWidth);

            yield break;
        }
Ejemplo n.º 6
0
        private IEnumerator ChangeDefaultAspectRatio()
        {
            float AspectWidth  = -1;
            float AspectHeight = -1;

            BuiltinUiUtils.ShowInputPopup("Aspect Ration Width:", "16", InputField.InputType.Standard, true, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                if (!float.TryParse(s, out AspectWidth) || AspectWidth < 0)
                {
                    AspectWidth = 16;
                }
            }, null, "", true, null);
            while (AspectWidth == -1)
            {
                yield return(new WaitForEndOfFrame());
            }

            BuiltinUiUtils.ShowInputPopup("Aspect Ration Height:", "9", InputField.InputType.Standard, true, "Okay", delegate(string s, Il2CppSystem.Collections.Generic.List <KeyCode> k, Text t)
            {
                if (!float.TryParse(s, out AspectHeight) || AspectHeight < 0)
                {
                    AspectHeight = 9;
                }
            }, null, "", true, null);
            while (AspectHeight == -1)
            {
                yield return(new WaitForEndOfFrame());
            }

            settings.Width  = AspectWidth;
            settings.Height = AspectHeight;
            aspectRatio     = AspectWidth / AspectHeight;
            writeConfig();

            yield break;
        }
Ejemplo n.º 7
0
        public static void OpenSavePresetMenu(int presetNumber)
        {
            var    savePresetMenu = ExpansionKitApi.CreateCustomFullMenuPopup(LayoutDescription.WideSlimList);
            string defaultText    = Helpers.GetPresetName(presetNumber);

            savePresetMenu.AddSimpleButton("Save this preset", () => { savePresetMenu.Hide(); BuiltinUiUtils.ShowInputPopup("Enter a preset name", defaultText, InputField.InputType.Standard, false, "Save", (x, kc, txt) => Helpers.SaveSafetySettings(presetNumber, x)); });
            savePresetMenu.Show();
        }
Ejemplo n.º 8
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;
                    }
                }
            }
        }