Пример #1
0
        private void CreateSkinSelectionUi(float x, ref float y)
        {
            var skinSetting = new SettingsEntryInterface(
                _settingsGroup,
                new Vector2(x, y),
                "Player skin ID",
                typeof(byte),
                0,
                0,
                o => { _clientManager.ChangeSkin((byte)o); }
                );

            y -= 100;

            new ButtonComponent(
                _settingsGroup,
                new Vector2(x, y),
                "Apply skin"
                ).SetOnPress(skinSetting.ApplySetting);

            y -= 40;
        }
Пример #2
0
        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);
            });
        }