public T AddTextSegmentsSetting <T>(string name, string hintText, string[] texts) where T : SegmentedControlViewController { var volumeSettings = GetVolumeSettings(); GameObject newSettingsObject = MonoBehaviour.Instantiate(volumeSettings.gameObject, transform); newSettingsObject.name = name; ListSettingsController volume = newSettingsObject.GetComponent <ListSettingsController>(); T newTextSegmentsSettingsController = (T)ReflectionUtil.CopyComponent(volume, typeof(ListSettingsController), typeof(T), newSettingsObject); MonoBehaviour.DestroyImmediate(volume); GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("DecButton").gameObject); GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("ValueText").gameObject); GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("IncButton").gameObject); TextSegmentedControl segmentedControl = BeatSaberUI.CreateTextSegmentedControl(newSettingsObject.transform.Find("Value") as RectTransform, new Vector2(0f, 0f), new Vector2(40f, 7f)); newTextSegmentsSettingsController.segmentedControl = segmentedControl; segmentedControl.SetTexts(texts); var tmpText = newSettingsObject.GetComponentInChildren <TMP_Text>(); tmpText.text = name; if (hintText != String.Empty) { BeatSaberUI.AddHintText(tmpText.rectTransform, hintText); } viewController?.AddSubmenuOption(newSettingsObject); AddHooks(newTextSegmentsSettingsController); return(newTextSegmentsSettingsController); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation && activationType == ActivationType.AddedToHierarchy) { _beatmapCharacteristics = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSO>(); _standardCharacteristic = _beatmapCharacteristics.First(x => x.serializedName == "Standard"); bool isHost = Client.Instance.isHost; _selectedSongCell = Instantiate(Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")), rectTransform, false); (_selectedSongCell.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_selectedSongCell.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_selectedSongCell.transform as RectTransform).anchoredPosition = new Vector2(-25f, 7.5f); _selectedSongCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]); _selectedSongCell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]); _selectedSongCell.SetPrivateField("_bought", true); foreach (var icon in _selectedSongCell.GetComponentsInChildren <UnityEngine.UI.Image>().Where(x => x.name.StartsWith("LevelTypeIcon"))) { Destroy(icon.gameObject); } _playersReadyText = BeatSaberUI.CreateText(rectTransform, "0/0 players ready", new Vector2(0f, 5f)); _playersReadyText.rectTransform.anchorMin = new Vector2(0.5f, 0f); _playersReadyText.rectTransform.anchorMax = new Vector2(0.5f, 0f); _playersReadyText.alignment = TextAlignmentOptions.Center; _playersReadyText.fontSize = 5.5f; _cancelButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); (_cancelButton.transform as RectTransform).anchoredPosition = new Vector2(-30f, -25f); (_cancelButton.transform as RectTransform).sizeDelta = new Vector2(28f, 12f); _cancelButton.SetButtonText("CANCEL"); _cancelButton.ToggleWordWrapping(false); _cancelButton.SetButtonTextSize(5.5f); _cancelButton.onClick.AddListener(delegate() { discardPressed?.Invoke(); }); _cancelButton.gameObject.SetActive(isHost); _playButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); (_playButton.transform as RectTransform).anchoredPosition = new Vector2(30f, -25f); (_playButton.transform as RectTransform).sizeDelta = new Vector2(28f, 12f); _playButton.SetButtonText("PLAY"); _playButton.ToggleWordWrapping(false); _playButton.SetButtonTextSize(5.5f); _playButton.onClick.AddListener(delegate() { playPressed?.Invoke(_selectedSong, selectedCharacteristic, selectedDifficulty); }); var playGlow = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => x.name == "PlayButton").GetComponentsInChildren <RectTransform>().First(x => x.name == "GlowContainer"), _playButton.transform); //Let's add some glow! playGlow.transform.SetAsFirstSibling(); playGlow.GetComponentInChildren <UnityEngine.UI.Image>().color = new Color(0f, 0.7058824f, 1f, 0.7843137f); _playButton.gameObject.SetActive(isHost); _characteristicControl = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(0f, 34f), new Vector2(110f, 7f), _characteristicControl_didSelectCellEvent); _characteristicControl.SetTexts(new string[] { "Standard", "No Arrows", "One Saber" }); _characteristicControlBlocker = new GameObject("CharacteristicControlBlocker", typeof(RectTransform)).GetComponent <RectTransform>(); //"If it works it's not stupid" _characteristicControlBlocker.SetParent(rectTransform, false); _characteristicControlBlocker.gameObject.AddComponent <UnityEngine.UI.Image>().color = new Color(0f, 0f, 0f, 0f); _characteristicControlBlocker.anchorMin = new Vector2(0f, 1f); _characteristicControlBlocker.anchorMax = new Vector2(1f, 1f); _characteristicControlBlocker.sizeDelta = new Vector2(-30f, 7f); _characteristicControlBlocker.anchoredPosition = new Vector2(0f, -6f); _difficultyControl = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(0f, 24f), new Vector2(110f, 7f), _difficultyControl_didSelectCellEvent); _difficultyControl.SetTexts(new string[] { "Easy", "Normal", "Hard", "Expert", "Expert+" }); _difficultyControlBlocker = new GameObject("DifficultyControlBlocker", typeof(RectTransform)).GetComponent <RectTransform>(); //"If it works it's not stupid" _difficultyControlBlocker.SetParent(rectTransform, false); _difficultyControlBlocker.gameObject.AddComponent <UnityEngine.UI.Image>().color = new Color(0f, 0f, 0f, 0f); _difficultyControlBlocker.anchorMin = new Vector2(0f, 1f); _difficultyControlBlocker.anchorMax = new Vector2(1f, 1f); _difficultyControlBlocker.sizeDelta = new Vector2(-30f, 7f); _difficultyControlBlocker.anchoredPosition = new Vector2(0f, -16f); _progressBarRect = new GameObject("ProgressBar", typeof(RectTransform)).GetComponent <RectTransform>(); _progressBarRect.SetParent(rectTransform, false); _progressBarRect.anchorMin = new Vector2(0.5f, 0.5f); _progressBarRect.anchorMax = new Vector2(0.5f, 0.5f); _progressBarRect.anchoredPosition = new Vector2(0f, -7.5f); _progressBarRect.sizeDelta = new Vector2(46f, 5f); _progressBackground = new GameObject("Background", typeof(RectTransform), typeof(UnityEngine.UI.Image)).GetComponent <UnityEngine.UI.Image>(); _progressBackground.rectTransform.SetParent(_progressBarRect, false); _progressBackground.rectTransform.anchorMin = new Vector2(0f, 0f); _progressBackground.rectTransform.anchorMax = new Vector2(1f, 1f); _progressBackground.rectTransform.anchoredPosition = new Vector2(0f, 0f); _progressBackground.rectTransform.sizeDelta = new Vector2(0f, 0f); _progressBackground.sprite = Sprites.whitePixel; _progressBackground.material = Sprites.NoGlowMat; _progressBackground.color = new Color(1f, 1f, 1f, 0.075f); _progressBarImage = new GameObject("ProgressImage", typeof(RectTransform), typeof(UnityEngine.UI.Image)).GetComponent <UnityEngine.UI.Image>(); _progressBarImage.rectTransform.SetParent(_progressBarRect, false); _progressBarImage.rectTransform.anchorMin = new Vector2(0f, 0f); _progressBarImage.rectTransform.anchorMax = new Vector2(1f, 1f); _progressBarImage.rectTransform.anchoredPosition = new Vector2(0f, 0f); _progressBarImage.rectTransform.sizeDelta = new Vector2(0f, 0f); _progressBarImage.sprite = Sprites.whitePixel; _progressBarImage.material = Sprites.NoGlowMat; _progressBarImage.type = UnityEngine.UI.Image.Type.Filled; _progressBarImage.fillMethod = UnityEngine.UI.Image.FillMethod.Horizontal; _progressBarImage.fillAmount = 0.5f; _progressText = BeatSaberUI.CreateText(rectTransform, "0.0%", new Vector2(55f, -10f)); _progressText.rectTransform.SetParent(_progressBarRect, true); } _playButton.interactable = false; _progressBarRect.gameObject.SetActive(false); }
public void SetContent(MoreSongsFlowCoordinator sender, Song newSongInfo) { selectedCharacteristic = null; currentDifficulties = null; _currentSong = newSongInfo; songNameText.text = _currentSong.songName; if (_characteristicSegmentedDisplay == null) { _characteristicSegmentedDisplay = BeatSaberUI.CreateIconSegmentedControl(rectTransform, new Vector2(-40, .2f), new Vector2(70, 9f), delegate(int value) { SelectedCharacteristic(_currentSong.metadata.characteristics[value]); }); SetupCharacteristicDisplay(_characteristicSegmentedDisplay, _currentSong); } else { SetupCharacteristicDisplay(_characteristicSegmentedDisplay, _currentSong); } if (_difficultySegmentedDisplay == null) { _difficultySegmentedDisplay = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(-40, -9f), new Vector2(85, 8f), delegate(int value) { SelectedDifficulty(currentDifficulties[value]); }); _difficultySegmentedDisplay.transform.localScale = new Vector3(.8f, _difficultySegmentedDisplay.transform.localScale.y, _difficultySegmentedDisplay.transform.localScale.z); SetupDifficultyDisplay(_difficultySegmentedDisplay, _currentSong); } else { SetupDifficultyDisplay(_difficultySegmentedDisplay, _currentSong); } downloadsText.text = _currentSong.downloads.ToString(); _levelParams.bpm = (float)(_currentSong.plays); _levelParams.notesCount = (int)_currentSong.bpm; _levelParams.obstaclesCount = _currentSong.upVotes; _levelParams.bombsCount = _currentSong.downVotes; Polyglot.LocalizedTextMeshProUGUI localizer1 = difficulty1Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>(); if (localizer1 != null) { GameObject.Destroy(localizer1); } Polyglot.LocalizedTextMeshProUGUI localizer2 = difficulty2Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>(); if (localizer2 != null) { GameObject.Destroy(localizer2); } Polyglot.LocalizedTextMeshProUGUI localizer3 = difficulty3Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>(); if (localizer3 != null) { GameObject.Destroy(localizer3); } difficulty1Title.text = ""; difficulty2Title.text = ""; difficulty3Title.text = ""; difficulty1Text.text = ""; difficulty2Text.text = ""; difficulty3Text.text = ""; // difficulty1Text.text = (_currentSong.metadata.difficulties.expert || _currentSong.metadata.difficulties.expertPlus) ? "Yes" : "No"; // difficulty2Text.text = (_currentSong.metadata.difficulties.hard) ? "Yes" : "No"; // difficulty3Text.text = (_currentSong.metadata.difficulties.easy || _currentSong.metadata.difficulties.normal) ? "Yes" : "No"; StartCoroutine(LoadScripts.LoadSpriteCoroutine(_currentSong.coverURL, (cover) => { coverImage.texture = cover.texture; })); SetFavoriteState(PluginConfig.favoriteSongs.Any(x => x.Contains(_currentSong.hash))); SetDownloadState((SongDownloader.Instance.IsSongDownloaded(_currentSong) ? DownloadState.Downloaded : (sender.IsDownloadingSong(_currentSong) ? DownloadState.Downloading : DownloadState.NotDownloaded))); SetLoadingState(false); SelectedCharacteristic(_currentSong.metadata.characteristics[0]); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation && activationType == ActivationType.AddedToHierarchy) { _downloadListTableCellInstance = Resources.FindObjectsOfTypeAll <LeaderboardTableCell>().First(); _tabControl = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(0f, 31f), new Vector2(100f, 7f), _tabControl_didSelectCellEvent); _tabControl.SetTexts(new string[] { "Players", "Modifiers" }); #region Modifiers tab _modifiersTab = new GameObject("ModifiersTab", typeof(RectTransform)).GetComponent <RectTransform>(); _modifiersTab.SetParent(rectTransform, false); _modifiersTab.anchorMin = new Vector2(0f, 0f); _modifiersTab.anchorMax = new Vector2(1f, 1f); _modifiersTab.anchoredPosition = new Vector2(0f, 0f); _modifiersTab.sizeDelta = new Vector2(0f, 0f); _modifiersPanel = Instantiate(Resources.FindObjectsOfTypeAll <GameplayModifiersPanelController>().First(), rectTransform, false); _modifiersPanel.gameObject.SetActive(true); _modifiersPanel.transform.SetParent(_modifiersTab, false); (_modifiersPanel.transform as RectTransform).anchorMin = new Vector2(0.5f, 0f); (_modifiersPanel.transform as RectTransform).anchorMax = new Vector2(0.5f, 1f); (_modifiersPanel.transform as RectTransform).anchoredPosition = new Vector2(0f, -23f); (_modifiersPanel.transform as RectTransform).sizeDelta = new Vector2(120f, -23f); HoverHintController hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First(); foreach (var hint in _modifiersPanel.GetComponentsInChildren <HoverHint>()) { hint.SetPrivateField("_hoverHintController", hoverHintController); } _modifiersPanel.Init(GameplayModifiers.defaultModifiers); _modifiersPanel.Awake(); var modifierToggles = _modifiersPanel.GetPrivateField <GameplayModifierToggle[]>("_gameplayModifierToggles"); foreach (var item in modifierToggles) { item.toggle.onValueChanged.AddListener((enabled) => { gameplayModifiersChanged?.Invoke(); }); } _modifiersPanelBlocker = new GameObject("ModifiersPanelBlocker", typeof(RectTransform)).GetComponent <RectTransform>(); //"If it works it's not stupid" _modifiersPanelBlocker.SetParent(_modifiersTab, false); _modifiersPanelBlocker.gameObject.AddComponent <UnityEngine.UI.Image>().color = new Color(0f, 0f, 0f, 0f); _modifiersPanelBlocker.anchorMin = new Vector2(0f, 0f); _modifiersPanelBlocker.anchorMax = new Vector2(1f, 0f); _modifiersPanelBlocker.pivot = new Vector2(0.5f, 0f); _modifiersPanelBlocker.sizeDelta = new Vector2(-10f, 62f); _modifiersPanelBlocker.anchoredPosition = new Vector2(0f, 0f); #endregion #region Players tab _playersTab = new GameObject("PlayersTab", typeof(RectTransform)).GetComponent <RectTransform>(); _playersTab.SetParent(rectTransform, false); _playersTab.anchorMin = new Vector2(0f, 0f); _playersTab.anchorMax = new Vector2(1f, 1f); _playersTab.anchoredPosition = new Vector2(0f, 0f); _playersTab.sizeDelta = new Vector2(0f, 0f); _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Last(x => (x.name == "PageUpButton")), _playersTab, false); (_pageUpButton.transform as RectTransform).anchorMin = new Vector2(0.5f, 1f); (_pageUpButton.transform as RectTransform).anchorMax = new Vector2(0.5f, 1f); (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -18.5f); (_pageUpButton.transform as RectTransform).sizeDelta = new Vector2(40f, 6f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _playersTableView.PageScrollUp(); }); _pageUpButton.interactable = false; _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), _playersTab, false); (_pageDownButton.transform as RectTransform).anchorMin = new Vector2(0.5f, 0f); (_pageDownButton.transform as RectTransform).anchorMax = new Vector2(0.5f, 0f); (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 7f); (_pageDownButton.transform as RectTransform).sizeDelta = new Vector2(40f, 6f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _playersTableView.PageScrollDown(); }); _pageDownButton.interactable = false; RectTransform container = new GameObject("Content", typeof(RectTransform)).transform as RectTransform; container.SetParent(_playersTab, false); container.anchorMin = new Vector2(0.15f, 0.5f); container.anchorMax = new Vector2(0.85f, 0.5f); container.sizeDelta = new Vector2(0f, 49f); container.anchoredPosition = new Vector2(0f, -3f); var tableGameObject = new GameObject("CustomTableView"); tableGameObject.SetActive(false); _playersTableView = tableGameObject.AddComponent <TableView>(); _playersTableView.gameObject.AddComponent <RectMask2D>(); _playersTableView.transform.SetParent(container, false); _playersTableView.SetPrivateField("_isInitialized", false); _playersTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); tableGameObject.SetActive(true); (_playersTableView.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (_playersTableView.transform as RectTransform).anchorMax = new Vector2(1f, 1f); (_playersTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 0f); (_playersTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); ReflectionUtil.SetPrivateField(_playersTableView, "_pageUpButton", _pageUpButton); ReflectionUtil.SetPrivateField(_playersTableView, "_pageDownButton", _pageDownButton); _playersTableView.dataSource = this; #endregion _pingText = this.CreateText("PING: 0", new Vector2(75f, 22.5f)); _pingText.alignment = TextAlignmentOptions.Left; _tabControl_didSelectCellEvent(0); } else { for (int i = 0; i < _tableCells.Count; i++) { Destroy(_tableCells[i].gameObject); } _tableCells.Clear(); _playersList.Clear(); _playersTableView.ReloadData(); } if (activationType == ActivationType.AddedToHierarchy) { SetGameplayModifiers(GameplayModifiers.defaultModifiers); } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { _settingsSegments = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(0f, 31f), new Vector2(100f, 7f), SettingsCellSelected); _settingsSegments.SetTexts(new string[] { "General", "Voice" }); #region General Settings int generalSettingsIndex = 0; var avatarsInGame = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Show Avatars In Game", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); avatarsInGame.ValueChanged += (value) => { Config.Instance.ShowAvatarsInGame = value; }; avatarsInGame.Value = Config.Instance.ShowAvatarsInGame; _generalSettings.Add(avatarsInGame.gameObject); var blocksInGame = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Show Other Players Blocks", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); blocksInGame.ValueChanged += (value) => { Config.Instance.ShowOtherPlayersBlocks = value; }; blocksInGame.Value = Config.Instance.ShowOtherPlayersBlocks; _generalSettings.Add(blocksInGame.gameObject); var avatarsInRoom = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Show Avatars In Room", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); avatarsInRoom.ValueChanged += (value) => { Config.Instance.ShowAvatarsInRoom = value; }; avatarsInRoom.Value = Config.Instance.ShowAvatarsInRoom; _generalSettings.Add(avatarsInRoom.gameObject); var downloadAvatars = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Download Other Players Avatars", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); downloadAvatars.ValueChanged += (value) => { Config.Instance.DownloadAvatars = value; }; downloadAvatars.Value = Config.Instance.DownloadAvatars; _generalSettings.Add(downloadAvatars.gameObject); var separateAvatar = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Separate Avatar For Multiplayer", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); separateAvatar.ValueChanged += (value) => { InGameOnlineController.Instance.SetSeparatePublicAvatarState(value); }; separateAvatar.Value = Config.Instance.SeparateAvatarForMultiplayer; _generalSettings.Add(separateAvatar.gameObject); _publicAvatarOption = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Public Avatar", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); _publicAvatarOption.OnEnable(); _publicAvatarOption.ValueChanged += (e) => { InGameOnlineController.Instance.SetSeparatePublicAvatarHash(ModelSaberAPI.cachedAvatars.FirstOrDefault(x => x.Value == CustomAvatar.Plugin.Instance.AvatarLoader.Avatars[e]).Key); }; _publicAvatarOption.maxValue = CustomAvatar.Plugin.Instance.AvatarLoader.Avatars.Count - 1; _publicAvatarOption.textForValues = CustomAvatar.Plugin.Instance.AvatarLoader.Avatars.Select(x => (string.IsNullOrEmpty(x.Name) ? "" : x.Name)).ToArray(); if (ModelSaberAPI.cachedAvatars.TryGetValue(Config.Instance.PublicAvatarHash, out CustomAvatar.CustomAvatar avatar)) { _publicAvatarOption.Value = CustomAvatar.Plugin.Instance.AvatarLoader.Avatars.ToList().IndexOf(avatar); } else { if (ModelSaberAPI.isCalculatingHashes) { ModelSaberAPI.hashesCalculated -= UpdateSelectedAvatar; ModelSaberAPI.hashesCalculated += UpdateSelectedAvatar; } _publicAvatarOption.Value = 0; } _publicAvatarOption.UpdateText(); _generalSettings.Add(_publicAvatarOption.gameObject); var spectatorMode = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Spectator Mode", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); spectatorMode.Value = Config.Instance.SpectatorMode; spectatorMode.ValueChanged += (value) => { Config.Instance.SpectatorMode = value; }; _generalSettings.Add(spectatorMode.gameObject); var submitScoresOption = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Submit Scores", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); submitScoresOption.OnEnable(); submitScoresOption.ValueChanged += (e) => { Config.Instance.SubmitScores = e; }; submitScoresOption.maxValue = 2; submitScoresOption.textForValues = new string[] { "NEVER", "RANKED", "ALWAYS" }; submitScoresOption.Value = Config.Instance.SubmitScores; _generalSettings.Add(submitScoresOption.gameObject); #endregion #region Voice Settings int voiceSettingsIndex = 0; var voiceEnabled = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Enable Voice Chat", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); voiceEnabled.ValueChanged += (value) => { InGameOnlineController.Instance.ToggleVoiceChat(value); }; voiceEnabled.Value = Config.Instance.EnableVoiceChat; _voiceSettings.Add(voiceEnabled.gameObject); var voiceVolume = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Voice Chat Volume", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); voiceVolume.Value = (int)(Config.Instance.VoiceChatVolume * 20f); voiceVolume.ValueChanged += delegate(int value) { Config.Instance.VoiceChatVolume = value / 20f; InGameOnlineController.Instance.VoiceChatVolumeChanged(value / 20f); }; voiceVolume.maxValue = 20; voiceVolume.textForValues = Enumerable.Range(0, 21).Select(x => $"{x * 5}%").ToArray(); voiceVolume.UpdateText(); _voiceSettings.Add(voiceVolume.gameObject); var micEnabled = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Enable Microphone", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); micEnabled.Value = Config.Instance.MicEnabled; micEnabled.ValueChanged += delegate(bool value) { Config.Instance.MicEnabled = value; }; _voiceSettings.Add(micEnabled.gameObject); var spatialAudio = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Spatial Audio", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); spatialAudio.Value = Config.Instance.SpatialAudio; spatialAudio.ValueChanged += delegate(bool value) { Config.Instance.SpatialAudio = value; InGameOnlineController.Instance.VoiceChatSpatialAudioChanged(value); }; _voiceSettings.Add(spatialAudio.gameObject); var pushToTalk = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Push to Talk", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); pushToTalk.Value = Config.Instance.PushToTalk; pushToTalk.ValueChanged += delegate(bool value) { Config.Instance.PushToTalk = value; }; _voiceSettings.Add(pushToTalk.gameObject); var pushToTalkButton = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Push to Talk Button", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); pushToTalkButton.OnEnable(); pushToTalkButton.ValueChanged += (e) => { Config.Instance.PushToTalkButton = e; }; pushToTalkButton.maxValue = 7; pushToTalkButton.textForValues = new string[] { "L Grip", "R Grip", "L Trigger", "R Trigger", "L+R Grip", "L+R Trigger", "Any Grip", "Any Trigger" }; pushToTalkButton.Value = Config.Instance.PushToTalkButton; pushToTalkButton.UpdateText(); _voiceSettings.Add(pushToTalkButton.gameObject); #endregion SettingsCellSelected(0); } }