public MakeGhostRoleWindow()
        {
            RobustXamlLoader.Load(this);

            MakeSentientLabel.MinSize    = (150, 0);
            RoleEntityLabel.MinSize      = (150, 0);
            RoleNameLabel.MinSize        = (150, 0);
            RoleName.MinSize             = (300, 0);
            RoleDescriptionLabel.MinSize = (150, 0);
            RoleDescription.MinSize      = (300, 0);
            RoleRulesLabel.MinSize       = (150, 0);
            RoleRules.MinSize            = (300, 0);

            MakeButton.OnPressed += OnPressed;
        }
Esempio n. 2
0
        public ViewVariablesAddWindow(IEnumerable <string> entries, string title)
        {
            RobustXamlLoader.Load(this);

            Title = Loc.GetString(title);

            EntryItemList.OnItemSelected   += _ => RefreshAddButton();
            EntryItemList.OnItemDeselected += _ => RefreshAddButton();
            SearchLineEdit.OnTextChanged   += OnSearchTextChanged;
            AddButton.OnPressed            += OnAddButtonPressed;

            Populate(entries);

            SetSize = (200, 300);
        }
        public InstrumentMenu(InstrumentBoundUserInterface owner)
        {
            RobustXamlLoader.Load(this);
            IoCManager.InjectDependencies(this);

            _owner = owner;

            _owner.Instrument.OnMidiPlaybackEnded += InstrumentOnMidiPlaybackEnded;

            Title = _owner.Instrument.Owner.Name;

            LoopButton.Disabled        = !_owner.Instrument.IsMidiOpen;
            LoopButton.Pressed         = _owner.Instrument.LoopMidi;
            StopButton.Disabled        = !_owner.Instrument.IsMidiOpen;
            PlaybackSlider.MouseFilter = _owner.Instrument.IsMidiOpen ? MouseFilterMode.Pass : MouseFilterMode.Ignore;

            if (!_midiManager.IsAvailable)
            {
                Margin.AddChild(new PanelContainer
                {
                    MouseFilter   = MouseFilterMode.Stop,
                    PanelOverride = new StyleBoxFlat {
                        BackgroundColor = Color.Black.WithAlpha(0.90f)
                    },
                    Children =
                    {
                        new Label
                        {
                            Align               = Label.AlignMode.Center,
                            SizeFlagsVertical   = SizeFlags.ShrinkCenter,
                            SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
                            StyleClasses        = { StyleNano.StyleClassLabelBig },
                            Text = Loc.GetString("MIDI support is currently\nnot available on your platform.")
                        }
                    }
                });

                // We return early as to not give the buttons behavior.
                return;
            }

            InputButton.OnToggled         += MidiInputButtonOnOnToggled;
            FileButton.OnPressed          += MidiFileButtonOnOnPressed;
            LoopButton.OnToggled          += MidiLoopButtonOnOnToggled;
            StopButton.OnPressed          += MidiStopButtonOnPressed;
            PlaybackSlider.OnValueChanged += PlaybackSliderSeek;
            PlaybackSlider.OnKeyBindUp    += PlaybackSliderKeyUp;
        }
Esempio n. 4
0
    public DecalPlacerWindow(IPrototypeManager prototypeManager)
    {
        RobustXamlLoader.Load(this);

        _prototypeManager     = prototypeManager;
        _decalPlacementSystem = EntitySystem.Get <DecalPlacementSystem>();

        // This needs to be done in C# so we can have custom stuff passed in the constructor
        // and thus have a proper step size
        RotationSpinBox = new FloatSpinBox(90.0f, 0)
        {
            HorizontalExpand = true
        };
        SpinBoxContainer.AddChild(RotationSpinBox);

        Search.OnTextChanged      += _ => RefreshList();
        ColorPicker.OnColorPicked += color =>
        {
            _color = color;
            UpdateDecalPlacementInfo();
            RefreshList();
        };
        RotationSpinBox.OnValueChanged += args =>
        {
            _rotation = args.Value;
            UpdateDecalPlacementInfo();
        };
        EnableColor.OnToggled += args =>
        {
            _useColor = args.Pressed;
            UpdateDecalPlacementInfo();
            RefreshList();
        };
        EnableSnap.OnToggled += args =>
        {
            _snap = args.Pressed;
            UpdateDecalPlacementInfo();
        };
        EnableCleanable.OnToggled += args =>
        {
            _cleanable = args.Pressed;
            UpdateDecalPlacementInfo();
        };
        // i have to make this a member method for some reason and i have no idea why its only for spinboxes
        ZIndexSpinBox.ValueChanged += ZIndexSpinboxChanged;

        Populate();
    }
        public AdminbusTab()
        {
            RobustXamlLoader.Load(this);
            IoCManager.InjectDependencies(this);

            var adminManager = IoCManager.Resolve <IClientAdminManager>();

            // For the SpawnEntitiesButton and SpawnTilesButton we need to do the press manually
            // TODO: This will probably need some command check at some point
            SpawnEntitiesButton.OnPressed     += SpawnEntitiesButtonOnPressed;
            SpawnTilesButton.OnPressed        += SpawnTilesButtonOnOnPressed;
            SpawnDecalsButton.OnPressed       += SpawnDecalsButtonOnPressed;
            LoadGamePrototypeButton.OnPressed += LoadGamePrototypeButtonOnPressed;
            LoadGamePrototypeButton.Disabled   = !adminManager.HasFlag(AdminFlags.Query);
            LoadBlueprintsButton.Disabled      = !adminManager.HasFlag(AdminFlags.Mapping);
        }
