コード例 #1
0
        private void InitializeComponent()
        {
            RobustXamlLoader.Load(this);

            TabContainer.SetTabTitle(DebugConsole, "Debug Console");
            TabContainer.SetTabTitle(UI, "User Interface");
        }
コード例 #2
0
        public OptionsMenu()
        {
            SetSize = MinSize = (800, 450);
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("ui-options-title");

            GraphicsControl  graphicsControl;
            KeyRebindControl rebindControl;
            AudioControl     audioControl;

            var tabs = new TabContainer
            {
                Children =
                {
                    (graphicsControl = new GraphicsControl(_configManager)),
                    (rebindControl   = new KeyRebindControl()),
                    (audioControl    = new AudioControl(_configManager,     _clydeAudio)),
                }
            };

            TabContainer.SetTabTitle(graphicsControl, Loc.GetString("ui-options-tab-graphics"));
            TabContainer.SetTabTitle(rebindControl, Loc.GetString("ui-options-tab-controls"));
            TabContainer.SetTabTitle(audioControl, Loc.GetString("ui-options-tab-audio"));

            Contents.AddChild(tabs);
        }
コード例 #3
0
        public InfoWindow()
        {
            IoCManager.InjectDependencies(this);

            optionsMenu = new OptionsMenu();

            Title = Loc.GetString("ui-info-title");

            var rootContainer = new TabContainer();

            var rulesList = new ScrollContainer
            {
                HScrollEnabled = false
            };
            var tutorialList = new ScrollContainer
            {
                HScrollEnabled = false
            };


            rootContainer.AddChild(rulesList);
            rootContainer.AddChild(tutorialList);

            TabContainer.SetTabTitle(rulesList, Loc.GetString("ui-info-tab-rules"));
            TabContainer.SetTabTitle(tutorialList, Loc.GetString("ui-info-tab-tutorial"));

            PopulateRules(rulesList);
            PopulateTutorial(tutorialList);

            Contents.AddChild(rootContainer);

            SetSize = (650, 650);
        }
コード例 #4
0
        public CreditsWindow()
        {
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("Credits");

            var rootContainer = new TabContainer();

            var patronsList = new ScrollContainer();
            var ss14ContributorsList = new ScrollContainer();
            var licensesList = new ScrollContainer();

            rootContainer.AddChild(ss14ContributorsList);
            rootContainer.AddChild(patronsList);
            rootContainer.AddChild(licensesList);

            TabContainer.SetTabTitle(patronsList, Loc.GetString("Patrons"));
            TabContainer.SetTabTitle(ss14ContributorsList, Loc.GetString("Credits"));
            TabContainer.SetTabTitle(licensesList, Loc.GetString("Open Source Licenses"));

            PopulatePatronsList(patronsList);
            PopulateCredits(ss14ContributorsList);
            PopulateLicenses(licensesList);

            Contents.AddChild(rootContainer);

            CustomMinimumSize = (650, 450);
        }
コード例 #5
0
        public OptionsMenu()
        {
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("Game Options");

            GraphicsControl  graphicsControl;
            KeyRebindControl rebindControl;
            AudioControl     audioControl;

            var tabs = new TabContainer
            {
                Children =
                {
                    (graphicsControl = new GraphicsControl(_configManager)),
                    (rebindControl   = new KeyRebindControl()),
                    (audioControl    = new AudioControl(_configManager)),
                }
            };

            TabContainer.SetTabTitle(graphicsControl, Loc.GetString("Graphics"));
            TabContainer.SetTabTitle(rebindControl, Loc.GetString("Controls"));
            TabContainer.SetTabTitle(audioControl, Loc.GetString("Audio"));

            Contents.AddChild(tabs);
        }
コード例 #6
0
        protected virtual void LoadMorphs(IMorphSet morphSet)
        {
            Ensure.That(morphSet, nameof(morphSet)).IsNotNull();

            ClearMorphs();

            var index = 0;

            foreach (var group in morphSet.Groups)
            {
                var node = GroupPanelScene.Instance();

                node.OfType <MorphGroupPanelFactory>().HeadOrNone().Match(
                    tab =>
                {
                    tab.Group  = Some(group);
                    tab.Morphs = Some(morphSet);

                    TabContainer.AddChild(node);
                    TabContainer.SetTabTitle(index, group.DisplayName);

                    index++;
                },
                    () => Logger.LogWarning("Invalid group panel scene."));
            }
        }
