protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { _backButton = BeatSaberUI.CreateBackButton(rectTransform); _backButton.onClick.AddListener(delegate() { didFinishEvent?.Invoke(); }); _nameKeyboard = BeatSaberUI.CreateViewController <CustomKeyboardViewController>(); _nameKeyboard.enterButtonPressed += NameEntered; _nameKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_nameKeyboard); }; _passwordKeyboard = BeatSaberUI.CreateViewController <CustomKeyboardViewController>(); _passwordKeyboard.allowEmptyInput = true; _passwordKeyboard.enterButtonPressed += PasswordEntered; _passwordKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_passwordKeyboard); }; _presetNameKeyboard = BeatSaberUI.CreateViewController <CustomKeyboardViewController>(); _presetNameKeyboard.enterButtonPressed += PresetNameEntered; _presetNameKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_presetNameKeyboard); }; _usePasswordToggle = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Use Password", new Vector2(0f, 11f)); _usePasswordToggle.ValueChanged += UsePasswordToggle_ValueChanged; _usePasswordToggle.Value = _usePassword; _songSelectionList = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Song Selection", new Vector2(0f, 3f)); _songSelectionList.ValueChanged += SongSelection_ValueChanged; _songSelectionList.maxValue = 1; _songSelectionList.Value = (int)_songSelectionType; _songSelectionList.textForValues = new string[] { "Manual", "Random" }; _songSelectionList.UpdateText(); _maxPlayersList = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Max Players", new Vector2(0f, -5f)); _maxPlayersList.ValueChanged += MaxPlayers_ValueChanged; _maxPlayersList.Value = _maxPlayers; _maxPlayersList.maxValue = 16; _maxPlayersList.textForValues = new string[] { "No limit" }; _maxPlayersList.UpdateText(); _resultsShowTimeList = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Results Show Time", new Vector2(0f, -13f)); _resultsShowTimeList.ValueChanged += ResultsShowTime_ValueChanged; _resultsShowTimeList.minValue = 5; _resultsShowTimeList.maxValue = 45; _resultsShowTimeList.Value = _resultsShowTime; _perPlayerDifficultyToggle = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Per player difficulty", new Vector2(0f, -21f)); _perPlayerDifficultyToggle.ValueChanged += PerPlayerDifficultyToggle_ValueChanged; _perPlayerDifficultyToggle.Value = _allowPerPlayerDifficulty; _roomName = $"{GetUserInfo.GetUserName()}'s room".ToUpper(); _nameText = BeatSaberUI.CreateText(rectTransform, _roomName, new Vector2(-22.5f, 30f)); _nameText.fontSize = 5f; _editNameButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _editNameButton.SetButtonText("EDIT NAME"); (_editNameButton.transform as RectTransform).sizeDelta = new Vector2(34f, 8f); (_editNameButton.transform as RectTransform).anchoredPosition = new Vector2(34f, 32f); _editNameButton.onClick.RemoveAllListeners(); _editNameButton.onClick.AddListener(delegate() { _nameKeyboard.inputString = _roomName; presentKeyboardEvent?.Invoke(_nameKeyboard); }); _roomPassword = ""; _passwordText = BeatSaberUI.CreateText(rectTransform, "ENTER PASSWORD", new Vector2(-22.5f, 20f)); _passwordText.fontSize = 5f; _editPasswordButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _editPasswordButton.SetButtonText("EDIT PASS"); (_editPasswordButton.transform as RectTransform).sizeDelta = new Vector2(34f, 8f); (_editPasswordButton.transform as RectTransform).anchoredPosition = new Vector2(34f, 22f); _editPasswordButton.onClick.RemoveAllListeners(); _editPasswordButton.onClick.AddListener(delegate() { _passwordKeyboard.inputString = _roomPassword; presentKeyboardEvent?.Invoke(_passwordKeyboard); }); _createRoomButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _createRoomButton.SetButtonText("Create Room"); (_createRoomButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_createRoomButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -32.5f); _createRoomButton.onClick.RemoveAllListeners(); _createRoomButton.onClick.AddListener(delegate() { CreatedRoom?.Invoke(new RoomSettings() { Name = _roomName, UsePassword = _usePassword, Password = _roomPassword, PerPlayerDifficulty = _allowPerPlayerDifficulty, MaxPlayers = _maxPlayers, SelectionType = _songSelectionType, ResultsShowTime = _resultsShowTime }); }); _createRoomButton.interactable = PluginUI.instance.roomCreationFlowCoordinator.CheckRequirements(); _savePresetButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _savePresetButton.SetButtonText("Save Preset"); (_savePresetButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_savePresetButton.transform as RectTransform).anchoredPosition = new Vector2(-32f, -32.5f); _savePresetButton.onClick.RemoveAllListeners(); _savePresetButton.onClick.AddListener(delegate() { _presetNameKeyboard.inputString = "NEW PRESET"; presentKeyboardEvent?.Invoke(_presetNameKeyboard); }); _loadPresetButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _loadPresetButton.SetButtonText("Load Preset"); (_loadPresetButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_loadPresetButton.transform as RectTransform).anchoredPosition = new Vector2(32f, -32.5f); _loadPresetButton.onClick.RemoveAllListeners(); _loadPresetButton.onClick.AddListener(delegate() { LoadPresetPressed?.Invoke(); }); } else { _songSelectionList.textForValues = new string[] { "Manual", "Random" }; _songSelectionList.UpdateText(); _maxPlayersList.textForValues = new string[] { "No limit" }; _maxPlayersList.UpdateText(); _createRoomButton.interactable = PluginUI.instance.roomCreationFlowCoordinator.CheckRequirements(); } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation && activationType == ActivationType.AddedToHierarchy) { _backButton = BeatSaberUI.CreateBackButton(rectTransform); _backButton.onClick.AddListener(delegate() { didFinishEvent?.Invoke(); }); _nameKeyboard = BeatSaberUI.CreateViewController <CustomKeyboardViewController>(); _nameKeyboard.enterButtonPressed += NameEntered; _nameKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_nameKeyboard); }; _passwordKeyboard = BeatSaberUI.CreateViewController <CustomKeyboardViewController>(); _passwordKeyboard.enterButtonPressed += PasswordEntered; _passwordKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_passwordKeyboard); }; _presetNameKeyboard = BeatSaberUI.CreateViewController <CustomKeyboardViewController>(); _presetNameKeyboard.enterButtonPressed += PresetNameEntered; _presetNameKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_presetNameKeyboard); }; _usePasswordToggle = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Use Password"); (_usePasswordToggle.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_usePasswordToggle.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_usePasswordToggle.transform as RectTransform).anchoredPosition = new Vector2(0f, 10f); _usePasswordToggle.ValueChanged += UsePasswordToggle_ValueChanged; _usePasswordToggle.Value = _usePassword; _songSelectionList = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Song Selection"); (_songSelectionList.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_songSelectionList.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_songSelectionList.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f); _songSelectionList.ValueChanged += SongSelection_ValueChanged; _songSelectionList.maxValue = 2; _songSelectionList.Value = (int)_songSelectionType; _songSelectionList.textForValues = new string[] { "Manual", "Random", "Voting" }; _songSelectionList.UpdateText(); _maxPlayersList = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Max Players"); (_maxPlayersList.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_maxPlayersList.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_maxPlayersList.transform as RectTransform).anchoredPosition = new Vector2(0f, -10f); _maxPlayersList.ValueChanged += MaxPlayers_ValueChanged; _maxPlayersList.Value = _maxPlayers; _maxPlayersList.maxValue = 16; _noFailToggle = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "No Fail Mode"); (_noFailToggle.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_noFailToggle.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_noFailToggle.transform as RectTransform).anchoredPosition = new Vector2(0f, -20f); _noFailToggle.ValueChanged += NoFailToggle_ValueChanged; _noFailToggle.Value = _noFailMode; _roomName = $"{GetUserInfo.GetUserName()}'s room".ToUpper(); _nameText = BeatSaberUI.CreateText(rectTransform, _roomName, new Vector2(-22.5f, 25f)); _nameText.fontSize = 5f; _editNameButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton"); _editNameButton.SetButtonText("EDIT NAME"); (_editNameButton.transform as RectTransform).sizeDelta = new Vector2(34f, 8f); (_editNameButton.transform as RectTransform).anchoredPosition = new Vector2(34f, 25f); _editNameButton.onClick.RemoveAllListeners(); _editNameButton.onClick.AddListener(delegate() { _nameKeyboard.inputString = _roomName; PluginUI.instance.roomCreationFlowCoordinator.PresentKeyboard(_nameKeyboard); }); _roomPassword = ""; _passwordText = BeatSaberUI.CreateText(rectTransform, "ENTER PASSWORD", new Vector2(-22.5f, 15f)); _passwordText.fontSize = 5f; _editPasswordButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton"); _editPasswordButton.SetButtonText("EDIT PASS"); (_editPasswordButton.transform as RectTransform).sizeDelta = new Vector2(34f, 8f); (_editPasswordButton.transform as RectTransform).anchoredPosition = new Vector2(34f, 15f); _editPasswordButton.onClick.RemoveAllListeners(); _editPasswordButton.onClick.AddListener(delegate() { _passwordKeyboard.inputString = _roomPassword; PluginUI.instance.roomCreationFlowCoordinator.PresentKeyboard(_passwordKeyboard); }); _createRoomButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton"); _createRoomButton.SetButtonText("Create Room"); (_createRoomButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_createRoomButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -32.5f); _createRoomButton.onClick.RemoveAllListeners(); _createRoomButton.onClick.AddListener(delegate() { CreatedRoom?.Invoke(new RoomSettings() { Name = _roomName, UsePassword = _usePassword, Password = _roomPassword, NoFail = _noFailMode, MaxPlayers = _maxPlayers, SelectionType = _songSelectionType }); }); _createRoomButton.interactable = PluginUI.instance.roomCreationFlowCoordinator.CheckRequirements(); _savePresetButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton"); _savePresetButton.SetButtonText("Save Preset"); (_savePresetButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_savePresetButton.transform as RectTransform).anchoredPosition = new Vector2(-32f, -32.5f); _savePresetButton.onClick.RemoveAllListeners(); _savePresetButton.onClick.AddListener(delegate() { _presetNameKeyboard.inputString = "NEW PRESET"; PluginUI.instance.roomCreationFlowCoordinator.PresentKeyboard(_presetNameKeyboard); }); _loadPresetButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton"); _loadPresetButton.SetButtonText("Load Preset"); (_loadPresetButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_loadPresetButton.transform as RectTransform).anchoredPosition = new Vector2(32f, -32.5f); _loadPresetButton.onClick.RemoveAllListeners(); _loadPresetButton.onClick.AddListener(delegate() { LoadPresetPressed?.Invoke(); }); } else { _songSelectionList.textForValues = new string[] { "Manual", "Random", "Voting" }; _songSelectionList.UpdateText(); _createRoomButton.interactable = PluginUI.instance.roomCreationFlowCoordinator.CheckRequirements(); } }