Esempio n. 6
0
        public AudioTab()
        {
            RobustXamlLoader.Load(this);
            IoCManager.InjectDependencies(this);

            AmbienceCheckBox.Pressed   = _cfg.GetCVar(CCVars.AmbienceBasicEnabled);
            LobbyMusicCheckBox.Pressed = _cfg.GetCVar(CCVars.LobbyMusicEnabled);

            ApplyButton.OnPressed             += OnApplyButtonPressed;
            ResetButton.OnPressed             += OnResetButtonPressed;
            MasterVolumeSlider.OnValueChanged += OnMasterVolumeSliderChanged;
            AmbienceCheckBox.OnToggled        += OnAmbienceCheckToggled;
            LobbyMusicCheckBox.OnToggled      += OnLobbyMusicCheckToggled;

            Reset();
        }
        public UplinkWithdrawWindow(int tcCount)
        {
            RobustXamlLoader.Load(this);

            // setup withdraw slider
            WithdrawSlider.MinValue = 1;
            WithdrawSlider.MaxValue = tcCount;

            // and buttons
            ApplyButton.OnButtonDown += _ =>
            {
                OnWithdrawAttempt?.Invoke(WithdrawSlider.Value);
                Close();
            };
            CancelButton.OnButtonDown += _ => Close();
        }
Esempio n. 8
0
        public GhostRoleRulesWindow(string rules, Action <BaseButton.ButtonEventArgs> requestAction)
        {
            RobustXamlLoader.Load(this);
            var ghostRoleTime = _cfg.GetCVar(CCVars.GhostRoleTime);

            _timer = ghostRoleTime;

            if (ghostRoleTime > 0f)
            {
                RequestButton.Text = Loc.GetString("ghost-roles-window-request-role-button-timer", ("time", $"{_timer:0.0}"));
                TopBanner.SetMessage(FormattedMessage.FromMarkupPermissive(rules + "\n" + Loc.GetString("ghost-roles-window-rules-footer", ("time", ghostRoleTime))));
                RequestButton.Disabled = true;
            }

            RequestButton.OnPressed += requestAction;
        }
Esempio n. 9
0
        public GhostRolesEntry(string name, string description, IEnumerable <GhostRoleInfo> roles)
        {
            RobustXamlLoader.Load(this);

            Title.Text = name;
            Description.SetMessage(description);

            foreach (var role in roles)
            {
                var button = new GhostRoleEntryButtons();
                button.RequestButton.OnPressed += _ => OnRoleSelected?.Invoke(role);
                button.FollowButton.OnPressed  += _ => OnRoleFollow?.Invoke(role);

                Buttons.AddChild(button);
            }
        }
Esempio n. 10
0
        public LobbyGui(IEntityManager entityManager,
                        IClientPreferencesManager preferencesManager)
        {
            RobustXamlLoader.Load(this);

            ServerName.SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkCenter;

            CharacterPreview = new LobbyCharacterPreviewPanel(
                entityManager,
                preferencesManager)
            {
                SizeFlagsHorizontal = SizeFlags.None
            };

            CLeftPanelContainer.AddChild(CharacterPreview);
            CharacterPreview.SetPositionFirst();
        }