コード例 #7
0
            public Menu(PermissionsEui ui)
            {
                _ui   = ui;
                Title = Loc.GetString("permissions-eui-menu-title");

                var tab = new TabContainer();

                AddAdminButton = new Button
                {
                    Text = Loc.GetString("permissions-eui-menu-add-admin-button"),
                    HorizontalAlignment = HAlignment.Right
                };

                AddAdminRankButton = new Button
                {
                    Text = Loc.GetString("permissions-eui-menu-add-admin-rank-button"),
                    HorizontalAlignment = HAlignment.Right
                };

                AdminsList = new GridContainer {
                    Columns = 5, VerticalExpand = true
                };
                var adminVBox = new BoxContainer
                {
                    Orientation = LayoutOrientation.Vertical,
                    Children    = { new ScrollContainer()
                                    {
                                        VerticalExpand = true, Children = { AdminsList }
                                    }, AddAdminButton },
                };

                TabContainer.SetTabTitle(adminVBox, Loc.GetString("permissions-eui-menu-admins-tab-title"));

                AdminRanksList = new GridContainer {
                    Columns = 3, VerticalExpand = true
                };
                var rankVBox = new BoxContainer
                {
                    Orientation = LayoutOrientation.Vertical,
                    Children    = { new ScrollContainer()
                                    {
                                        VerticalExpand = true, Children = { AdminRanksList }
                                    }, AddAdminRankButton }
                };

                TabContainer.SetTabTitle(rankVBox, Loc.GetString("permissions-eui-menu-admin-ranks-tab-title"));

                tab.AddChild(adminVBox);
                tab.AddChild(rankVBox);

                Contents.AddChild(tab);
            }
コード例 #8
0
            public Menu(PermissionsEui ui)
            {
                _ui   = ui;
                Title = Loc.GetString("Permissions Panel");

                var tab = new TabContainer();

                AddAdminButton = new Button
                {
                    Text = Loc.GetString("Add Admin"),
                    HorizontalAlignment = HAlignment.Right
                };

                AddAdminRankButton = new Button
                {
                    Text = Loc.GetString("Add Admin Rank"),
                    HorizontalAlignment = HAlignment.Right
                };

                AdminsList = new GridContainer {
                    Columns = 5, VerticalExpand = true
                };
                var adminVBox = new VBoxContainer
                {
                    Children = { AdminsList, AddAdminButton },
                };

                TabContainer.SetTabTitle(adminVBox, Loc.GetString("Admins"));

                AdminRanksList = new GridContainer {
                    Columns = 3
                };
                var rankVBox = new VBoxContainer
                {
                    Children = { AdminRanksList, AddAdminRankButton }
                };

                TabContainer.SetTabTitle(rankVBox, Loc.GetString("Admin Ranks"));

                tab.AddChild(adminVBox);
                tab.AddChild(rankVBox);

                Contents.AddChild(tab);
            }
