private void CreateTeamSelectionUi(float x, ref float y) { new TextComponent( _settingsGroup, new Vector2(x, y), new Vector2(200, 30), "Team Selection", FontManager.UIFontRegular, 18 ); y -= 35; var radioButtonBox = new RadioButtonBoxComponent( _settingsGroup, new Vector2(x, y), new Vector2(300, 35), new[] { "No team", "Moss", "Hive", "Grimm", "Lifeblood", }, 0 ); // Make it non-interactable by default radioButtonBox.SetInteractable(false); y -= 200; // If we connect, make the radio button box interactable _clientManager.RegisterOnConnect(() => radioButtonBox.SetInteractable(true)); // If we disconnect, we reset it and make it non-interactable _clientManager.RegisterOnDisconnect(() => { radioButtonBox.SetInteractable(false); radioButtonBox.Reset(); }); _clientManager.RegisterTeamSettingChange(() => { if (_clientGameSettings.TeamsEnabled) { // If the team settings becomes enabled, we make it interactable again radioButtonBox.SetInteractable(true); } else { // If the team settings becomes disabled, we reset it and make it non-interactable radioButtonBox.SetInteractable(false); radioButtonBox.Reset(); } }); radioButtonBox.SetOnChange(value => { if (!_clientGameSettings.TeamsEnabled) { return; } _clientManager.ChangeTeam((Team)value); }); }
private void CreateSettingsUI() { _settingsUiObject.SetActive(false); var x = Screen.width - 210f; var y = Screen.height - 75f; new TextComponent( _settingsUiObject, new Vector2(x, y), new Vector2(200, 30), "Team Selection", FontManager.UIFontRegular, 18 ); y -= 35; var radioButtonBox = new RadioButtonBoxComponent( _settingsUiObject, new Vector2(x, y), new Vector2(300, 35), new[] { "No team", "Moss", "Hive", "Grimm", "Lifeblood", }, 0 ); // Make it non-interactable by default radioButtonBox.SetInteractable(false); y -= 200; new ButtonComponent( _settingsUiObject, new Vector2(x, y), "Back" ).SetOnPress(() => { _settingsUiObject.SetActive(false); _connectUiObject.SetActive(true); }); // If we connect, make the radio button box interactable _clientManager.RegisterOnConnect(() => radioButtonBox.SetInteractable(true)); // If we disconnect, we reset it and make it non-interactable _clientManager.RegisterOnDisconnect(() => { radioButtonBox.SetInteractable(false); radioButtonBox.Reset(); }); _clientManager.RegisterTeamSettingChange(() => { if (_clientGameSettings.TeamsEnabled) { // If the team settings becomes enabled, we make it interactable again radioButtonBox.SetInteractable(true); } else { // If the team settings becomes disabled, we reset it and make it non-interactable radioButtonBox.SetInteractable(false); radioButtonBox.Reset(); } }); radioButtonBox.SetOnChange(value => { if (!_clientGameSettings.TeamsEnabled) { return; } _clientManager.ChangeTeam((Team)value); }); }
public ClientSettingsInterface( ModSettings modSettings, Game.Settings.GameSettings clientGameSettings, ComponentGroup settingsGroup, ComponentGroup connectGroup, PingInterface pingInterface ) { settingsGroup.SetActive(false); _clientGameSettings = clientGameSettings; var x = 1920f - 210f; var y = 1080f - 100f; new TextComponent( settingsGroup, new Vector2(x, y), new Vector2(240f, ButtonComponent.DefaultHeight), "Settings", UiManager.HeaderFontSize, alignment: TextAnchor.MiddleLeft ); var closeButton = new ButtonComponent( settingsGroup, new Vector2(x + 240f / 2f - ButtonComponent.DefaultHeight / 2f, y), new Vector2(ButtonComponent.DefaultHeight, ButtonComponent.DefaultHeight), "", TextureManager.CloseButtonBg, FontManager.UIFontRegular, UiManager.NormalFontSize ); closeButton.SetOnPress(() => { settingsGroup.SetActive(false); connectGroup.SetActive(true); }); y -= ButtonComponent.DefaultHeight + 30f; var skinSetting = new SettingsEntryInterface( settingsGroup, new Vector2(x, y), "Player skin ID", typeof(byte), 0, 0, o => { OnSkinIdChange?.Invoke((byte)o); }, true ); skinSetting.SetInteractable(false); _skinCondition = new CompoundCondition( () => skinSetting.SetInteractable(true), () => skinSetting.SetInteractable(false), false, true ); y -= InputComponent.DefaultHeight + 8f; new SettingsEntryInterface( settingsGroup, new Vector2(x, y), "Display ping", typeof(bool), false, modSettings.DisplayPing, o => { var newValue = (bool)o; modSettings.DisplayPing = newValue; pingInterface.SetEnabled(newValue); }, true ); y -= SettingsEntryInterface.CheckboxSize + 8f; var teamRadioButton = new RadioButtonBoxComponent( settingsGroup, new Vector2(x, y), "Team selection", new[] { "None", "Moss", "Hive", "Grimm", "Lifeblood", }, 0 ); // Make it non-interactable by default teamRadioButton.SetInteractable(false); _teamCondition = new CompoundCondition( () => teamRadioButton.SetInteractable(true), () => { teamRadioButton.SetInteractable(false); teamRadioButton.Reset(); }, false, false, true ); teamRadioButton.SetOnChange(value => { if (!_clientGameSettings.TeamsEnabled) { return; } OnTeamRadioButtonChange?.Invoke((Team)value); }); }