Esempio n. 11
0
        /// <summary>
        /// Create and initialize the dispenser UI client-side. Creates the basic layout,
        /// actual data isn't filled in until the server sends data about the dispenser.
        /// </summary>
        public ReagentDispenserWindow()
        {
            RobustXamlLoader.Load(this);
            IoCManager.InjectDependencies(this);

            var dispenseAmountGroup = new ButtonGroup();

            DispenseButton1.Group   = dispenseAmountGroup;
            DispenseButton5.Group   = dispenseAmountGroup;
            DispenseButton10.Group  = dispenseAmountGroup;
            DispenseButton15.Group  = dispenseAmountGroup;
            DispenseButton20.Group  = dispenseAmountGroup;
            DispenseButton25.Group  = dispenseAmountGroup;
            DispenseButton30.Group  = dispenseAmountGroup;
            DispenseButton50.Group  = dispenseAmountGroup;
            DispenseButton100.Group = dispenseAmountGroup;
        }
Esempio n. 12
0
        public LobbyGui(IEntityManager entityManager,
                        IClientPreferencesManager preferencesManager)
        {
            RobustXamlLoader.Load(this);

            ServerName.HorizontalExpand    = true;
            ServerName.HorizontalAlignment = HAlignment.Center;

            CharacterPreview = new LobbyCharacterPreviewPanel(
                entityManager,
                preferencesManager)
            {
                HorizontalAlignment = HAlignment.Left
            };

            CLeftPanelContainer.AddChild(CharacterPreview);
            CharacterPreview.SetPositionFirst();
        }
Esempio n. 13
0
    public PlayerTabEntry(string username, string character, string identity, string job, string antagonist, StyleBox styleBox, bool connected)
    {
        RobustXamlLoader.Load(this);

        UsernameLabel.Text = username;
        if (!connected)
        {
            UsernameLabel.StyleClasses.Add("Disabled");
        }
        JobLabel.Text       = job;
        CharacterLabel.Text = character;
        if (identity != character)
        {
            CharacterLabel.Text += $" [{identity}]";
        }
        AntagonistLabel.Text = antagonist;
        BackgroundColorPanel.PanelOverride = styleBox;
    }
Esempio n. 14
0
        public CharacterSetupGui(
            IEntityManager entityManager,
            IResourceCache resourceCache,
            IClientPreferencesManager preferencesManager,
            IPrototypeManager prototypeManager,
            IConfigurationManager configurationManager)
        {
            RobustXamlLoader.Load(this);
            _entityManager        = entityManager;
            _prototypeManager     = prototypeManager;
            _preferencesManager   = preferencesManager;
            _configurationManager = configurationManager;

            var panelTex = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
            var back     = new StyleBoxTexture
            {
                Texture  = panelTex,
                Modulate = new Color(37, 37, 42)
            };

            back.SetPatchMargin(StyleBox.Margin.All, 10);

            BackgroundPanel.PanelOverride = back;

            _createNewCharacterButton = new Button
            {
                Text = Loc.GetString("character-setup-gui-create-new-character-button"),
            };
            _createNewCharacterButton.OnPressed += args =>
            {
                preferencesManager.CreateCharacter(HumanoidCharacterProfile.Random());
                UpdateUI();
                args.Event.Handle();
            };

            _humanoidProfileEditor = new HumanoidProfileEditor(preferencesManager, prototypeManager, entityManager, configurationManager);
            _humanoidProfileEditor.OnProfileChanged += ProfileChanged;
            CharEditor.AddChild(_humanoidProfileEditor);

            UpdateUI();

            RulesButton.OnPressed += _ => new RulesAndInfoWindow().Open();
            preferencesManager.OnServerDataLoaded += UpdateUI;
        }
Esempio n. 15
0
        public AudioTab()
        {
            RobustXamlLoader.Load(this);
            IoCManager.InjectDependencies(this);

            LobbyMusicCheckBox.Pressed = _cfg.GetCVar(CCVars.LobbyMusicEnabled);

            ApplyButton.OnPressed               += OnApplyButtonPressed;
            ResetButton.OnPressed               += OnResetButtonPressed;
            MasterVolumeSlider.OnValueChanged   += OnMasterVolumeSliderChanged;
            MidiVolumeSlider.OnValueChanged     += OnMidiVolumeSliderChanged;
            AmbienceVolumeSlider.OnValueChanged += OnAmbienceVolumeSliderChanged;
            AmbienceSoundsSlider.OnValueChanged += OnAmbienceSoundsSliderChanged;
            LobbyMusicCheckBox.OnToggled        += OnLobbyMusicCheckToggled;

            AmbienceSoundsSlider.MinValue = _cfg.GetCVar(CCVars.MinMaxAmbientSourcesConfigured);
            AmbienceSoundsSlider.MaxValue = _cfg.GetCVar(CCVars.MaxMaxAmbientSourcesConfigured);

            Reset();
        }