コード例 #9
0
        public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager)
        {
            _random = IoCManager.Resolve <IRobustRandom>();

            _preferencesManager = preferencesManager;

            var margin = new MarginContainer
            {
                MarginTopOverride    = 10,
                MarginBottomOverride = 10,
                MarginLeftOverride   = 10,
                MarginRightOverride  = 10
            };

            AddChild(margin);

            var vBox = new VBoxContainer();

            margin.AddChild(vBox);

            var middleContainer = new HBoxContainer
            {
                SeparationOverride = 10
            };

            vBox.AddChild(middleContainer);

            var leftColumn = new VBoxContainer();

            middleContainer.AddChild(leftColumn);

            #region Randomize

            {
                var panel = HighlightedContainer();
                var randomizeEverythingButton = new Button
                {
                    Text = Loc.GetString("Randomize everything")
                };
                randomizeEverythingButton.OnPressed += args => { RandomizeEverything(); };
                panel.AddChild(randomizeEverythingButton);
                leftColumn.AddChild(panel);
            }

            #endregion Randomize

            #region Name

            {
                var panel = HighlightedContainer();
                var hBox  = new HBoxContainer
                {
                    SizeFlagsVertical = SizeFlags.FillExpand
                };
                var nameLabel = new Label {
                    Text = Loc.GetString("Name:")
                };
                _nameEdit = new LineEdit
                {
                    CustomMinimumSize = (270, 0),
                    SizeFlagsVertical = SizeFlags.ShrinkCenter
                };
                _nameEdit.OnTextChanged += args => { SetName(args.Text); };
                var nameRandomButton = new Button
                {
                    Text = Loc.GetString("Randomize"),
                };
                nameRandomButton.OnPressed += args => RandomizeName();
                hBox.AddChild(nameLabel);
                hBox.AddChild(_nameEdit);
                hBox.AddChild(nameRandomButton);
                panel.AddChild(hBox);
                leftColumn.AddChild(panel);
            }

            #endregion Name

            var tabContainer = new TabContainer {
                SizeFlagsVertical = SizeFlags.FillExpand
            };
            vBox.AddChild(tabContainer);

            #region Appearance

            {
                var appearanceVBox = new VBoxContainer();
                tabContainer.AddChild(appearanceVBox);
                tabContainer.SetTabTitle(0, Loc.GetString("Appearance"));

                var sexAndAgeRow = new HBoxContainer
                {
                    SeparationOverride = 10
                };

                appearanceVBox.AddChild(sexAndAgeRow);

                #region Sex

                {
                    var panel    = HighlightedContainer();
                    var hBox     = new HBoxContainer();
                    var sexLabel = new Label {
                        Text = Loc.GetString("Sex:")
                    };

                    var sexButtonGroup = new ButtonGroup();

                    _sexMaleButton = new Button
                    {
                        Text  = Loc.GetString("Male"),
                        Group = sexButtonGroup
                    };
                    _sexMaleButton.OnPressed += args => { SetSex(Sex.Male); };
                    _sexFemaleButton          = new Button
                    {
                        Text  = Loc.GetString("Female"),
                        Group = sexButtonGroup
                    };
                    _sexFemaleButton.OnPressed += args => { SetSex(Sex.Female); };
                    hBox.AddChild(sexLabel);
                    hBox.AddChild(_sexMaleButton);
                    hBox.AddChild(_sexFemaleButton);
                    panel.AddChild(hBox);
                    sexAndAgeRow.AddChild(panel);
                }

                #endregion Sex

                #region Age

                {
                    var panel    = HighlightedContainer();
                    var hBox     = new HBoxContainer();
                    var ageLabel = new Label {
                        Text = Loc.GetString("Age:")
                    };
                    _ageEdit = new LineEdit {
                        CustomMinimumSize = (40, 0)
                    };
                    _ageEdit.OnTextChanged += args =>
                    {
                        if (!int.TryParse(args.Text, out var newAge))
                        {
                            return;
                        }
                        SetAge(newAge);
                    };
                    hBox.AddChild(ageLabel);
                    hBox.AddChild(_ageEdit);
                    panel.AddChild(hBox);
                    sexAndAgeRow.AddChild(panel);
                }

                #endregion Age

                #region Hair

                {
                    var panel = HighlightedContainer();
                    panel.SizeFlagsHorizontal = SizeFlags.None;
                    var hairHBox = new HBoxContainer();

                    _hairPicker = new HairStylePicker();
                    _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 = new FacialHairStylePicker();
                    _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;
                    };

                    hairHBox.AddChild(_hairPicker);
                    hairHBox.AddChild(_facialHairPicker);

                    panel.AddChild(hairHBox);
                    appearanceVBox.AddChild(panel);
                }

                #endregion Hair
            }

            #endregion

            #region Jobs

            {
                var jobList = new VBoxContainer();

                var jobVBox = new VBoxContainer
                {
                    Children =
                    {
                        (_preferenceUnavailableButton = new OptionButton()),
                        new ScrollContainer
                        {
                            SizeFlagsVertical = SizeFlags.FillExpand,
                            Children          =
                            {
                                jobList
                            }
                        }
                    }
                };

                tabContainer.AddChild(jobVBox);

                tabContainer.SetTabTitle(1, Loc.GetString("Jobs"));

                _preferenceUnavailableButton.AddItem(
                    Loc.GetString("Stay in lobby if preference unavailable."),
                    (int)PreferenceUnavailableMode.StayInLobby);
                _preferenceUnavailableButton.AddItem(
                    Loc.GetString("Be an {0} if preference unavailable.",
                                  Loc.GetString(SharedGameTicker.OverflowJobName)),
                    (int)PreferenceUnavailableMode.SpawnAsOverflow);

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

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

                _jobPriorities = new List <JobPrioritySelector>();

                foreach (var job in prototypeManager.EnumeratePrototypes <JobPrototype>().OrderBy(j => j.Name))
                {
                    var selector = new JobPrioritySelector(job);
                    jobList.AddChild(selector);
                    _jobPriorities.Add(selector);

                    selector.PriorityChanged += priority =>
                    {
                        Profile = Profile.WithJobPriority(job.ID, priority);
                        IsDirty = true;

                        if (priority == JobPriority.High)
                        {
                            // Lower any other high priorities to medium.
                            foreach (var jobSelector in _jobPriorities)
                            {
                                if (jobSelector != selector && jobSelector.Priority == JobPriority.High)
                                {
                                    jobSelector.Priority = JobPriority.Medium;
                                    Profile = Profile.WithJobPriority(jobSelector.Job.ID, JobPriority.Medium);
                                }
                            }
                        }
                    };
                }
            }

            #endregion

            #region Antags

            {
                var antagList = new VBoxContainer();

                var antagVBox = new VBoxContainer
                {
                    Children =
                    {
                        new ScrollContainer
                        {
                            SizeFlagsVertical = SizeFlags.FillExpand,
                            Children          =
                            {
                                antagList
                            }
                        }
                    }
                };

                tabContainer.AddChild(antagVBox);

                tabContainer.SetTabTitle(2, Loc.GetString("Antags"));

                _antagPreferences = new List <AntagPreferenceSelector>();

                foreach (var antag in prototypeManager.EnumeratePrototypes <AntagPrototype>().OrderBy(a => a.Name))
                {
                    if (!antag.SetPreference)
                    {
                        continue;
                    }
                    var selector = new AntagPreferenceSelector(antag);
                    antagList.AddChild(selector);
                    _antagPreferences.Add(selector);

                    selector.PreferenceChanged += preference =>
                    {
                        Profile = Profile.WithAntagPreference(antag.ID, preference);
                        IsDirty = true;
                    };
                }
            }

            #endregion

            var rightColumn = new VBoxContainer();
            middleContainer.AddChild(rightColumn);

            #region Import/Export

            {
                var panelContainer = HighlightedContainer();
                var hBox           = new HBoxContainer();
                var importButton   = new Button
                {
                    Text     = Loc.GetString("Import"),
                    Disabled = true,
                    ToolTip  = "Not yet implemented!"
                };
                var exportButton = new Button
                {
                    Text     = Loc.GetString("Export"),
                    Disabled = true,
                    ToolTip  = "Not yet implemented!"
                };
                hBox.AddChild(importButton);
                hBox.AddChild(exportButton);
                panelContainer.AddChild(hBox);
                rightColumn.AddChild(panelContainer);
            }

            #endregion Import/Export

            #region Save

            {
                var panel = HighlightedContainer();
                _saveButton = new Button
                {
                    Text = Loc.GetString("Save"),
                    SizeFlagsHorizontal = SizeFlags.ShrinkCenter
                };
                _saveButton.OnPressed += args => { Save(); };
                panel.AddChild(_saveButton);
                rightColumn.AddChild(panel);
            }

            #endregion Save

            if (preferencesManager.ServerDataLoaded)
            {
                LoadServerData();
            }

            preferencesManager.OnServerDataLoaded += LoadServerData;

            IsDirty = false;
        }
