/// <summary> /// Create a ListViewController outside of the settings menu. /// NOTE: CustomUI.Settings.SubMenu:AddHooks() can make a call to ApplySettings. /// </summary> /// <param name="name">The text to be displayed for this setting.</param> /// <param name="values">A list of values representing an option in this setting.</param> /// <param name="hintText">The text to be displayed when this settings is hovered over.</param> /// <returns>A new ListViewController.</returns> public static ListViewController CreateListViewController(string name, float[] values, string hintText = "") { ListViewController viewController = _submenu.AddList(name, values, hintText); // remove this view controller from the global list of CustomSettings, otherwise it'll try to call Init() when we don't need it to SubMenu.needsInit.Remove(viewController); return(viewController); }
public static void InitUI() { SubMenu menu = SettingsUI.CreateSubMenu("Beat Saber Console"); var lines = menu.AddInt("Line Count", "How many lines the Console will display.", 15, 50, 5); lines.GetValue += delegate { return(Config.lines); }; lines.SetValue += v => Config.lines = v; float[] timeOptions = new float[] { 0.1f, 0.25f, 0.5f, 0.75f, 1, 1.5f, 2, 3, 4, 5 }; var time = menu.AddList("Console Update Time", timeOptions, "The amount of time between Console updates in seconds."); time.GetValue += delegate { return(Config.updateTime); }; time.SetValue += v => Config.updateTime = v; time.FormatValue += delegate(float c) { return($"{c} Sec."); }; var cubes = menu.AddBool("Show Move Bars", "Show the bars that appear under the console.\n<color=#FF0000>Moving the console and output log by clicking under them will still work.</color>"); cubes.GetValue += delegate { return(Config.showMoveCubes); }; cubes.SetValue += v => Config.showMoveCubes = v; var clipboard = menu.AddBool("Copy Last Exception", "Automatically copies the Console's last logged Exception to your clipboard for easy pasting.\n<color=#FF0000>This will overwrite any previous clipboard entries.</color>"); clipboard.GetValue += delegate { return(Config.copyToClipboard); }; clipboard.SetValue += v => Config.copyToClipboard = v; var common = menu.AddBool("Hide Common Errors", "Hide common errors from appearing in the Output Log."); common.GetValue += delegate { return(Config.hideCommonErrors); }; common.SetValue += v => Config.hideCommonErrors = v; var showStacktrace = menu.AddBool("Show Stacktrace", "Shows stacktrace in Output Log."); showStacktrace.GetValue += delegate { return(Config.showStacktrace); }; showStacktrace.SetValue += v => Config.showStacktrace = v; var reset = menu.AddBool("Reset Positions?", "When set to true, the Console and Output log will reset to above the player."); reset.GetValue += delegate { return(false); }; reset.SetValue += v => { if (v) { Config.consolePos = new Vector3(1, 2.5f, 0); Config.consoleRot = new Vector3(-90, 0, 0); Config.outputPos = new Vector3(0, 2.5f, 0); Config.outputRot = new Vector3(-90, 0, 0); } }; }
internal static ListViewController AddList <T>(ref SubMenu sub, T settings, string Label, string HintText, int sizeCount) where T : ConfigModel { List <float> values = new List <float>() { }; for (var i = 0; i < sizeCount; i++) { values.Add(i); } var list = sub.AddList(Label, values.ToArray(), HintText); list.applyImmediately = true; PositionElement(list.gameObject); LoadedSettings.Add(list); if (!(settings is null)) { list.SetValue = (v) => Instance?.StartCoroutine(DelayedMockCounterUpdate(settings)); } return(list); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { _maxResultsShownStagingValue = PluginConfig.MaxSearchResults; _stripSymbolsStagingValue = PluginConfig.StripSymbols; _splitQueryStagingValue = PluginConfig.SplitQueryByWords; _songFieldsStagingValue = PluginConfig.SongFieldsToSearch; _compactModeStagingValue = PluginConfig.CompactSearchMode; if (firstActivation) { var headerRectTransform = Instantiate(Resources.FindObjectsOfTypeAll <RectTransform>() .First(x => x.name == "HeaderPanel" && x.parent.name == "PlayerSettingsViewController"), this.rectTransform); headerRectTransform.gameObject.SetActive(true); TextMeshProUGUI titleText = headerRectTransform.GetComponentInChildren <TextMeshProUGUI>(); titleText.text = "Options"; _submenu = new SubMenu(this.transform); // have to use the ListViewController because IntViewController doesn't seem to work outside of the settings menu float[] maxResultsShownValues = Enumerable.Range(PluginConfig.MaxSearchResultsMinValue, PluginConfig.MaxSearchResultsMaxValue + 1) .Select((x) => (float)x).ToArray(); _maxResultsShownSetting = _submenu.AddList("Maximum # of Results Shown", maxResultsShownValues, "The maximum number of songs found before a search result is shown.\n" + "<color=#11FF11>A lower number is less distracting and only displays results when most irrelevant songs are removed.</color>\n" + "<color=#FFFF11>You can force a search result to be shown using the button on the center screen.</color>"); _maxResultsShownSetting.GetTextForValue += x => ((int)x).ToString(); _maxResultsShownSetting.GetValue += () => _maxResultsShownStagingValue; _maxResultsShownSetting.SetValue += delegate(float value) { _maxResultsShownStagingValue = (int)value; _resetButton.interactable = true; _applyButton.interactable = true; }; SetSettingElementPosition(_maxResultsShownSetting.transform as RectTransform); _maxResultsShownSetting.Init(); _maxResultsShownSetting.applyImmediately = true; // applyImmediately is after Init(), otherwise it calls SetValue once _splitQuerySetting = _submenu.AddBool("Search Each Word Individually", "Split up the search query into words and searches the song details for those words individually. " + "A song will only appear in the results if it contains all the words typed.\n" + "<color=#11FF11>'ON' - For when you know some words or names in the song details, but not the specific order.</color>\n" + "<color=#11FF11>'OFF' - Useful if you want to search for a particular phrase.</color>"); _splitQuerySetting.GetValue += () => _splitQueryStagingValue; _splitQuerySetting.SetValue += delegate(bool value) { _splitQueryStagingValue = value; _resetButton.interactable = true; _applyButton.interactable = true; }; SetSettingElementPosition(_splitQuerySetting.transform as RectTransform); _splitQuerySetting.Init(); _splitQuerySetting.applyImmediately = true; float[] songFieldsValues = new float[3] { (float)SearchableSongFields.All, (float)SearchableSongFields.TitleAndAuthor, (float)SearchableSongFields.TitleOnly }; _songFieldsSetting = _submenu.AddList("Song Fields to Search", songFieldsValues, "A query will only search in these particular details of a song.\n" + "<color=#11FF11>Can get relevant results quicker if you never search for song artist or beatmap creator.</color>\n" + "Options - 'All', 'Title and Author', 'Title Only'"); _songFieldsSetting.GetTextForValue += delegate(float value) { switch (value) { case (float)SearchableSongFields.All: return("All"); case (float)SearchableSongFields.TitleAndAuthor: return("<size=80%>Title and Author</size>"); //case (float)SearchableSongFields.TitleOnly: default: return("Title Only"); } }; _songFieldsSetting.GetValue += () => (float)_songFieldsStagingValue; _songFieldsSetting.SetValue += delegate(float value) { _songFieldsStagingValue = (SearchableSongFields)value; _resetButton.interactable = true; _applyButton.interactable = true; }; SetSettingElementPosition(_songFieldsSetting.transform as RectTransform); _songFieldsSetting.Init(); _songFieldsSetting.applyImmediately = true; _stripSymbolsSetting = _submenu.AddBool("Strip Symbols from Song Details", "Removes symbols from song title, subtitle, artist, etc. fields when performing search.\n" + "<color=#11FF11>Can be useful when searching for song remixes and titles with apostrophes, quotations, or hyphens.</color>"); _stripSymbolsSetting.GetValue += () => _stripSymbolsStagingValue; _stripSymbolsSetting.SetValue += delegate(bool value) { _stripSymbolsStagingValue = value; _resetButton.interactable = true; _applyButton.interactable = true; }; SetSettingElementPosition(_stripSymbolsSetting.transform as RectTransform); _stripSymbolsSetting.Init(); _stripSymbolsSetting.applyImmediately = true; _compactModeSetting = _submenu.AddBool("Use Compact Mode", "Removes the keyboard on the right screen, replacing it with a smaller keyboard on the center screen."); _compactModeSetting.GetValue += () => _compactModeStagingValue; _compactModeSetting.SetValue += delegate(bool value) { _compactModeStagingValue = value; _resetButton.interactable = true; _applyButton.interactable = true; }; SetSettingElementPosition(_compactModeSetting.transform as RectTransform); _compactModeSetting.Init(); _compactModeSetting.applyImmediately = true; _defaultButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", new Vector2(-37f, -32f), new Vector2(36f, 10f), DefaultButtonPressed, "Use Defaults"); _defaultButton.ToggleWordWrapping(false); _resetButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", new Vector2(16f, -32f), new Vector2(24f, 9f), ResetButtonPressed, "Reset"); _resetButton.ToggleWordWrapping(false); _applyButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", new Vector2(43f, -32f), new Vector2(24f, 9f), ApplyButtonPressed, "Apply"); _applyButton.ToggleWordWrapping(false); } else { // force show current value in config RefreshUI(); } _resetButton.interactable = false; _applyButton.interactable = false; }
public static void InitializeMenu() { InitializePresetList(); MenuButtonUI.AddButton("Reload Chroma", OnReloadClick); MenuButtonUI.AddButton("Show Release Notes", "Shows the Release Notes and other info from the Beat Saber developers", delegate { SidePanelUtil.ResetPanel(); }); MenuButtonUI.AddButton("Chroma Notes", "Shows the Release Notes and other info for Chroma", delegate { SidePanelUtil.SetPanel("chroma"); }); MenuButtonUI.AddButton("Safety Waiver", "Shows the Chroma Safety Waiver", delegate { SidePanelUtil.SetPanel("chromaWaiver"); }); /* * SETTINGS */ SubMenu ctSettings = SettingsUI.CreateSubMenu("Chroma Settings"); BoolViewController hideSubMenusController = ctSettings.AddBool("Hide CT Menus", "If true, hides all other Chroma menus. This has a lot of options, I know."); hideSubMenusController.GetValue += delegate { return(ChromaConfig.HideSubMenus); }; hideSubMenusController.SetValue += delegate(bool value) { ChromaConfig.HideSubMenus = value; }; BoolViewController ctSettingsMapCheck = ctSettings.AddBool("Enabled Map Checking", "If false, Chroma and its extensions will not check for special maps. Recommended to leave on."); ctSettingsMapCheck.GetValue += delegate { return(ChromaConfig.CustomMapCheckingEnabled); }; ctSettingsMapCheck.SetValue += delegate(bool value) { ChromaConfig.CustomMapCheckingEnabled = value; }; ListViewController ctSettingsMasterVolume = ctSettings.AddList("Chroma Sounds Volume", new float[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f }, "Master volume control for sounds made by Chroma"); ctSettingsMasterVolume.GetValue += delegate { return(ChromaConfig.MasterVolume); }; ctSettingsMasterVolume.SetValue += delegate(float value) { ChromaConfig.MasterVolume = value; }; ctSettingsMasterVolume.FormatValue += delegate(float value) { return(value * 100 + "%"); }; BoolViewController ctSettingsDebugMode = ctSettings.AddBool("Debug Mode", "Very performance heavy - only do this if you are bug chasing."); ctSettingsDebugMode.GetValue += delegate { return(ChromaConfig.DebugMode); }; ctSettingsDebugMode.SetValue += delegate(bool value) { ChromaConfig.DebugMode = value; }; ListViewController ctLogSettings = ctSettings.AddList("Logging Level", new float[] { 0, 1, 2, 3 }, "The further to the left this is, the more will be logged."); ctLogSettings.applyImmediately = true; ctLogSettings.GetValue += delegate { return((int)ChromaLogger.LogLevel); }; ctLogSettings.SetValue += delegate(float value) { ChromaLogger.LogLevel = (ChromaLogger.Level)(int) value; ChromaConfig.SetInt("Logger", "loggerLevel", (int)value); }; ctLogSettings.FormatValue += delegate(float value) { return(((ChromaLogger.Level)(int) value).ToString()); }; StringViewController ctPassword = ctSettings.AddString("Secrets", "What could it mean?!?!"); ctPassword.GetValue += delegate { return(""); }; ctPassword.SetValue += delegate(string value) { if (value.ToUpper() == "SAFETYHAZARD") { ChromaConfig.WaiverRead = true; AudioUtil.Instance.PlayOneShotSound("NightmareMode.wav"); } else if (value.ToUpper() == "CREDITS") { AudioUtil.Instance.PlayOneShotSound("ConfigReload.wav"); } }; SettingsMenuCreatedEvent?.Invoke(ctSettings); ChromaLogger.Log("Sub-menus " + (ChromaConfig.HideSubMenus ? "are" : "are not") + " hidden."); /* * SUB-MENUS */ if (!ChromaConfig.HideSubMenus) { float[] presets = new float[colourPresets.Count]; for (int i = 0; i < colourPresets.Count; i++) { presets[i] = i; } /* * NOTES COLOURS */ SubMenu ctNotes = SettingsUI.CreateSubMenu("Chroma Notes"); //A ListViewController ctAColour = ctNotes.AddList("Left Notes", presets); ctAColour.applyImmediately = true; ctAColour.GetValue += delegate { String name = ChromaConfig.GetString("Notes", "colourA", "DEFAULT"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctAColour.SetValue += delegate(float value) { ColourManager.A = colourPresets[(int)value].color; ChromaConfig.SetString("Notes", "colourA", colourPresets[(int)value].name); }; ctAColour.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; //B ListViewController ctBColour = ctNotes.AddList("Right Notes", presets); ctBColour.applyImmediately = true; ctBColour.GetValue += delegate { String name = ChromaConfig.GetString("Notes", "colourB", "DEFAULT"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctBColour.SetValue += delegate(float value) { ColourManager.B = colourPresets[(int)value].color; ChromaConfig.SetString("Notes", "colourB", colourPresets[(int)value].name); }; ctBColour.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; SettingsNoteMenuAddedEvent?.Invoke(ctNotes, presets, colourPresets); /* * LIGHTS COLOURS */ SubMenu ctLights = SettingsUI.CreateSubMenu("Chroma Lights"); ListViewController ctLightAmbientColour = ctLights.AddList("Ambient (bg) Lights", presets); ctLightAmbientColour.applyImmediately = true; ctLightAmbientColour.GetValue += delegate { String name = ChromaConfig.GetString("Lights", "lightAmbient", "DEFAULT"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctLightAmbientColour.SetValue += delegate(float value) { ColourManager.LightAmbient = colourPresets[(int)value].color; ChromaConfig.SetString("Lights", "lightAmbient", colourPresets[(int)value].name); ColourManager.RecolourAmbientLights(ColourManager.LightAmbient); }; ctLightAmbientColour.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; //LightA ListViewController ctLightAColour = ctLights.AddList("Warm (red) Lights", presets); ctLightAColour.applyImmediately = true; ctLightAColour.GetValue += delegate { String name = ChromaConfig.GetString("Lights", "lightColourA", "DEFAULT"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctLightAColour.SetValue += delegate(float value) { ColourManager.LightA = colourPresets[(int)value].color; ChromaConfig.SetString("Lights", "lightColourA", colourPresets[(int)value].name); }; ctLightAColour.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; //LightB ListViewController ctLightBColour = ctLights.AddList("Cold (blue) Lights", presets); ctLightBColour.applyImmediately = true; ctLightBColour.GetValue += delegate { String name = ChromaConfig.GetString("Lights", "lightColourB", "DEFAULT"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctLightBColour.SetValue += delegate(float value) { ColourManager.LightB = colourPresets[(int)value].color; ChromaConfig.SetString("Lights", "lightColourB", colourPresets[(int)value].name); }; ctLightBColour.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; SettingsLightsMenuAddedEvent?.Invoke(ctLights, presets, colourPresets); /* * OTHERS COLOURS */ SubMenu ctOthers = SettingsUI.CreateSubMenu("Chroma Aesthetics"); //Barriers ListViewController ctBarrier = ctOthers.AddList("Barriers", presets); ctBarrier.applyImmediately = true; ctBarrier.GetValue += delegate { String name = ChromaConfig.GetString("Aesthetics", "barrierColour", "Barrier Red"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctBarrier.SetValue += delegate(float value) { ColourManager.BarrierColour = colourPresets[(int)value].color; ChromaConfig.SetString("Aesthetics", "barrierColour", colourPresets[(int)value].name); }; ctBarrier.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; //BarrierCorrection ListViewController ctBarrierCorrection = ctOthers.AddList("Barrier Col. Correction", new float[] { 0, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2f }); ctBarrierCorrection.GetValue += delegate { return(ColourManager.barrierColourCorrectionScale); }; ctBarrierCorrection.SetValue += delegate(float value) { ColourManager.barrierColourCorrectionScale = value; ChromaConfig.SetFloat("Aesthetics", "barrierColourCorrectionScale", value); }; ctBarrierCorrection.FormatValue += delegate(float value) { return(value * 100 + "%"); }; //SignB ListViewController ctSignB = ctOthers.AddList("Neon Sign Top", presets); ctSignB.applyImmediately = true; ctSignB.GetValue += delegate { String name = ChromaConfig.GetString("Aesthetics", "signColourB", "Notes Blue"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctSignB.SetValue += delegate(float value) { ColourManager.SignB = colourPresets[(int)value].color; ChromaConfig.SetString("Aesthetics", "signColourB", colourPresets[(int)value].name); ColourManager.RecolourNeonSign(ColourManager.SignA, ColourManager.SignB); }; ctSignB.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; //SignA ListViewController ctSignA = ctOthers.AddList("Neon Sign Bottom", presets); ctSignA.applyImmediately = true; ctSignA.GetValue += delegate { String name = ChromaConfig.GetString("Aesthetics", "signColourA", "Notes Red"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctSignA.SetValue += delegate(float value) { ColourManager.SignA = colourPresets[(int)value].color; ChromaConfig.SetString("Aesthetics", "signColourA", colourPresets[(int)value].name); ColourManager.RecolourNeonSign(ColourManager.SignA, ColourManager.SignB); }; ctSignA.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; //LaserPointer ListViewController ctLaserColour = ctOthers.AddList("Laser Pointer", presets); ctLaserColour.applyImmediately = true; ctLaserColour.GetValue += delegate { String name = ChromaConfig.GetString("Aesthetics", "laserPointerColour", "Notes Blue"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctLaserColour.SetValue += delegate(float value) { ColourManager.LaserPointerColour = colourPresets[(int)value].color; ChromaConfig.SetString("Aesthetics", "laserPointerColour", colourPresets[(int)value].name); //ColourManager.RecolourLaserPointer(ColourManager.LaserPointerColour); ColourManager.RecolourMenuStuff(ColourManager.A, ColourManager.B, ColourManager.LightA, ColourManager.LightB, ColourManager.Platform, ColourManager.LaserPointerColour); }; ctLaserColour.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; ListViewController ctPlatform = ctOthers.AddList("Platform Accoutrements", presets); ctPlatform.applyImmediately = true; ctPlatform.GetValue += delegate { String name = ChromaConfig.GetString("Aesthetics", "platformAccoutrements", "DEFAULT"); for (int i = 0; i < colourPresets.Count; i++) { if (colourPresets[i].name == name) { return(i); } } return(0); }; ctPlatform.SetValue += delegate(float value) { ColourManager.Platform = colourPresets[(int)value].color; ChromaConfig.SetString("Aesthetics", "platformAccoutrements", colourPresets[(int)value].name); ColourManager.RecolourMenuStuff(ColourManager.A, ColourManager.B, ColourManager.LightA, ColourManager.LightB, ColourManager.Platform, ColourManager.LaserPointerColour); }; ctPlatform.FormatValue += delegate(float value) { return(colourPresets[(int)value].name); }; SettingsOthersMenuAddedEvent?.Invoke(ctOthers, presets, colourPresets); ExtensionSubMenusEvent?.Invoke(presets, colourPresets); } GameplaySettingsUISetup(); }
private void FirstActivation() { RectTransform containerRect = new GameObject("AvatarSettingsContainer", typeof(RectTransform)).transform as RectTransform; containerRect.SetParent(rectTransform, false); containerRect.anchorMin = new Vector2(0.05f, 0.0f); containerRect.anchorMax = new Vector2(0.95f, 1.0f); containerRect.sizeDelta = new Vector2(0, 0); SubMenu container = new SubMenu(containerRect); System.Action <RectTransform, float, float, float, float, float, float> relative_layout = (RectTransform rt, float x, float y, float w, float h, float pivotx, float pivoty) => { rt.anchorMin = new Vector2(x, y); rt.anchorMax = new Vector2(x + w, y + h); rt.pivot = new Vector2(pivotx, pivoty); rt.sizeDelta = Vector2.zero; rt.anchoredPosition = Vector2.zero; }; gameObject.SetActive(false); TextMeshProUGUI text = BeatSaberUI.CreateText(containerRect, "AVATAR SETTINGS (buttons don't work, use the hotkeys)", Vector2.zero); text.fontSize = 6.0f; text.alignment = TextAlignmentOptions.Center; relative_layout(text.rectTransform, 0f, 0.85f, 1f, 0.166f, 0.5f, 1f); var boolFirstPerson = container.AddList("[HOME] Visible In First Person View", new float[] { 0, 1 }); boolFirstPerson.applyImmediately = true; relative_layout(boolFirstPerson.transform as RectTransform, 0, 0.66f, 1, 0.166f, 0, 1f); BeatSaberUI.AddHintText(boolFirstPerson.transform as RectTransform, "Allows you to see the avatar inside of VR"); var boolRotatePreviewAvatar = container.AddList("Rotate Avatar Preview", new float[] { 0, 1 }); boolRotatePreviewAvatar.applyImmediately = true; relative_layout(boolRotatePreviewAvatar.transform as RectTransform, 0, 0.55f, 1, 0.166f, 0, 1f); BeatSaberUI.AddHintText(boolRotatePreviewAvatar.transform as RectTransform, "Slowly rotate the preview model"); var listResizePolicy = container.AddList("[END] Resize Avatars To Player's", new float[] { 0, 1, 2 }); listResizePolicy.applyImmediately = true; relative_layout(listResizePolicy.transform as RectTransform, 0, 0.44f, 1, 0.166f, 0, 1f); BeatSaberUI.AddHintText(listResizePolicy.transform as RectTransform, "Use 'Arms Length' to resize the avatar based on your proportions, 'Height' to resize based on your height, and 'Never' to not resize"); var boolFloorMovePolicy = container.AddList("[Insert] Floor Height Adjust", new float[] { 0, 1 }); boolFloorMovePolicy.applyImmediately = true; relative_layout(boolFloorMovePolicy.transform as RectTransform, 0, 0.33f, 1, 0.166f, 0, 1f); BeatSaberUI.AddHintText(boolFloorMovePolicy.transform as RectTransform, "Move the floor to compensate for height when using 'Arms Length' resize, requires CustomPlatforms"); var labelMeasure = BeatSaberUI.CreateText(containerRect, $"Hand To Hand Length = {Mathf.Ceil(Plugin.Instance.AvatarTailor.PlayerArmLength * 100.0f) / 100.0f}", Vector2.zero); relative_layout(labelMeasure.transform as RectTransform, 0f, 0.18f, 0.5f, 0.11f, 0, .5f); BeatSaberUI.AddHintText(labelMeasure.transform as RectTransform, "Value used for 'Arms Length' resize, press on the 'MEASURE!' button and T-Pose"); labelMeasure.fontSize = 5f; labelMeasure.alignment = TextAlignmentOptions.MidlineLeft; gameObject.SetActive(true); var buttonMeasure = BeatSaberUI.CreateUIButton(containerRect, "QuitButton", () => { labelMeasure.text = "Measuring ..."; Plugin.Instance.AvatarTailor.MeasurePlayerArmLength((value) => { labelMeasure.text = $"Measuring ... {Mathf.Ceil(value * 100.0f) / 100.0f}"; }, (result) => { labelMeasure.text = $"Hand To Hand Length = {Mathf.Ceil(result * 100.0f) / 100.0f}"; if (Plugin.Instance.AvatarTailor.ResizePolicy == AvatarTailor.ResizePolicyType.AlignArmLength) { Plugin.Instance.PlayerAvatarManager.ResizePlayerAvatar(); } }); }, "Measure!"); relative_layout(buttonMeasure.transform as RectTransform, 0.65f, 0.18f, 0.35f, 0.11f, .5f, .5f); BeatSaberUI.AddHintText(buttonMeasure.transform as RectTransform, "Press this and T-Pose to measure your arms, needed to use 'Arms Length' resize"); boolFirstPerson.GetTextForValue = (value) => (value != 0f) ? "ON" : "OFF"; boolFirstPerson.GetValue = () => Plugin.Instance.FirstPersonEnabled ? 1f : 0f; boolFirstPerson.SetValue = (value) => Plugin.Instance.FirstPersonEnabled = value != 0f; boolFirstPerson.Init(); boolRotatePreviewAvatar.GetTextForValue = (value) => value != 0f ? "ON" : "OFF"; boolRotatePreviewAvatar.GetValue = () => Plugin.Instance.RotatePreviewEnabled ? 1f : 0f; boolRotatePreviewAvatar.SetValue = (value) => Plugin.Instance.RotatePreviewEnabled = value != 0f; boolRotatePreviewAvatar.Init(); listResizePolicy.GetTextForValue = (value) => new string[] { "Arms Length", "Height", "Never" }[(int)value]; listResizePolicy.GetValue = () => (int)Plugin.Instance.AvatarTailor.ResizePolicy; listResizePolicy.SetValue = (value) => { Plugin.Instance.AvatarTailor.ResizePolicy = (AvatarTailor.ResizePolicyType)(int) value; Plugin.Instance.PlayerAvatarManager.ResizePlayerAvatar(); }; listResizePolicy.Init(); boolFloorMovePolicy.GetTextForValue = (value) => (value != 0f) ? "ON" : "OFF"; boolFloorMovePolicy.GetValue = () => Plugin.Instance.AvatarTailor.FloorMovePolicy == AvatarTailor.FloorMovePolicyType.AllowMove ? 1f : 0f; boolFloorMovePolicy.SetValue = (value) => { Plugin.Instance.AvatarTailor.FloorMovePolicy = (value != 0f) ? AvatarTailor.FloorMovePolicyType.AllowMove : AvatarTailor.FloorMovePolicyType.NeverMove; Plugin.Instance.PlayerAvatarManager.ResizePlayerAvatar(); }; boolFloorMovePolicy.Init(); }
private static void SetupChromaSparksMenu(float[] presets, List <NamedColor> colourPresets) { /* * PARTICLES */ SubMenu ctParticles = SettingsUI.CreateSubMenu("Chroma Sparks"); float[] particleMults = new float[] { 0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2f, 2.25f, 2.5f, 2.75f, 3f, 3.25f, 3.5f, 3.75f, 4f, 4.25f, 4.5f, 4.75f, 5f, 5.5f, 6f, 6.5f, 7f, 7.5f, 8f, 8.5f, 9f, 9.5f, 10f, 11f, 12f, 13f, 14f, 15f, 16f, 17f, 18f, 19f, 20f, 22.5f, 25f, 27.5f, 30f, 32.5f, 35f, 37.5f, 40f, 42.5f, 45f, 47.5f, 50f, 55f, 60f, 65f, 70f, 75f, 80f, 85f, 90f, 100f, 110f, 120f, 130f, 140f, 150f, 160f, 170f, 180f, 190f, 200f }; //Completely disable particle affecting BoolViewController ctParticlesEnabled = ctParticles.AddBool("Override Particles"); ctParticlesEnabled.GetValue += delegate { return(ChromaSparksConfig.ParticleManipulationEnabled); }; ctParticlesEnabled.SetValue += delegate(bool value) { ChromaSparksConfig.ParticleManipulationEnabled = value; }; //global Particles Mult ListViewController ctParticlesMax = ctParticles.AddList("Global Particle Max", particleMults); ctParticlesMax.GetValue += delegate { return(ChromaSparksConfig.ParticlesGlobalMaxMult); }; ctParticlesMax.SetValue += delegate(float value) { ChromaSparksConfig.ParticlesGlobalMaxMult = value; }; ctParticlesMax.FormatValue += delegate(float value) { return(value * 100 + "%"); }; //slash Particles Mult ListViewController ctSlashAmt = ctParticles.AddList("Slash Part. Amount", particleMults); ctSlashAmt.GetValue += delegate { return(ChromaSparksConfig.SlashParticlesMult); }; ctSlashAmt.SetValue += delegate(float value) { ChromaSparksConfig.SlashParticlesMult = value; }; ctSlashAmt.FormatValue += delegate(float value) { return(value * 100 + "%"); }; /*//slash Particles Life * ListViewController ctSlashLife = ctParticles.AddList("Slash Part. Lifetime", particleMults); * ctSlashLife.GetValue += delegate { return Plugin.slashParticlesLifeMult; }; * ctSlashLife.SetValue += delegate (float value) { Plugin.slashParticlesLifeMult = value; Plugin.didChangeSettings = true; }; * ctSlashLife.FormatValue += delegate (float value) { return value * 100 + "%"; };*/ //slash Particles Life ListViewController ctSlashSpeed = ctParticles.AddList("Slash Part. Speed", particleMults); ctSlashSpeed.GetValue += delegate { return(ChromaSparksConfig.SlashParticlesSpeedMult); }; ctSlashSpeed.SetValue += delegate(float value) { ChromaSparksConfig.SlashParticlesSpeedMult = value; }; ctSlashSpeed.FormatValue += delegate(float value) { return(value * 100 + "%"); }; ListViewController ctSlashTimeScale = ctParticles.AddList("Slash Part. TimeScale", particleMults); ctSlashTimeScale.GetValue += delegate { return(ChromaSparksConfig.SlashParticlesTimeScale); }; ctSlashTimeScale.SetValue += delegate(float value) { ChromaSparksConfig.SlashParticlesTimeScale = value; }; ctSlashTimeScale.FormatValue += delegate(float value) { if (value == 1) { return("Unchanged"); } return(value + "/s"); }; //explosions Particles Mult ListViewController ctExplosionsAmt = ctParticles.AddList("Explosion Part. Amount", particleMults); ctExplosionsAmt.GetValue += delegate { return(ChromaSparksConfig.ExplosionParticlesMult); }; ctExplosionsAmt.SetValue += delegate(float value) { ChromaSparksConfig.ExplosionParticlesMult = value; }; ctExplosionsAmt.FormatValue += delegate(float value) { return(value * 100 + "%"); }; /*//explosions Particles Life * ListViewController ctExplosionsLife = ctParticles.AddList("Explosion Part. Lifetime", particleMults); * ctExplosionsLife.GetValue += delegate { return Plugin.explosionParticlesLifeMult; }; * ctExplosionsLife.SetValue += delegate (float value) { Plugin.explosionParticlesLifeMult = value; Plugin.didChangeSettings = true; }; * ctExplosionsLife.FormatValue += delegate (float value) { return value * 100 + "%"; };*/ //explosions Particles Life ListViewController ctExplosionsSpeed = ctParticles.AddList("Explosion Part. Speed", particleMults); ctExplosionsSpeed.GetValue += delegate { return(ChromaSparksConfig.ExplosionParticlesSpeedMult); }; ctExplosionsSpeed.SetValue += delegate(float value) { ChromaSparksConfig.ExplosionParticlesSpeedMult = value; }; ctExplosionsSpeed.FormatValue += delegate(float value) { return(value * 100 + "%"); }; ListViewController ctExplosionsTimeScale = ctParticles.AddList("Explosion Part. TimeScale", particleMults); ctExplosionsTimeScale.GetValue += delegate { return(ChromaSparksConfig.ExplosionParticlesTimeScale); }; ctExplosionsTimeScale.SetValue += delegate(float value) { ChromaSparksConfig.ExplosionParticlesTimeScale = value; }; ctExplosionsTimeScale.FormatValue += delegate(float value) { if (value == 1) { return("Unchanged"); } return(value + "/s"); }; }