Esempio n. 16
0
        public GasPressurePumpWindow()
        {
            RobustXamlLoader.Load(this);

            ToggleStatusButton.OnPressed += _ => SetPumpStatus(!PumpStatus);
            ToggleStatusButton.OnPressed += _ => ToggleStatusButtonPressed?.Invoke();

            PumpPressureOutputInput.OnTextChanged += _ => SetOutputPressureButton.Disabled = false;
            SetOutputPressureButton.OnPressed     += _ =>
            {
                PumpOutputPressureChanged?.Invoke(PumpPressureOutputInput.Text ??= "");
                SetOutputPressureButton.Disabled = true;
            };

            SetMaxPressureButton.OnPressed += _ =>
            {
                PumpPressureOutputInput.Text     = Atmospherics.MaxOutputPressure.ToString(CultureInfo.InvariantCulture);
                SetOutputPressureButton.Disabled = false;
            };
        }
        public GasVolumePumpWindow()
        {
            RobustXamlLoader.Load(this);

            ToggleStatusButton.OnPressed += _ => SetPumpStatus(!PumpStatus);
            ToggleStatusButton.OnPressed += _ => ToggleStatusButtonPressed?.Invoke();

            PumpTransferRateInput.OnTextChanged += _ => SetTransferRateButton.Disabled = false;
            SetTransferRateButton.OnPressed     += _ =>
            {
                PumpTransferRateChanged?.Invoke(PumpTransferRateInput.Text ??= "");
                SetTransferRateButton.Disabled = true;
            };

            SetMaxRateButton.OnPressed += _ =>
            {
                PumpTransferRateInput.Text     = Atmospherics.MaxTransferRate.ToString(CultureInfo.InvariantCulture);
                SetTransferRateButton.Disabled = false;
            };
        }
        public LauncherConnectingGui(LauncherConnecting state)
        {
            _state = state;

            RobustXamlLoader.Load(this);

            LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);

            Stylesheet = IoCManager.Resolve <IStylesheetManager>().SheetSpace;

            ReconnectButton.OnPressed += _ => _state.RetryConnect();
            // Redial shouldn't fail, but if it does, try a reconnect (maybe we're being run from debug)
            RedialButton.OnPressed += _ =>
            {
                if (!_state.Redial())
                {
                    _state.RetryConnect();
                }
            };
            RetryButton.OnPressed += _ => _state.RetryConnect();
            ExitButton.OnPressed  += _ => _state.Exit();

            var addr = state.Address;

            if (addr != null)
            {
                ConnectingAddress.Text = addr;
            }

            state.PageChanged += OnPageChanged;
            state.ConnectFailReasonChanged += ConnectFailReasonChanged;
            state.ConnectionStateChanged   += ConnectionStateChanged;

            ConnectionStateChanged(state.ConnectionState);

            // Redial flag setup
            var edim = IoCManager.Resolve <ExtendedDisconnectInformationManager>();

            edim.LastNetDisconnectedArgsChanged += LastNetDisconnectedArgsChanged;
            LastNetDisconnectedArgsChanged(edim.LastNetDisconnectedArgs);
        }
Esempio n. 19
0
        public ContextMenuItem(IUserInterfaceManager uiManager, IEntityManager entityManager, EntityUid entity)
        {
            IoCManager.InjectDependencies(this);
            RobustXamlLoader.Load(this);

            _uiManager = uiManager;

            NameLabel.Margin = new Thickness(2, 0, 4, 0);
            if (entityManager.TryGetComponent(entity, out _entityMetaData))
            {
                NameLabel.Text = _entityMetaData.EntityName;
            }

            Icon.Margin = new Thickness(2);
            if (entityManager.TryGetComponent(entity, out DMISpriteComponent sprite))
            {
                Icon.Texture = sprite.Icon.CurrentFrame;
            }

            OnMouseEntered += MouseEntered;
            OnMouseExited  += MouseExited;
        }
Esempio n. 20
0
    public AdminNotesLinePopup(SharedAdminNote note, bool showDelete, bool showEdit)
    {
        RobustXamlLoader.Load(this);

        NoteId = note.Id;
        DeleteButton.Visible = showDelete;
        EditButton.Visible   = showEdit;

        UserInterfaceManager.ModalRoot.AddChild(this);

        IdLabel.Text      = Loc.GetString("admin-notes-id", ("id", note.Id));
        RoundIdLabel.Text = note.Round == null
            ? Loc.GetString("admin-notes-round-id-unknown")
            : Loc.GetString("admin-notes-round-id", ("id", note.Round));

        CreatedByLabel.Text = Loc.GetString("admin-notes-created-by", ("author", note.CreatedByName));
        CreatedAtLabel.Text = Loc.GetString("admin-notes-created-at", ("date", note.CreatedAt.ToString("dd MMM yyyy HH:mm:ss")));
        EditedByLabel.Text  = Loc.GetString("admin-notes-last-edited-by", ("author", note.EditedByName));
        EditedAtLabel.Text  = Loc.GetString("admin-notes-last-edited-at", ("date", note.LastEditedAt.ToString("dd MMM yyyy HH:mm:ss")));

        EditButton.OnPressed   += EditPressed;
        DeleteButton.OnPressed += DeletePressed;
    }