コード例 #10
0
        public override void Initialize(DefaultWindow window, object obj)
        {
            _entity = (EntityUid)obj;

            var scrollContainer = new ScrollContainer();

            //scrollContainer.SetAnchorPreset(Control.LayoutPreset.Wide, true);
            window.Contents.AddChild(scrollContainer);
            var vBoxContainer = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            scrollContainer.AddChild(vBoxContainer);

            // Handle top bar displaying type and ToString().
            {
                Control top;
                var     stringified = PrettyPrint.PrintUserFacingWithType(obj, out var typeStringified);
                if (typeStringified != "")
                {
                    //var smallFont = new VectorFont(_resourceCache.GetResource<FontResource>("/Fonts/CALIBRI.TTF"), 10);
                    // Custom ToString() implementation.
                    var headBox = new BoxContainer
                    {
                        Orientation        = LayoutOrientation.Vertical,
                        SeparationOverride = 0
                    };
                    headBox.AddChild(new Label {
                        Text = stringified, ClipText = true
                    });
                    headBox.AddChild(new Label
                    {
                        Text = typeStringified,
                        //    FontOverride = smallFont,
                        FontColorOverride = Color.DarkGray,
                        ClipText          = true
                    });
                    top = headBox;
                }
                else
                {
                    top = new Label {
                        Text = stringified
                    };
                }

                if (_entityManager.TryGetComponent(_entity, out ISpriteComponent? sprite))
                {
                    var hBox = new BoxContainer
                    {
                        Orientation = LayoutOrientation.Horizontal
                    };
                    top.HorizontalExpand = true;
                    hBox.AddChild(top);
                    hBox.AddChild(new SpriteView {
                        Sprite = sprite, OverrideDirection = Direction.South
                    });
                    vBoxContainer.AddChild(hBox);
                }
                else
                {
                    vBoxContainer.AddChild(top);
                }
            }

            _tabs = new TabContainer();
            _tabs.OnTabChanged += _tabsOnTabChanged;
            vBoxContainer.AddChild(_tabs);

            var clientVBox = new BoxContainer
            {
                Orientation        = LayoutOrientation.Vertical,
                SeparationOverride = 0
            };

            _tabs.AddChild(clientVBox);
            _tabs.SetTabTitle(TabClientVars, Loc.GetString("view-variable-instance-entity-client-variables-tab-title"));

            var first = true;

            foreach (var group in LocalPropertyList(obj, ViewVariablesManager, _robustSerializer))
            {
                ViewVariablesTraitMembers.CreateMemberGroupHeader(
                    ref first,
                    TypeAbbreviation.Abbreviate(group.Key),
                    clientVBox);

                foreach (var control in group)
                {
                    clientVBox.AddChild(control);
                }
            }

            _clientComponents = new BoxContainer
            {
                Orientation        = LayoutOrientation.Vertical,
                SeparationOverride = 0
            };
            _tabs.AddChild(_clientComponents);
            _tabs.SetTabTitle(TabClientComponents, Loc.GetString("view-variable-instance-entity-client-components-tab-title"));

            PopulateClientComponents();

            if (!_entity.IsClientSide())
            {
                _serverVariables = new BoxContainer
                {
                    Orientation        = LayoutOrientation.Vertical,
                    SeparationOverride = 0
                };
                _tabs.AddChild(_serverVariables);
                _tabs.SetTabTitle(TabServerVars, Loc.GetString("view-variable-instance-entity-server-variables-tab-title"));

                _serverComponents = new BoxContainer
                {
                    Orientation        = LayoutOrientation.Vertical,
                    SeparationOverride = 0
                };
                _tabs.AddChild(_serverComponents);
                _tabs.SetTabTitle(TabServerComponents, Loc.GetString("view-variable-instance-entity-server-components-tab-title"));

                PopulateServerComponents(false);
            }
        }
