private void RefreshUI(bool init = true, bool refreshValue = false) { if (init) { if (!refreshValue) { // disable applyImmediately temporarily, otherwise Init() triggers a call to SetValue, which also calls RefreshUI() _minViewController.applyImmediately = false; _maxViewController.applyImmediately = false; _includeUnratedViewController.applyImmediately = false; } _minViewController.Init(); _maxViewController.Init(); _includeUnratedViewController.Init(); if (!refreshValue) { _minViewController.applyImmediately = true; _maxViewController.applyImmediately = true; _includeUnratedViewController.applyImmediately = true; } } // reset button state _minViewController.GetComponentsInChildren <Button>().First(x => x.name == "DecButton").interactable = _minEnabledStagingValue && _minStagingValue > MinValue; _minViewController.GetComponentsInChildren <Button>().First(x => x.name == "IncButton").interactable = _minEnabledStagingValue && (!_maxEnabledStagingValue || _minStagingValue < _maxStagingValue) && _minStagingValue < MaxValue; _maxViewController.GetComponentsInChildren <Button>().First(x => x.name == "DecButton").interactable = _maxEnabledStagingValue && (!_minEnabledStagingValue || _maxStagingValue > _minStagingValue) && _maxStagingValue > MinValue; _maxViewController.GetComponentsInChildren <Button>().First(x => x.name == "IncButton").interactable = _maxEnabledStagingValue && _maxStagingValue < MaxValue; }
/// <summary> /// Force the current staging values to be displayed /// </summary> private void RefreshUI() { _maxResultsShownSetting.Init(); _stripSymbolsSetting.Init(); _splitQuerySetting.Init(); _songFieldsSetting.Init(); _compactModeSetting.Init(); }
private void RefreshUI() { _oneSaberViewController.applyImmediately = false; _lightshowViewController.applyImmediately = false; _mappingExtensionsViewController.applyImmediately = false; _oneSaberViewController.Init(); _lightshowViewController.Init(); _mappingExtensionsViewController.Init(); _oneSaberViewController.applyImmediately = true; _lightshowViewController.applyImmediately = true; _mappingExtensionsViewController.applyImmediately = true; }
public static VRUIViewController Create() { menu = SettingsUI.CreateSubMenu("ModListSettings", false); autoCheck = menu.AddBool("Auto Update Check", "If enabled, automatically checks for updates on game start."); autoUpdate = menu.AddBool("Auto Update", "If enabled, automatically installs updates after checking for them."); showEnableDisable = menu.AddBool("Show Enable/Disable Button", "If enabled, BSIPA mods will have a button to enable or disable them."); autoCheck.applyImmediately = true; autoCheck.GetValue += () => IPA.Config.SelfConfig.Instance.Value.Updates.AutoCheckUpdates; autoCheck.SetValue += val => { IPA.Config.SelfConfig.Instance.Value.Updates.AutoCheckUpdates = val; IPA.Config.SelfConfig.LoaderConfig.Store(IPA.Config.SelfConfig.Instance.Value); }; autoUpdate.applyImmediately = true; autoUpdate.GetValue += () => IPA.Config.SelfConfig.Instance.Value.Updates.AutoUpdate; autoUpdate.SetValue += val => { IPA.Config.SelfConfig.Instance.Value.Updates.AutoUpdate = val; IPA.Config.SelfConfig.LoaderConfig.Store(IPA.Config.SelfConfig.Instance.Value); }; showEnableDisable.applyImmediately = true; showEnableDisable.GetValue += () => Plugin.config.Value.ShowEnableDisable; showEnableDisable.SetValue += val => { Plugin.config.Value.ShowEnableDisable = val; Plugin.provider.Store(Plugin.config.Value); }; autoCheck.Init(); autoUpdate.Init(); showEnableDisable.Init(); return(menu.viewController); }
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 void Init() { if (_isInitialized) { return; } // we're using SongDataCore's ScoreSaber data storage to find out the star rating if (!Tweaks.SongDataCoreTweaks.ModLoaded) { Controls = new FilterControl[1]; var noModMessage = BeatSaberUI.CreateText(null, "<color=#FFAAAA>Sorry!\n\n<size=80%>This filter requires the SongDataCore mod to be\n installed.</size></color>", Vector2.zero); noModMessage.alignment = TextAlignmentOptions.Center; noModMessage.fontSize = 5.5f; Controls[0] = new FilterControl(noModMessage.gameObject, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(80f, 50f), new Vector2(0f, 10f)); _isInitialized = true; return; } var togglePrefab = Utilities.GetTogglePrefab(); // title text var text = BeatSaberUI.CreateText(null, "Keep Songs Between Some Star Rating", Vector2.zero, Vector2.zero); text.fontSize = 5.5f; var rt = text.rectTransform; rt.anchorMin = new Vector2(0f, 1f); rt.anchorMax = new Vector2(0f, 1f); rt.pivot = new Vector2(0f, 1f); Controls[0] = new FilterControl(text.gameObject, new Vector2(0f, 0.95f), new Vector2(0f, 0.95f), new Vector2(0f, 1f), new Vector2(50f, 6f), Vector2.zero); // min view controller float[] values = Enumerable.Range((int)MinValue, (int)((MaxValue - MinValue) / IncrementValue) + 1).Select(x => x * IncrementValue).ToArray(); _minViewController = Utilities.CreateListViewController("Minimum Star Rating", values, "Filters out songs that have a lesser star difficulty rating than this value"); _minViewController.GetTextForValue += x => x.ToString("0.00"); _minViewController.GetValue += () => _minStagingValue; _minViewController.SetValue += delegate(float value) { if (_maxEnabledStagingValue && value > _maxStagingValue) { _minStagingValue = _maxStagingValue; RefreshUI(); return; } _minStagingValue = value; RefreshUI(false); SettingChanged?.Invoke(); }; _minViewController.Init(); _minViewController.applyImmediately = true; var minToggle = Utilities.CreateToggleFromPrefab(togglePrefab.toggle, _minViewController.transform.Find("Value")); minToggle.name = "MinValueToggle"; minToggle.onValueChanged.AddListener(delegate(bool value) { _minEnabledStagingValue = value; if (value && _maxEnabledStagingValue && _minStagingValue > _maxStagingValue) { _minStagingValue = _maxStagingValue; } RefreshUI(true, true); SettingChanged?.Invoke(); }); Utilities.MoveListViewControllerElements(_minViewController); Utilities.CreateHorizontalDivider(_minViewController.transform); Controls[1] = new FilterControl(_minViewController.gameObject, new Vector2(0f, 0.95f), new Vector2(1f, 0.95f), new Vector2(0.5f, 1f), new Vector2(0f, 12f), new Vector2(0f, -8f), delegate() { // disabling buttons needs to be done after the view controller is enabled to override the interactable assignments of ListSettingsController:OnEnable() _minViewController.GetComponentsInChildren <Button>().First(x => x.name == "DecButton").interactable = _minEnabledStagingValue && _minStagingValue > MinValue; _maxViewController.GetComponentsInChildren <Button>().First(x => x.name == "IncButton").interactable = _minEnabledStagingValue && (!_maxEnabledStagingValue || _minStagingValue < _maxStagingValue) && _minStagingValue < MaxValue; }); // max view controller _maxViewController = Utilities.CreateListViewController("Maximum Star Rating", values, "Filters out songs that have a greater star difficulty rating than this value"); _maxViewController.GetTextForValue += x => x.ToString("0.00"); _maxViewController.GetValue += () => _maxStagingValue; _maxViewController.SetValue += delegate(float value) { if (_minEnabledStagingValue && value < _minStagingValue) { _maxStagingValue = _minStagingValue; RefreshUI(); return; } _maxStagingValue = value; RefreshUI(false); SettingChanged?.Invoke(); }; _maxViewController.Init(); _maxViewController.applyImmediately = true; var maxToggle = Utilities.CreateToggleFromPrefab(togglePrefab.toggle, _maxViewController.transform.Find("Value")); maxToggle.name = "MaxValueToggle"; maxToggle.onValueChanged.AddListener(delegate(bool value) { _maxEnabledStagingValue = value; if (value && _minEnabledStagingValue && _maxStagingValue < _minStagingValue) { _maxStagingValue = _minStagingValue; } RefreshUI(true, true); SettingChanged?.Invoke(); }); Utilities.MoveListViewControllerElements(_maxViewController); Utilities.CreateHorizontalDivider(_maxViewController.transform); Controls[2] = new FilterControl(_maxViewController.gameObject, new Vector2(0f, 0.95f), new Vector2(1f, 0.95f), new Vector2(0.5f, 1f), new Vector2(0f, 12f), new Vector2(0f, -20f), delegate() { // disabling buttons needs to be done after the view controller is enabled to override the interactable assignments of ListSettingsController:OnEnable() _maxViewController.GetComponentsInChildren <Button>().First(x => x.name == "DecButton").interactable = _maxEnabledStagingValue && (!_minEnabledStagingValue || _maxStagingValue > _minStagingValue) && _maxStagingValue > MinValue; _maxViewController.GetComponentsInChildren <Button>().First(x => x.name == "IncButton").interactable = _maxEnabledStagingValue && _maxStagingValue < MaxValue; }); // include unrated songs toggle _includeUnratedViewController = Utilities.CreateBoolViewController("Include Unrated Songs", "Do not filter out songs that do not have a star rating provided by ScoreSaber"); _includeUnratedViewController.GetValue += () => _includeUnratedStagingValue; _includeUnratedViewController.SetValue += delegate(bool value) { _includeUnratedStagingValue = value; SettingChanged?.Invoke(); }; _includeUnratedViewController.Init(); _includeUnratedViewController.applyImmediately = true; Utilities.MoveIncDecViewControllerElements(_includeUnratedViewController); Controls[3] = new FilterControl(_includeUnratedViewController.gameObject, new Vector2(0f, 0.95f), new Vector2(1f, 0.95f), new Vector2(0.5f, 1f), new Vector2(0f, 12f), new Vector2(0f, -32f)); Object.Destroy(togglePrefab); _isInitialized = true; }
public void Init() { if (_isInitialized) { return; } // title text var text = BeatSaberUI.CreateText(null, "Other Filters", Vector2.zero, Vector2.zero); text.fontSize = 5.5f; var rt = text.rectTransform; rt.anchorMin = new Vector2(0f, 1f); rt.anchorMax = rt.anchorMin; rt.pivot = rt.anchorMin; Controls[0] = new FilterControl(text.gameObject, new Vector2(0f, 0.95f), new Vector2(0f, 0.95f), new Vector2(0f, 1f), new Vector2(50f, 6f), Vector2.zero); // one saber view controller _oneSaberViewController = Utilities.CreateBoolViewController("Has One Saber Mode", "Filters out songs that don't have at least one saber map"); _oneSaberViewController.GetValue += () => _oneSaberStagingValue; _oneSaberViewController.SetValue += delegate(bool value) { _oneSaberStagingValue = value; SettingChanged?.Invoke(); }; _oneSaberViewController.Init(); _oneSaberViewController.applyImmediately = true; Utilities.CreateHorizontalDivider(_oneSaberViewController.transform); Utilities.MoveIncDecViewControllerElements(_oneSaberViewController); Controls[1] = new FilterControl(_oneSaberViewController.gameObject, new Vector2(0f, 0.95f), new Vector2(1f, 0.95f), new Vector2(0.5f, 1f), new Vector2(0f, 12f), new Vector2(0f, -8f)); // lightshow view controller _lightshowViewController = Utilities.CreateBoolViewController("Has Lightshow Mode", "Filters out songs that don't have a lightshow map"); _lightshowViewController.GetValue += () => _lightshowStagingValue; _lightshowViewController.SetValue += delegate(bool value) { _lightshowStagingValue = value; SettingChanged?.Invoke(); }; _lightshowViewController.Init(); _lightshowViewController.applyImmediately = true; Utilities.CreateHorizontalDivider(_lightshowViewController.transform); Utilities.MoveIncDecViewControllerElements(_lightshowViewController); Controls[2] = new FilterControl(_lightshowViewController.gameObject, new Vector2(0f, 0.95f), new Vector2(1f, 0.95f), new Vector2(0.5f, 1f), new Vector2(0f, 12f), new Vector2(0f, -20f)); // mapping extensions view controller var values = Enumerable.Range(0, 3).Select(x => (float)x).ToArray(); _mappingExtensionsViewController = Utilities.CreateListViewController("Requires Mapping Extensions", values, "Filters out songs that don't require the 'Mapping Extensions' mod"); _mappingExtensionsViewController.GetTextForValue += delegate(float value) { if (value == (float)SongRequirement.Required) { return("<size=90%>Required</size>"); } else if (value == (float)SongRequirement.NotRequired) { return("<size=70%>Not Required</size>"); } else { return("OFF"); } }; _mappingExtensionsViewController.GetValue += () => (float)_mappingExtensionsStagingValue; _mappingExtensionsViewController.SetValue += delegate(float value) { _mappingExtensionsStagingValue = (SongRequirement)value; SettingChanged?.Invoke(); }; _mappingExtensionsViewController.Init(); _mappingExtensionsViewController.applyImmediately = true; Utilities.MoveIncDecViewControllerElements(_mappingExtensionsViewController); Controls[3] = new FilterControl(_mappingExtensionsViewController.gameObject, new Vector2(0f, 0.95f), new Vector2(1f, 0.95f), new Vector2(0.5f, 1f), new Vector2(0f, 12f), new Vector2(0f, -32f)); _isInitialized = true; }