Esempio n. 21
0
        public MainMenuControl(IResourceCache resCache, IConfigurationManager configMan)
        {
            RobustXamlLoader.Load(this);

            LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);

            LayoutContainer.SetAnchorPreset(VBox, LayoutContainer.LayoutPreset.TopRight);
            LayoutContainer.SetMarginRight(VBox, -25);
            LayoutContainer.SetMarginTop(VBox, 30);
            LayoutContainer.SetGrowHorizontal(VBox, LayoutContainer.GrowDirection.Begin);

            var logoTexture = resCache.GetResource <TextureResource>("/Textures/Logo/logo.png");

            Logo.Texture = logoTexture;

            var currentUserName = configMan.GetCVar(CVars.PlayerName);

            UsernameBox.Text = currentUserName;

            LayoutContainer.SetAnchorPreset(VersionLabel, LayoutContainer.LayoutPreset.BottomRight);
            LayoutContainer.SetGrowHorizontal(VersionLabel, LayoutContainer.GrowDirection.Begin);
            LayoutContainer.SetGrowVertical(VersionLabel, LayoutContainer.GrowDirection.Begin);
        }
        public MicrowaveMenu(MicrowaveBoundUserInterface owner)
        {
            RobustXamlLoader.Load(this);

            CookTimeButtonGroup = new ButtonGroup();

            for (var i = 0; i <= 30; i += 5)
            {
                var newButton = new MicrowaveCookTimeButton
                {
                    Text       = i == 0 ? Loc.GetString("microwave-menu-instant-button") : i.ToString(),
                    CookTime   = (uint)i,
                    TextAlign  = Label.AlignMode.Center,
                    ToggleMode = true,
                    Group      = CookTimeButtonGroup,
                };
                CookTimeButtonVbox.AddChild(newButton);
                newButton.OnToggled += args =>
                {
                    OnCookTimeSelected?.Invoke(args, newButton.GetPositionInParent());
                };
            }
        }
    public AdminLogsControl()
    {
        RobustXamlLoader.Load(this);

        TypeSearch.OnTextChanged   += TypeSearchChanged;
        PlayerSearch.OnTextChanged += PlayerSearchChanged;
        LogSearch.OnTextChanged    += LogSearchChanged;

        SelectAllTypesButton.OnPressed += SelectAllTypes;
        SelectNoTypesButton.OnPressed  += SelectNoTypes;

        SelectAllPlayersButton.OnPressed += SelectAllPlayers;
        SelectNoPlayersButton.OnPressed  += SelectNoPlayers;

        RoundSpinBox.IsValid       = i => i > 0 && i <= CurrentRound;
        RoundSpinBox.ValueChanged += RoundSpinBoxChanged;
        RoundSpinBox.InitDefaultButtons();

        ResetRoundButton.OnPressed += ResetRoundPressed;

        SetImpacts(Enum.GetValues <LogImpact>().OrderBy(impact => impact).ToArray());
        SetTypes(Enum.GetValues <LogType>());
    }
Esempio n. 24
0
        public MainMenuControl(IResourceCache resCache, IConfigurationManager configMan)
        {
            RobustXamlLoader.Load(this);

            Panel.PanelOverride   = new StyleBoxFlat(Color.Black);
            WIPLabel.FontOverride = new VectorFont(resCache.GetResource <FontResource>("/Fonts/NotoSans-Bold.ttf"), 32);

            LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);

            LayoutContainer.SetAnchorPreset(VBox, LayoutContainer.LayoutPreset.Center);
            LayoutContainer.SetGrowHorizontal(VBox, LayoutContainer.GrowDirection.Both);
            LayoutContainer.SetGrowVertical(VBox, LayoutContainer.GrowDirection.Both);

            var logoTexture = resCache.GetResource <TextureResource>("/OpenDream/Logo/logo.png");

            Logo.Texture = logoTexture;

            var currentUserName = configMan.GetCVar(CVars.PlayerName);

            UserNameBox.Text = currentUserName;

            AddressBoxProtected.Text = "127.0.0.1:25566";
        }