コード例 #11
0
 public InfoPanel(string name)
 {
     PanelName = name;
     TabContainer.SetTabTitle(this, name);
 }
コード例 #12
0
        public override void Initialize(SS14Window window, object obj)
        {
            _entity = (IEntity)obj;

            var type = obj.GetType();

            var scrollContainer = new ScrollContainer();

            scrollContainer.SetAnchorPreset(Control.LayoutPreset.Wide, true);
            window.Contents.AddChild(scrollContainer);
            var vBoxContainer = new VBoxContainer
            {
                SizeFlagsHorizontal = Control.SizeFlags.FillExpand,
                SizeFlagsVertical   = Control.SizeFlags.FillExpand,
            };

            scrollContainer.AddChild(vBoxContainer);

            // Handle top bar displaying type and ToString().
            {
                Control top;
                var     stringified = obj.ToString();
                if (type.FullName != stringified)
                {
                    var smallFont = new VectorFont(_resourceCache.GetResource <FontResource>("/Fonts/CALIBRI.TTF"), 10);
                    // Custom ToString() implementation.
                    var headBox = new VBoxContainer {
                        SeparationOverride = 0
                    };
                    headBox.AddChild(new Label {
                        Text = stringified, ClipText = true
                    });
                    headBox.AddChild(new Label
                    {
                        Text              = type.FullName,
                        FontOverride      = smallFont,
                        FontColorOverride = Color.DarkGray,
                        ClipText          = true
                    });
                    top = headBox;
                }
                else
                {
                    top = new Label {
                        Text = stringified
                    };
                }

                if (_entity.TryGetComponent(out ISpriteComponent sprite))
                {
                    var hBox = new HBoxContainer();
                    top.SizeFlagsHorizontal = Control.SizeFlags.FillExpand;
                    hBox.AddChild(top);
                    hBox.AddChild(new SpriteView {
                        Sprite = sprite
                    });
                    vBoxContainer.AddChild(hBox);
                }
                else
                {
                    vBoxContainer.AddChild(top);
                }
            }

            _tabs = new TabContainer();
            _tabs.OnTabChanged += _tabsOnTabChanged;
            vBoxContainer.AddChild(_tabs);

            var clientVBox = new VBoxContainer {
                SeparationOverride = 0
            };

            _tabs.AddChild(clientVBox);
            _tabs.SetTabTitle(TabClientVars, "Client Variables");

            foreach (var control in LocalPropertyList(obj, ViewVariablesManager, _resourceCache))
            {
                clientVBox.AddChild(control);
            }

            var clientComponents = new VBoxContainer {
                SeparationOverride = 0
            };

            _tabs.AddChild(clientComponents);
            _tabs.SetTabTitle(TabClientComponents, "Client Components");

            // See engine#636 for why the Distinct() call.
            var componentList = _entity.GetAllComponents().Distinct().OrderBy(c => c.GetType().ToString());

            foreach (var component in componentList)
            {
                var button = new Button {
                    Text = component.GetType().ToString(), TextAlign = Button.AlignMode.Left
                };
                button.OnPressed += args => { ViewVariablesManager.OpenVV(component); };
                clientComponents.AddChild(button);
            }

            if (!_entity.Uid.IsClientSide())
            {
                _serverVariables = new VBoxContainer {
                    SeparationOverride = 0
                };
                _tabs.AddChild(_serverVariables);
                _tabs.SetTabTitle(TabServerVars, "Server Variables");

                _serverComponents = new VBoxContainer {
                    SeparationOverride = 0
                };
                _tabs.AddChild(_serverComponents);
                _tabs.SetTabTitle(TabServerComponents, "Server Components");
            }
        }
コード例 #13
0
        public override void Initialize(SS14Window window, object obj)
        {
            _entity = (IEntity)obj;

            var scrollContainer = new ScrollContainer();

            //scrollContainer.SetAnchorPreset(Control.LayoutPreset.Wide, true);
            window.Contents.AddChild(scrollContainer);
            var vBoxContainer = new VBoxContainer
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                SizeFlagsVertical   = SizeFlags.FillExpand,
            };

            scrollContainer.AddChild(vBoxContainer);

            // Handle top bar displaying type and ToString().
            {
                Control top;
                var     stringified = PrettyPrint.PrintUserFacingWithType(obj, out var typeStringified);
                if (typeStringified != "")
                {
                    //var smallFont = new VectorFont(_resourceCache.GetResource<FontResource>("/Fonts/CALIBRI.TTF"), 10);
                    // Custom ToString() implementation.
                    var headBox = new VBoxContainer {
                        SeparationOverride = 0
                    };
                    headBox.AddChild(new Label {
                        Text = stringified, ClipText = true
                    });
                    headBox.AddChild(new Label
                    {
                        Text = typeStringified,
                        //    FontOverride = smallFont,
                        FontColorOverride = Color.DarkGray,
                        ClipText          = true
                    });
                    top = headBox;
                }
                else
                {
                    top = new Label {
                        Text = stringified
                    };
                }

                if (_entity.TryGetComponent(out ISpriteComponent? sprite))
                {
                    var hBox = new HBoxContainer();
                    top.SizeFlagsHorizontal = SizeFlags.FillExpand;
                    hBox.AddChild(top);
                    hBox.AddChild(new SpriteView {
                        Sprite = sprite
                    });
                    vBoxContainer.AddChild(hBox);
                }
                else
                {
                    vBoxContainer.AddChild(top);
                }
            }

            _tabs = new TabContainer();
            _tabs.OnTabChanged += _tabsOnTabChanged;
            vBoxContainer.AddChild(_tabs);

            var clientVBox = new VBoxContainer {
                SeparationOverride = 0
            };

            _tabs.AddChild(clientVBox);
            _tabs.SetTabTitle(TabClientVars, "Client Variables");

            var first = true;

            foreach (var group in LocalPropertyList(obj, ViewVariablesManager, _resourceCache))
            {
                ViewVariablesTraitMembers.CreateMemberGroupHeader(
                    ref first,
                    TypeAbbreviation.Abbreviate(group.Key),
                    clientVBox);

                foreach (var control in group)
                {
                    clientVBox.AddChild(control);
                }
            }

            _clientComponents = new VBoxContainer {
                SeparationOverride = 0
            };
            _tabs.AddChild(_clientComponents);
            _tabs.SetTabTitle(TabClientComponents, "Client Components");

            _clientComponents.AddChild(_clientComponentsSearchBar = new LineEdit
            {
                PlaceHolder         = Loc.GetString("Search"),
                SizeFlagsHorizontal = SizeFlags.FillExpand
            });

            _clientComponentsSearchBar.OnTextChanged += OnClientComponentsSearchBarChanged;

            // See engine#636 for why the Distinct() call.
            var componentList = _entity.GetAllComponents().OrderBy(c => c.GetType().ToString());

            foreach (var component in componentList)
            {
                var button = new Button {
                    Text = TypeAbbreviation.Abbreviate(component.GetType()), TextAlign = Label.AlignMode.Left
                };
                button.OnPressed += args => { ViewVariablesManager.OpenVV(component); };
                _clientComponents.AddChild(button);
            }

            if (!_entity.Uid.IsClientSide())
            {
                _serverVariables = new VBoxContainer {
                    SeparationOverride = 0
                };
                _tabs.AddChild(_serverVariables);
                _tabs.SetTabTitle(TabServerVars, "Server Variables");

                _serverComponents = new VBoxContainer {
                    SeparationOverride = 0
                };
                _tabs.AddChild(_serverComponents);
                _tabs.SetTabTitle(TabServerComponents, "Server Components");

                _serverComponents.AddChild(_serverComponentsSearchBar = new LineEdit
                {
                    PlaceHolder         = Loc.GetString("Search"),
                    SizeFlagsHorizontal = SizeFlags.FillExpand
                });

                _serverComponentsSearchBar.OnTextChanged += OnServerComponentsSearchBarChanged;
            }
        }