Esempio n. 25
0
        public GasMixerWindow()
        {
            RobustXamlLoader.Load(this);

            ToggleStatusButton.OnPressed += _ => SetMixerStatus(!MixerStatus);
            ToggleStatusButton.OnPressed += _ => ToggleStatusButtonPressed?.Invoke();

            MixerPressureOutputInput.OnTextChanged += _ => SetOutputPressureButton.Disabled = false;
            SetOutputPressureButton.OnPressed      += _ =>
            {
                MixerOutputPressureChanged?.Invoke(MixerPressureOutputInput.Text ??= "");
                SetOutputPressureButton.Disabled = true;
            };

            SetMaxPressureButton.OnPressed += _ =>
            {
                MixerPressureOutputInput.Text    = Atmospherics.MaxOutputPressure.ToString(CultureInfo.InvariantCulture);
                SetOutputPressureButton.Disabled = false;
            };

            MixerNodeOneInput.OnTextChanged += _ =>
            {
                SetMixerPercentageButton.Disabled = false;
                NodeOneLastEdited = true;
            };
            MixerNodeTwoInput.OnTextChanged += _ =>
            {
                SetMixerPercentageButton.Disabled = false;
                NodeOneLastEdited = false;
            };

            SetMixerPercentageButton.OnPressed += _ =>
            {
                MixerNodePercentageChanged?.Invoke(NodeOneLastEdited ? MixerNodeOneInput.Text ??= "" : MixerNodeTwoInput.Text ??= "");
                SetMixerPercentageButton.Disabled = true;
            };
        }
        /// <summary>
        /// Create and initialize the chem master UI client-side. Creates the basic layout,
        /// actual data isn't filled in until the server sends data about the chem master.
        /// </summary>
        public ChemMasterWindow()
        {
            RobustXamlLoader.Load(this);
            IoCManager.InjectDependencies(this);
            LabelLineEdit.OnTextEntered += e => OnLabelEntered?.Invoke(e.Text);

            //Pill type selection buttons, in total there are 20 pills.
            //Pill rsi file should have states named as pill1, pill2, and so on.
            var resourcePath  = new ResourcePath(PillsRsiPath);
            var pillTypeGroup = new ButtonGroup();

            PillTypeButtons = new Button[20];
            for (uint i = 0; i < PillTypeButtons.Length; i++)
            {
                //For every button decide which stylebase to have
                //Every row has 10 buttons
                String styleBase = StyleBase.ButtonOpenBoth;
                uint   modulo    = i % 10;
                if (i > 0 && modulo == 0)
                {
                    styleBase = StyleBase.ButtonOpenRight;
                }
                else if (i > 0 && modulo == 9)
                {
                    styleBase = StyleBase.ButtonOpenLeft;
                }
                else if (i == 0)
                {
                    styleBase = StyleBase.ButtonOpenRight;
                }

                //Generate buttons
                PillTypeButtons[i] = new Button
                {
                    Access       = AccessLevel.Public,
                    StyleClasses = { styleBase },
        public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager,
                                     IEntityManager entityManager)
        {
            RobustXamlLoader.Load(this);
            _random             = IoCManager.Resolve <IRobustRandom>();
            _prototypeManager   = prototypeManager;
            _entMan             = entityManager;
            _preferencesManager = preferencesManager;

            #region Left

            #region Randomize

            #endregion Randomize

            #region Name

            _nameEdit.OnTextChanged              += args => { SetName(args.Text); };
            _nameRandomButton.OnPressed          += args => RandomizeName();
            _randomizeEverythingButton.OnPressed += args => { RandomizeEverything(); };
            _warningLabel.SetMarkup($"[color=red]{Loc.GetString("humanoid-profile-editor-naming-rules-warning")}[/color]");

            #endregion Name

            #region Appearance

            _tabContainer.SetTabTitle(0, Loc.GetString("humanoid-profile-editor-appearance-tab"));

            #region Sex

            var sexButtonGroup = new ButtonGroup();

            _sexMaleButton.Group      = sexButtonGroup;
            _sexMaleButton.OnPressed += args =>
            {
                SetSex(Sex.Male);
                if (Profile?.Gender == Gender.Female)
                {
                    SetGender(Gender.Male);
                    UpdateGenderControls();
                }
            };

            _sexFemaleButton.Group      = sexButtonGroup;
            _sexFemaleButton.OnPressed += _ =>
            {
                SetSex(Sex.Female);

                if (Profile?.Gender == Gender.Male)
                {
                    SetGender(Gender.Female);
                    UpdateGenderControls();
                }
            };

            #endregion Sex

            #region Age

            _ageEdit.OnTextChanged += args =>
            {
                if (!int.TryParse(args.Text, out var newAge))
                {
                    return;
                }
                SetAge(newAge);
            };

            #endregion Age

            #region Gender

            _genderButton.AddItem(Loc.GetString("humanoid-profile-editor-pronouns-male-text"), (int)Gender.Male);
            _genderButton.AddItem(Loc.GetString("humanoid-profile-editor-pronouns-female-text"), (int)Gender.Female);
            _genderButton.AddItem(Loc.GetString("humanoid-profile-editor-pronouns-epicene-text"), (int)Gender.Epicene);
            _genderButton.AddItem(Loc.GetString("humanoid-profile-editor-pronouns-neuter-text"), (int)Gender.Neuter);

            _genderButton.OnItemSelected += args =>
            {
                _genderButton.SelectId(args.Id);
                SetGender((Gender)args.Id);
            };

            #endregion Gender

            #region Species

            _speciesList = prototypeManager.EnumeratePrototypes <SpeciesPrototype>().ToList();
            for (var i = 0; i < _speciesList.Count; i++)
            {
                CSpeciesButton.AddItem(_speciesList[i].Name, i);
            }

            CSpeciesButton.OnItemSelected += args =>
            {
                CSpeciesButton.SelectId(args.Id);
                SetSpecies(_speciesList[args.Id].ID);
                OnSkinColorOnValueChanged(CSkin);
            };

            #endregion Species

            #region Skin

            // 0 - 100, 0 being gold/yellowish and 100 being dark
            // HSV based
            //
            // 0 - 20 changes the hue
            // 20 - 100 changes the value
            // 0 is 45 - 20 - 100
            // 20 is 25 - 20 - 100
            // 100 is 25 - 100 - 20
            _skinColor.OnValueChanged += OnSkinColorOnValueChanged;

            #endregion

            #region Hair

            _hairPicker.Populate();

            _hairPicker.OnHairStylePicked += newStyle =>
            {
                if (Profile is null)
                {
                    return;
                }
                Profile = Profile.WithCharacterAppearance(
                    Profile.Appearance.WithHairStyleName(newStyle));
                IsDirty = true;
            };

            _hairPicker.OnHairColorPicked += newColor =>
            {
                if (Profile is null)
                {
                    return;
                }
                Profile = Profile.WithCharacterAppearance(
                    Profile.Appearance.WithHairColor(newColor));
                IsDirty = true;
            };

            _facialHairPicker.Populate();

            _facialHairPicker.OnHairStylePicked += newStyle =>
            {
                if (Profile is null)
                {
                    return;
                }
                Profile = Profile.WithCharacterAppearance(
                    Profile.Appearance.WithFacialHairStyleName(newStyle));
                IsDirty = true;
            };

            _facialHairPicker.OnHairColorPicked += newColor =>
            {
                if (Profile is null)
                {
                    return;
                }
                Profile = Profile.WithCharacterAppearance(
                    Profile.Appearance.WithFacialHairColor(newColor));
                IsDirty = true;
            };

            #endregion Hair

            #region Clothing

            _clothingButton.AddItem(Loc.GetString("humanoid-profile-editor-preference-jumpsuit"), (int)ClothingPreference.Jumpsuit);
            _clothingButton.AddItem(Loc.GetString("humanoid-profile-editor-preference-jumpskirt"), (int)ClothingPreference.Jumpskirt);

            _clothingButton.OnItemSelected += args =>
            {
                _clothingButton.SelectId(args.Id);
                SetClothing((ClothingPreference)args.Id);
            };

            #endregion Clothing

            #region Backpack

            _backpackButton.AddItem(Loc.GetString("humanoid-profile-editor-preference-backpack"), (int)BackpackPreference.Backpack);
            _backpackButton.AddItem(Loc.GetString("humanoid-profile-editor-preference-satchel"), (int)BackpackPreference.Satchel);
            _backpackButton.AddItem(Loc.GetString("humanoid-profile-editor-preference-duffelbag"), (int)BackpackPreference.Duffelbag);

            _backpackButton.OnItemSelected += args =>
            {
                _backpackButton.SelectId(args.Id);
                SetBackpack((BackpackPreference)args.Id);
            };

            #endregion Backpack

            #region Eyes

            _eyesPicker.OnEyeColorPicked += newColor =>
            {
                if (Profile is null)
                {
                    return;
                }
                Profile = Profile.WithCharacterAppearance(
                    Profile.Appearance.WithEyeColor(newColor));
                IsDirty = true;
            };

            #endregion Eyes

            #endregion Appearance

            #region Jobs

            _tabContainer.SetTabTitle(1, Loc.GetString("humanoid-profile-editor-jobs-tab"));

            _preferenceUnavailableButton.AddItem(
                Loc.GetString("humanoid-profile-editor-preference-unavailable-stay-in-lobby-button"),
                (int)PreferenceUnavailableMode.StayInLobby);
            _preferenceUnavailableButton.AddItem(
                Loc.GetString("humanoid-profile-editor-preference-unavailable-spawn-as-overflow-button",
                              ("overflowJob", Loc.GetString(SharedGameTicker.FallbackOverflowJobName))),
                (int)PreferenceUnavailableMode.SpawnAsOverflow);

            _preferenceUnavailableButton.OnItemSelected += args =>
            {
                _preferenceUnavailableButton.SelectId(args.Id);

                Profile = Profile?.WithPreferenceUnavailable((PreferenceUnavailableMode)args.Id);
                IsDirty = true;
            };

            _jobPriorities = new List <JobPrioritySelector>();
            _jobCategories = new Dictionary <string, BoxContainer>();

            var firstCategory = true;

            foreach (var job in prototypeManager.EnumeratePrototypes <JobPrototype>().OrderBy(j => j.Name))
            {
                if (!job.SetPreference)
                {
                    continue;
                }

                foreach (var department in job.Departments)
                {
                    if (!_jobCategories.TryGetValue(department, out var category))
                    {
                        category = new BoxContainer
                        {
                            Orientation = LayoutOrientation.Vertical,
                            Name        = department,
                            ToolTip     = Loc.GetString("humanoid-profile-editor-jobs-amount-in-department-tooltip",
                                                        ("departmentName", department))
                        };

                        if (firstCategory)
                        {
                            firstCategory = false;
                        }
                        else
                        {
                            category.AddChild(new Control
                            {
                                MinSize = new Vector2(0, 23),
                            });
                        }

                        category.AddChild(new PanelContainer
                        {
                            PanelOverride = new StyleBoxFlat {
                                BackgroundColor = Color.FromHex("#464966")
                            },
                            Children =
                            {
                                new Label
                                {
                                    Text = Loc.GetString("humanoid-profile-editor-department-jobs-label",
                                                         ("departmentName", department))
                                }
                            }
                        });
 public InfoControlsSection()
 {
     RobustXamlLoader.Load(this);
 }
Esempio n. 29
0
 public RadarConsoleWindow()
 {
     RobustXamlLoader.Load(this);
 }
    public DecalPlacerWindow(IPrototypeManager prototypeManager)
    {
        RobustXamlLoader.Load(this);

        _prototypeManager     = prototypeManager;
        _decalPlacementSystem = EntitySystem.Get <DecalPlacementSystem>();

        // This needs to be done in C# so we can have custom stuff passed in the constructor
        // and thus have a proper step size
        RotationSpinBox = new FloatSpinBox(90.0f, 0)
        {
            HorizontalExpand = true
        };
        SpinBoxContainer.AddChild(RotationSpinBox);

        Search.OnTextChanged       += _ => RefreshList();
        ColorPicker.OnColorChanged += OnColorPicked;

        PickerOpen.OnPressed += _ =>
        {
            if (_picker is null)
            {
                _picker = new PaletteColorPicker();
                _picker.OpenToLeft();
                _picker.PaletteList.OnItemSelected += args =>
                {
                    var color = (args.ItemList.GetSelected().First().Metadata as Color?) !.Value;
                    ColorPicker.Color = color;
                    OnColorPicked(color);
                };
            }
            else
            {
                if (_picker.IsOpen)
                {
                    _picker.Close();
                }
                else
                {
                    _picker.Open();
                }
            }
        };

        RotationSpinBox.OnValueChanged += args =>
        {
            _rotation = args.Value;
            UpdateDecalPlacementInfo();
        };
        EnableColor.OnToggled += args =>
        {
            _useColor = args.Pressed;
            UpdateDecalPlacementInfo();
            RefreshList();
        };
        EnableSnap.OnToggled += args =>
        {
            _snap = args.Pressed;
            UpdateDecalPlacementInfo();
        };
        EnableCleanable.OnToggled += args =>
        {
            _cleanable = args.Pressed;
            UpdateDecalPlacementInfo();
        };
        // i have to make this a member method for some reason and i have no idea why its only for spinboxes
        ZIndexSpinBox.ValueChanged += ZIndexSpinboxChanged;

        Populate();
    }