コード例 #14
0
        public AdminMenuWindow() //TODO: search for buttons?
        {
            CustomMinimumSize = (415, 0);
            Title             = Loc.GetString("Admin Menu");

            #region PlayerList
            // Players // List of all the players, their entities and status
            var playerTabContainer = new MarginContainer
            {
                MarginLeftOverride   = 4,
                MarginTopOverride    = 4,
                MarginRightOverride  = 4,
                MarginBottomOverride = 4,
                CustomMinimumSize    = (50, 50),
            };
            PlayerList = new VBoxContainer();
            var refreshButton = new Button
            {
                Text = "Refresh"
            };
            refreshButton.OnPressed += RefreshPlayerList;
            RefreshPlayerList(null !);
            var playerVBox = new VBoxContainer
            {
                Children =
                {
                    refreshButton,
                    PlayerList
                }
            };
            playerTabContainer.AddChild(playerVBox);
            #endregion PlayerList

            #region Admin Tab
            // Admin Tab // Actual admin stuff
            var adminTabContainer = new MarginContainer
            {
                MarginLeftOverride   = 4,
                MarginTopOverride    = 4,
                MarginRightOverride  = 4,
                MarginBottomOverride = 4,
                CustomMinimumSize    = (50, 50),
            };
            var adminButtonGrid = new GridContainer
            {
                Columns = 4,
            };
            AddCommandButton(_adminButtons, adminButtonGrid);
            adminTabContainer.AddChild(adminButtonGrid);
            #endregion

            #region Adminbus
            // Adminbus // Fun Commands
            var adminbusTabContainer = new MarginContainer
            {
                MarginLeftOverride   = 4,
                MarginTopOverride    = 4,
                MarginRightOverride  = 4,
                MarginBottomOverride = 4,
                CustomMinimumSize    = (50, 50),
            };
            var adminbusButtonGrid = new GridContainer
            {
                Columns = 4,
            };
            AddCommandButton(_adminbusButtons, adminbusButtonGrid);
            adminbusTabContainer.AddChild(adminbusButtonGrid);
            #endregion

            #region Debug
            // Debug // Mostly dev tools, like addatmos
            var debugTabContainer = new MarginContainer
            {
                MarginLeftOverride   = 4,
                MarginTopOverride    = 4,
                MarginRightOverride  = 4,
                MarginBottomOverride = 4,
                CustomMinimumSize    = (50, 50),
            };
            var debugButtonGrid = new GridContainer
            {
                Columns = 4,
            };
            AddCommandButton(_debugButtons, debugButtonGrid);
            debugTabContainer.AddChild(debugButtonGrid);
            #endregion

            #region Round
            // Round // Commands like Check Antags, End Round, RestartRound
            var roundTabContainer = new MarginContainer
            {
                MarginLeftOverride   = 4,
                MarginTopOverride    = 4,
                MarginRightOverride  = 4,
                MarginBottomOverride = 4,
                CustomMinimumSize    = (50, 50),
            };
            var roundButtonGrid = new GridContainer
            {
                Columns = 4,
            };
            AddCommandButton(_roundButtons, roundButtonGrid);
            roundTabContainer.AddChild(roundButtonGrid);
            #endregion

            #region Server
            // Server // Commands like Restart, Shutdown
            var serverTabContainer = new MarginContainer
            {
                MarginLeftOverride   = 4,
                MarginTopOverride    = 4,
                MarginRightOverride  = 4,
                MarginBottomOverride = 4,
                CustomMinimumSize    = (50, 50),
            };
            var serverButtonGrid = new GridContainer
            {
                Columns = 4,
            };
            AddCommandButton(_serverButtons, serverButtonGrid);
            serverTabContainer.AddChild(serverButtonGrid);
            #endregion


            //The master menu that contains all of the tabs.
            MasterTabContainer = new TabContainer();

            //Add all the tabs to the Master container.
            MasterTabContainer.AddChild(adminTabContainer);
            MasterTabContainer.SetTabTitle(0, Loc.GetString("Admin"));
            MasterTabContainer.AddChild(adminbusTabContainer);
            MasterTabContainer.SetTabTitle(1, Loc.GetString("Adminbus"));
            MasterTabContainer.AddChild(debugTabContainer);
            MasterTabContainer.SetTabTitle(2, Loc.GetString("Debug"));
            MasterTabContainer.AddChild(roundTabContainer);
            MasterTabContainer.SetTabTitle(3, Loc.GetString("Round"));
            MasterTabContainer.AddChild(serverTabContainer);
            MasterTabContainer.SetTabTitle(4, Loc.GetString("Server"));
            MasterTabContainer.AddChild(playerTabContainer);
            MasterTabContainer.SetTabTitle(5, Loc.GetString("Players"));
            Contents.AddChild(MasterTabContainer);
            //Request station events, so we can use them later
            IoCManager.Resolve <IStationEventManager>().RequestEvents();
        }
コード例 #15
0
 public void AddTab(string title, Control control)
 {
     _tabs.AddChild(control);
     _tabs.SetTabTitle(_tabCount++, title);
 }