예제 #1
0
        /// <summary>
        ///     Add a single reagent entry to the list
        /// </summary>
        private void AddReagentEntry(Solution.ReagentQuantity reagent)
        {
            var box  = new BoxContainer();
            var spin = new FloatSpinBox(1, 2);

            spin.Value            = reagent.Quantity.Float();
            spin.OnValueChanged  += (args) => SetReagent(args, reagent.ReagentId);
            spin.HorizontalExpand = true;

            box.AddChild(new Label()
            {
                Text = reagent.ReagentId, HorizontalExpand = true
            });
            box.AddChild(spin);

            ReagentList.AddChild(box);
        }
        private BoxContainer MakeRoundEndSummaryTab(string gamemode, string roundEnd, TimeSpan roundDuration)
        {
            var roundEndSummaryTab = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical,
                Name        = Loc.GetString("round-end-summary-window-round-end-summary-tab-title")
            };

            var roundEndSummaryContainerScrollbox = new ScrollContainer
            {
                VerticalExpand = true
            };
            var roundEndSummaryContainer = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            //Gamemode Name
            var gamemodeLabel = new RichTextLabel();

            gamemodeLabel.SetMarkup(Loc.GetString("round-end-summary-window-gamemode-name-label", ("gamemode", gamemode)));
            roundEndSummaryContainer.AddChild(gamemodeLabel);

            //Duration
            var roundTimeLabel = new RichTextLabel();

            roundTimeLabel.SetMarkup(Loc.GetString("round-end-summary-window-duration-label",
                                                   ("hours", roundDuration.Hours),
                                                   ("minutes", roundDuration.Minutes),
                                                   ("seconds", roundDuration.Seconds)));
            roundEndSummaryContainer.AddChild(roundTimeLabel);

            //Round end text
            if (!string.IsNullOrEmpty(roundEnd))
            {
                var roundEndLabel = new RichTextLabel();
                roundEndLabel.SetMarkup(roundEnd);
                roundEndSummaryContainer.AddChild(roundEndLabel);
            }

            roundEndSummaryContainerScrollbox.AddChild(roundEndSummaryContainer);
            roundEndSummaryTab.AddChild(roundEndSummaryContainerScrollbox);

            return(roundEndSummaryTab);
        }
        public ViewVariablesPropertyControl(IViewVariablesManagerInternal viewVars, IRobustSerializer robustSerializer)
        {
            MouseFilter = MouseFilterMode.Pass;

            _viewVariablesManager = viewVars;
            _robustSerializer     = robustSerializer;

            MouseFilter = MouseFilterMode.Pass;
            ToolTip     = "Click to expand";
            MinHeight   = 25;

            VBox = new BoxContainer
            {
                Orientation        = LayoutOrientation.Vertical,
                SeparationOverride = 0
            };
            AddChild(VBox);

            TopContainer = new BoxContainer
            {
                Orientation    = LayoutOrientation.Horizontal,
                VerticalExpand = true
            };
            VBox.AddChild(TopContainer);

            BottomContainer = new BoxContainer
            {
                Orientation = LayoutOrientation.Horizontal,
                Visible     = false
            };
            VBox.AddChild(BottomContainer);

            //var smallFont = new VectorFont(_resourceCache.GetResource<FontResource>("/Fonts/CALIBRI.TTF"), 10);

            _bottomLabel = new Label
            {
                //    FontOverride = smallFont,
                FontColorOverride = Color.DarkGray
            };
            BottomContainer.AddChild(_bottomLabel);

            NameLabel = new Label();
            TopContainer.AddChild(NameLabel);
        }
예제 #4
0
            public EntityButton()
            {
                ActualButton = new Button
                {
                    HorizontalExpand = true,
                    VerticalExpand   = true,
                    ToggleMode       = true,
                    MouseFilter      = MouseFilterMode.Stop
                };
                AddChild(ActualButton);

                var hBoxContainer = new BoxContainer
                {
                    Orientation = LayoutOrientation.Horizontal
                };

                EntitySpriteView = new SpriteView
                {
                    MinSize           = new Vector2(32.0f, 32.0f),
                    OverrideDirection = Direction.South
                };
                EntityName = new Label
                {
                    VerticalAlignment = VAlignment.Center,
                    HorizontalExpand  = true,
                    Margin            = new Thickness(0, 0, 6, 0),
                    Text     = "Backpack",
                    ClipText = true
                };

                hBoxContainer.AddChild(EntitySpriteView);
                hBoxContainer.AddChild(EntityName);

                EntitySize = new Label
                {
                    VerticalAlignment = VAlignment.Bottom,
                    Text  = "Size 6",
                    Align = Label.AlignMode.Right,
                };

                hBoxContainer.AddChild(EntitySize);
                AddChild(hBoxContainer);
            }
예제 #5
0
        public LinkBanner()
        {
            var buttons = new BoxContainer
            {
                Orientation = LayoutOrientation.Horizontal
            };

            AddChild(buttons);

            var uriOpener = IoCManager.Resolve <IUriOpener>();

            var rulesButton = new Button()
            {
                Text = Loc.GetString("server-info-rules-button")
            };

            rulesButton.OnPressed += args => new RulesAndInfoWindow().Open();

            var discordButton = new Button {
                Text = Loc.GetString("server-info-discord-button")
            };

            discordButton.OnPressed += args => uriOpener.OpenUri(UILinks.Discord);

            var websiteButton = new Button {
                Text = Loc.GetString("server-info-website-button")
            };

            websiteButton.OnPressed += args => uriOpener.OpenUri(UILinks.Website);

            var wikiButton = new Button {
                Text = Loc.GetString("server-info-wiki-button")
            };

            wikiButton.OnPressed += args => uriOpener.OpenUri(UILinks.Wiki);
            var changelogButton = new ChangelogButton();

            buttons.AddChild(changelogButton);
            buttons.AddChild(rulesButton);
            buttons.AddChild(discordButton);
            buttons.AddChild(websiteButton);
            buttons.AddChild(wikiButton);
        }
        private BoxContainer MakePlayerManifestoTab(RoundEndMessageEvent.RoundEndPlayerInfo[] playersInfo)
        {
            var playerManifestTab = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical,
                Name        = Loc.GetString("round-end-summary-window-player-manifesto-tab-title")
            };

            var playerInfoContainerScrollbox = new ScrollContainer
            {
                VerticalExpand = true
            };
            var playerInfoContainer = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            //Put observers at the bottom of the list. Put antags on top.
            var sortedPlayersInfo = playersInfo.OrderBy(p => p.Observer).ThenBy(p => !p.Antag);

            //Create labels for each player info.
            foreach (var playerInfo in sortedPlayersInfo)
            {
                var playerInfoText = new RichTextLabel();

                if (playerInfo.PlayerICName != null)
                {
                    if (playerInfo.Observer)
                    {
                        playerInfoText.SetMarkup(
                            Loc.GetString("round-end-summary-window-player-info-if-observer-text",
                                          ("playerOOCName", playerInfo.PlayerOOCName),
                                          ("playerICName", playerInfo.PlayerICName)));
                    }
                    else
                    {
                        //TODO: On Hover display a popup detailing more play info.
                        //For example: their antag goals and if they completed them sucessfully.
                        var icNameColor = playerInfo.Antag ? "red" : "white";
                        playerInfoText.SetMarkup(
                            Loc.GetString("round-end-summary-window-player-info-if-not-observer-text",
                                          ("playerOOCName", playerInfo.PlayerOOCName),
                                          ("icNameColor", icNameColor),
                                          ("playerICName", playerInfo.PlayerICName),
                                          ("playerRole", Loc.GetString(playerInfo.Role))));
                    }
                }
                playerInfoContainer.AddChild(playerInfoText);
            }

            playerInfoContainerScrollbox.AddChild(playerInfoContainer);
            playerManifestTab.AddChild(playerInfoContainerScrollbox);

            return(playerManifestTab);
        }
예제 #7
0
        public void TestCalcMinSize()
        {
            var boxContainer = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };
            var control1 = new Control
            {
                MinSize = (50, 30)
            };
            var control2 = new Control {
                MinSize = (30, 50)
            };

            boxContainer.AddChild(control1);
            boxContainer.AddChild(control2);

            boxContainer.Measure((100, 100));

            Assert.That(boxContainer.DesiredSize, Is.EqualTo(new Vector2(50, 80)));
        }
예제 #8
0
        // Adds a row
        public void AddItem(string name, string status)
        {
            var hbox = new BoxContainer
            {
                Orientation      = LayoutOrientation.Horizontal,
                HorizontalExpand = true,
            };

            // Player Name
            hbox.AddChild(new PanelContainer()
            {
                PanelOverride = new StyleBoxFlat
                {
                    BackgroundColor             = Color.FromHex("#373744"),
                    ContentMarginBottomOverride = 2,
                    ContentMarginLeftOverride   = 4,
                    ContentMarginRightOverride  = 4,
                    ContentMarginTopOverride    = 2
                },
                Children =
                {
                    new Label
                    {
                        Text = name
                    }
                },
                HorizontalExpand = true
            });
            // Status
            hbox.AddChild(new PanelContainer()
            {
                PanelOverride = new StyleBoxFlat
                {
                    BackgroundColor             = Color.FromHex("#373744"),
                    ContentMarginBottomOverride = 2,
                    ContentMarginLeftOverride   = 4,
                    ContentMarginRightOverride  = 4,
                    ContentMarginTopOverride    = 2
                },
                Children =
                {
                    new Label
                    {
                        Text = status
                    }
                },
                HorizontalExpand      = true,
                SizeFlagsStretchRatio = 0.2f,
            });

            _vBox.AddChild(hbox);
        }
        public EyeColorPicker()
        {
            var vBox = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            AddChild(vBox);

            vBox.AddChild(_colorSelectors = new ColorSelectorSliders());

            _colorSelectors.OnColorChanged += ColorValueChanged;
        }
예제 #10
0
 public void UpdateGuiEntries()
 {
     foreach (Node child in _cmdHistoryList.GetChildren())
     {
         child.Free();
     }
     
     foreach (string str in _console.GetCmdHistory())
     {
         Label entry = new Label();
         entry.Text = str;
         _cmdHistoryList.AddChild(entry);
     }
 }
        /// <summary>
        ///     Updates the entry displaying the current and maximum volume of the selected solution.
        /// </summary>
        /// <param name="solution">The selected solution.</param>
        private void UpdateVolumeBox(Solution solution)
        {
            VolumeBox.DisposeAllChildren();

            var volumeLabel = new Label();

            volumeLabel.HorizontalExpand = true;
            volumeLabel.Margin           = new Thickness(0, 4);
            volumeLabel.Text             = Loc.GetString("admin-solutions-window-volume-label",
                                                         ("currentVolume", solution.CurrentVolume),
                                                         ("maxVolume", solution.MaxVolume));

            var capacityBox = new BoxContainer();

            capacityBox.Orientation      = BoxContainer.LayoutOrientation.Horizontal;
            capacityBox.HorizontalExpand = true;
            capacityBox.Margin           = new Thickness(0, 4);

            var capacityLabel = new Label();

            capacityLabel.HorizontalExpand = true;
            capacityLabel.Margin           = new Thickness(0, 1);
            capacityLabel.Text             = Loc.GetString("admin-solutions-window-capacity-label");

            var capacitySpin = new FloatSpinBox(1, 2);

            capacitySpin.HorizontalExpand = true;
            capacitySpin.Margin           = new Thickness(0, 1);
            capacitySpin.Value            = (float)solution.MaxVolume;
            capacitySpin.OnValueChanged  += SetCapacity;

            capacityBox.AddChild(capacityLabel);
            capacityBox.AddChild(capacitySpin);

            VolumeBox.AddChild(volumeLabel);
            VolumeBox.AddChild(capacityBox);
        }
        private void PopulateClientComponents()
        {
            _clientComponents.DisposeAllChildren();

            _clientComponents.AddChild(_clientComponentsSearchBar = new LineEdit
            {
                PlaceHolder      = Loc.GetString("view-variable-instance-entity-client-components-search-bar-placeholder"),
                HorizontalExpand = true,
            });

            _clientComponents.AddChild(_clientComponentsAddButton = new Button()
            {
                Text             = Loc.GetString("view-variable-instance-entity-server-components-add-component-button-placeholder"),
                HorizontalExpand = true,
            });

            _clientComponentsAddButton.OnPressed     += OnClientComponentsAddButtonPressed;
            _clientComponentsSearchBar.OnTextChanged += OnClientComponentsSearchBarChanged;

            var componentList = _entityManager.GetComponents(_entity).OrderBy(c => c.GetType().ToString());

            foreach (var component in componentList)
            {
                var button = new Button {
                    Text = TypeAbbreviation.Abbreviate(component.GetType()), TextAlign = Label.AlignMode.Left
                };
                var removeButton = new TextureButton()
                {
                    StyleClasses        = { DefaultWindow.StyleClassWindowCloseButton },
                    HorizontalAlignment = HAlignment.Right
                };
                button.OnPressed       += _ => ViewVariablesManager.OpenVV(component);
                removeButton.OnPressed += _ => RemoveClientComponent(component);
                button.AddChild(removeButton);
                _clientComponents.AddChild(button);
            }
        }
예제 #13
0
        protected override Control MakeUI(object?value)
        {
            var hBox = new BoxContainer
            {
                Orientation = LayoutOrientation.Horizontal,
                MinSize     = new Vector2(200, 0)
            };

            var uid      = (EntityUid)value !;
            var lineEdit = new LineEdit
            {
                Text             = uid.ToString(),
                Editable         = !ReadOnly,
                HorizontalExpand = true,
            };

            if (!ReadOnly)
            {
                lineEdit.OnTextEntered += e =>
                                          ValueChanged(EntityUid.Parse(e.Text));
            }

            var vvButton = new Button()
            {
                Text = "View",
            };

            vvButton.OnPressed += e =>
            {
                IoCManager.Resolve <IConsoleHost>().ExecuteCommand($"vv {uid}");
            };

            hBox.AddChild(lineEdit);
            hBox.AddChild(vvButton);
            return(hBox);
        }
예제 #14
0
        public void BuildDisplay(Dictionary <string, int> data, OptionSelectedCallback callback)
        {
            _optionsBox.DisposeAllChildren();
            _optionSelectedCallback = callback;

            foreach (var(displayText, callbackData) in data)
            {
                var button = new SurgeryButton(callbackData);

                button.SetOnToggleBehavior(OnButtonPressed);
                button.SetDisplayText(Loc.GetString(displayText));

                _optionsBox.AddChild(button);
            }
        }
예제 #15
0
파일: SaveList.cs 프로젝트: patana93/Thrive
    public override void _Process(float delta)
    {
        if (AutoRefreshOnFirstVisible && !refreshedAtLeastOnce && IsVisibleInTree())
        {
            Refresh();
            return;
        }

        if (!refreshing)
        {
            return;
        }

        if (!readSavesList.IsCompleted)
        {
            return;
        }

        var saves = readSavesList.Result;

        readSavesList.Dispose();
        readSavesList = null;

        foreach (var save in saves)
        {
            var item = (SaveListItem)listItemScene.Instance();
            item.Selectable = SelectableItems;
            item.Loadable   = LoadableItems;

            if (SelectableItems)
            {
                item.Connect(nameof(SaveListItem.OnSelectedChanged), this, nameof(OnSubItemSelectedChanged));
            }

            item.Connect(nameof(SaveListItem.OnDeleted), this, nameof(OnDeletePressed), new Array()
            {
                save
            });

            item.SaveName = save;
            savesList.AddChild(item);
        }

        loadingItem.Visible = false;
        refreshing          = false;
    }
예제 #16
0
    public async void Add(CanvasItem newNode, float delay = 0)
    {
        // Fade-in effect
        Tween tween = new Tween();

        tween.InterpolateProperty(newNode, "modulate", Colors.Transparent, Colors.White, 0.5f,
                                  Tween.TransitionType.Linear, Tween.EaseType.InOut, delay);
        tween.Connect("tween_all_completed", tween, "queue_free");
        newNode.AddChild(tween);
        newNode.Modulate = Colors.Transparent;
        container.AddChild(newNode); // We actually add the thing here
        tween.Start();

        // Wait for the scrollbar to recalculate and scroll to the bottom
        await ToSignal(GetTree(), "idle_frame");

        scroll.ScrollVertical = (int)scroll.GetVScrollbar().MaxValue;
    }
예제 #17
0
            public CharacterWindow(List <ICharacterUI> windowComponents)
            {
                Title = "Character";

                _contentsVBox = new BoxContainer
                {
                    Orientation = LayoutOrientation.Vertical
                };
                Contents.AddChild(_contentsVBox);

                windowComponents.Sort((a, b) => ((int)a.Priority).CompareTo((int)b.Priority));
                foreach (var element in windowComponents)
                {
                    _contentsVBox.AddChild(element.Scene);
                }

                _windowComponents = windowComponents;
            }
            public MicrowaveMenu(MicrowaveBoundUserInterface owner)
            {
                SetSize = MinSize = (512, 256);

                Owner = owner;
                Title = Loc.GetString("microwave-menu-title");
                DisableCookingPanelOverlay = new PanelContainer
                {
                    MouseFilter   = MouseFilterMode.Stop,
                    PanelOverride = new StyleBoxFlat {
                        BackgroundColor = Color.Black.WithAlpha(0.60f)
                    },
                };

                var hSplit = new BoxContainer
                {
                    Orientation = LayoutOrientation.Horizontal
                };

                IngredientsListReagents = new ItemList
                {
                    VerticalExpand        = true,
                    HorizontalExpand      = true,
                    SelectMode            = ItemList.ItemListSelectMode.Button,
                    SizeFlagsStretchRatio = 2,
                    MinSize = (100, 128)
                };

                IngredientsList = new ItemList
                {
                    VerticalExpand        = true,
                    HorizontalExpand      = true,
                    SelectMode            = ItemList.ItemListSelectMode.Button,
                    SizeFlagsStretchRatio = 2,
                    MinSize = (100, 128)
                };

                hSplit.AddChild(IngredientsListReagents);
                //Padding between the lists.
                hSplit.AddChild(new Control
                {
                    MinSize = (0, 5),
                });
예제 #19
0
        public VerbButton(VerbSystem system, Verb verb, VerbType type, EntityUid target, bool drawIcons = true, bool categoryPrefix = false) : base()
        {
            Disabled     = verb.Disabled;
            ToolTip      = verb.Tooltip;
            TooltipDelay = 0.5f;

            var buttonContents = new BoxContainer {
                Orientation = LayoutOrientation.Horizontal
            };

            // maybe draw verb icons
            if (drawIcons)
            {
                TextureRect icon = new()
                {
                    MinSize      = (ContextMenuPopup.ButtonHeight, ContextMenuPopup.ButtonHeight),
                    Stretch      = TextureRect.StretchMode.KeepCentered,
                    TextureScale = (0.5f, 0.5f)
                };

                // Even though we are drawing icons, the icon for this specific verb may be null.
                if (verb.Icon != null)
                {
                    icon.Texture = verb.Icon.Frame0();
                }
                else if (categoryPrefix && verb.Category?.Icon != null)
                {
                    // we will use the category icon instead
                    icon.Texture = verb.Category.Icon.Frame0();
                }

                buttonContents.AddChild(icon);
            }

            // maybe add a label
            if (verb.Text != string.Empty || categoryPrefix)
            {
                // First add a small bit of padding
                buttonContents.AddChild(new Control {
                    MinSize = (4, ContextMenuPopup.ButtonHeight)
                });
예제 #20
0
파일: HUD.cs 프로젝트: aim4/brickhell
    public void Start()
    {
        _levelLabel      = GetNode <Label>(_levelPath);
        _levelLabel.Text = (1).ToString();

        _scoreLabel      = GetNode <Label>(_scorePath);
        _scoreLabel.Text = (0).ToString();

        _livesContainer = GetNode <BoxContainer>(_livesContainerPath);
        if (_livesContainer.GetChildren().Count > 0)
        {
            foreach (Node child in _livesContainer.GetChildren())
            {
                child.QueueFree();
            }
        }

        for (int i = 0; i < _maxLives; i++)
        {
            var textureRect = CreateLifeTexture();
            _livesContainer.AddChild(textureRect);
        }
    }
            public GrinderMenu(ReagentGrinderBoundUserInterface owner)
            {
                SetSize = MinSize = (512, 256);
                Owner   = owner;
                Title   = Loc.GetString("grinder-menu-title");

                var hSplit = new BoxContainer
                {
                    Orientation = LayoutOrientation.Horizontal
                };

                var vBoxGrindJuiceButtonPanel = new BoxContainer
                {
                    Orientation       = LayoutOrientation.Vertical,
                    VerticalAlignment = VAlignment.Center
                };

                GrindButton = new Button
                {
                    Text      = Loc.GetString("grinder-menu-grind-button"),
                    TextAlign = Label.AlignMode.Center,
                    MinSize   = (64, 64)
                };

                JuiceButton = new Button
                {
                    Text      = Loc.GetString("grinder-menu-juice-button"),
                    TextAlign = Label.AlignMode.Center,
                    MinSize   = (64, 64)
                };

                vBoxGrindJuiceButtonPanel.AddChild(GrindButton);
                //inner button padding
                vBoxGrindJuiceButtonPanel.AddChild(new Control
                {
                    MinSize = (0, 16),
                });
예제 #22
0
    public override void _Process(float delta)
    {
        bool isCurrentlyVisible = IsVisibleInTree();

        if (isCurrentlyVisible && ((AutoRefreshOnFirstVisible && !refreshedAtLeastOnce) ||
                                   (AutoRefreshOnBecomingVisible && !wasVisible)))
        {
            Refresh();
            wasVisible = true;
            return;
        }

        if (!isCurrentlyVisible)
        {
            wasVisible = false;
        }

        if (!refreshing)
        {
            return;
        }

        if (!readSavesList.IsCompleted)
        {
            return;
        }

        var saves = readSavesList.Result;

        readSavesList.Dispose();
        readSavesList = null;

        if (saves.Count > 0)
        {
            noSavesItem.Visible = false;

            foreach (var save in saves)
            {
                var item = (SaveListItem)listItemScene.Instance();
                item.Selectable = SelectableItems;
                item.Loadable   = LoadableItems;

                if (SelectableItems)
                {
                    item.Connect(nameof(SaveListItem.OnSelectedChanged), this, nameof(OnSubItemSelectedChanged));
                }

                item.Connect(nameof(SaveListItem.OnDeleted), this, nameof(OnDeletePressed), new Array {
                    save
                });

                item.Connect(nameof(SaveListItem.OnOldSaveLoaded), this, nameof(OnOldSaveLoaded), new Array {
                    save
                });

                // This can't use binds because we need an additional dynamic parameter from the list item here
                item.Connect(nameof(SaveListItem.OnUpgradeableSaveLoaded), this, nameof(OnUpgradeableSaveLoaded));
                item.Connect(nameof(SaveListItem.OnNewSaveLoaded), this, nameof(OnNewSaveLoaded), new Array {
                    save
                });
                item.Connect(nameof(SaveListItem.OnBrokenSaveLoaded), this, nameof(OnInvalidLoaded),
                             new Array {
                    save
                });
                item.Connect(nameof(SaveListItem.OnKnownIncompatibleLoaded), this, nameof(OnKnownIncompatibleLoaded));

                item.SaveName = save;
                savesList.AddChild(item);
            }
        }
        else
        {
            noSavesItem.Visible = true;
        }

        loadingItem.Visible = false;
        refreshing          = false;
    }
예제 #23
0
        public void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            var window = new DefaultWindow {
                MinSize = (500, 400)
            };
            var tabContainer = new TabContainer();

            window.Contents.AddChild(tabContainer);
            var scroll = new ScrollContainer();

            tabContainer.AddChild(scroll);
            //scroll.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide);
            var vBox = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            scroll.AddChild(vBox);

            var progressBar = new ProgressBar {
                MaxValue = 10, Value = 5
            };

            vBox.AddChild(progressBar);

            var optionButton = new OptionButton();

            optionButton.AddItem("Honk");
            optionButton.AddItem("Foo");
            optionButton.AddItem("Bar");
            optionButton.AddItem("Baz");
            optionButton.OnItemSelected += eventArgs => optionButton.SelectId(eventArgs.Id);
            vBox.AddChild(optionButton);

            var tree = new Tree {
                VerticalExpand = true
            };
            var root = tree.CreateItem();

            root.Text = "Honk!";
            var child = tree.CreateItem();

            child.Text = "Foo";
            for (var i = 0; i < 20; i++)
            {
                child      = tree.CreateItem();
                child.Text = $"Bar {i}";
            }

            vBox.AddChild(tree);

            var rich    = new RichTextLabel();
            var message = new FormattedMessage();

            message.AddText("Foo\n");
            message.PushColor(Color.Red);
            message.AddText("Bar");
            message.Pop();
            rich.SetMessage(message);
            vBox.AddChild(rich);

            var itemList = new ItemList();

            tabContainer.AddChild(itemList);
            for (var i = 0; i < 10; i++)
            {
                itemList.AddItem(i.ToString());
            }

            var grid = new GridContainer {
                Columns = 3
            };

            tabContainer.AddChild(grid);
            for (var y = 0; y < 3; y++)
            {
                for (var x = 0; x < 3; x++)
                {
                    grid.AddChild(new Button
                    {
                        MinSize = (50, 50),
                        Text    = $"{x}, {y}"
                    });
예제 #24
0
        public LobbyCharacterPreviewPanel(IEntityManager entityManager,
                                          IClientPreferencesManager preferencesManager)
        {
            _preferencesManager = preferencesManager;
            _previewDummy       = entityManager.SpawnEntity("HumanMob_Dummy", MapCoordinates.Nullspace);

            var header = new NanoHeading
            {
                Text = Loc.GetString("lobby-character-preview-panel-header")
            };

            CharacterSetupButton = new Button
            {
                Text = Loc.GetString("lobby-character-preview-panel-character-setup-button"),
                HorizontalAlignment = HAlignment.Left
            };

            _summaryLabel = new Label();

            var viewSouth = MakeSpriteView(_previewDummy, Direction.South);
            var viewNorth = MakeSpriteView(_previewDummy, Direction.North);
            var viewWest  = MakeSpriteView(_previewDummy, Direction.West);
            var viewEast  = MakeSpriteView(_previewDummy, Direction.East);

            var vBox = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            vBox.AddChild(header);

            _unloaded = new Label {
                Text = Loc.GetString("lobby-character-preview-panel-unloaded-preferences-label")
            };

            _loaded = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical,
                Visible     = false
            };

            _loaded.AddChild(CharacterSetupButton);
            _loaded.AddChild(_summaryLabel);

            var hBox = new BoxContainer
            {
                Orientation = LayoutOrientation.Horizontal
            };

            hBox.AddChild(viewSouth);
            hBox.AddChild(viewNorth);
            hBox.AddChild(viewWest);
            hBox.AddChild(viewEast);

            _loaded.AddChild(hBox);

            vBox.AddChild(_loaded);
            vBox.AddChild(_unloaded);
            AddChild(vBox);

            UpdateUI();

            _preferencesManager.OnServerDataLoaded += UpdateUI;
        }
        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);
            }
        }
예제 #26
0
        protected override Control MakeUI(object?value)
        {
            var hBoxContainer = new BoxContainer
            {
                Orientation = LayoutOrientation.Horizontal,
                MinSize     = new Vector2(200, 0),
            };

            var left = new LineEdit
            {
                Editable         = !ReadOnly,
                HorizontalExpand = true,
                PlaceHolder      = "Left",
                ToolTip          = "Left"
            };

            var top = new LineEdit
            {
                Editable         = !ReadOnly,
                HorizontalExpand = true,
                PlaceHolder      = "Top",
                ToolTip          = "Top"
            };

            var right = new LineEdit
            {
                Editable         = !ReadOnly,
                HorizontalExpand = true,
                PlaceHolder      = "Right",
                ToolTip          = "Right"
            };

            var bottom = new LineEdit
            {
                Editable         = !ReadOnly,
                HorizontalExpand = true,
                PlaceHolder      = "Bottom",
                ToolTip          = "Bottom"
            };

            // Assign default text to editors.
            switch (_type)
            {
            case BoxType.Box2:
            {
                var box = (Box2)value !;
                left.Text   = box.Left.ToString(CultureInfo.InvariantCulture);
                top.Text    = box.Top.ToString(CultureInfo.InvariantCulture);
                right.Text  = box.Right.ToString(CultureInfo.InvariantCulture);
                bottom.Text = box.Bottom.ToString(CultureInfo.InvariantCulture);
                break;
            }

            case BoxType.Box2i:
            {
                var box = (Box2i)value !;
                left.Text   = box.Left.ToString(CultureInfo.InvariantCulture);
                top.Text    = box.Top.ToString(CultureInfo.InvariantCulture);
                right.Text  = box.Right.ToString(CultureInfo.InvariantCulture);
                bottom.Text = box.Bottom.ToString(CultureInfo.InvariantCulture);
                break;
            }

            case BoxType.UIBox2:
            {
                var box = (UIBox2)value !;
                left.Text   = box.Left.ToString(CultureInfo.InvariantCulture);
                top.Text    = box.Top.ToString(CultureInfo.InvariantCulture);
                right.Text  = box.Right.ToString(CultureInfo.InvariantCulture);
                bottom.Text = box.Bottom.ToString(CultureInfo.InvariantCulture);
                break;
            }

            case BoxType.UIBox2i:
            {
                var box = (UIBox2i)value !;
                left.Text   = box.Left.ToString(CultureInfo.InvariantCulture);
                top.Text    = box.Top.ToString(CultureInfo.InvariantCulture);
                right.Text  = box.Right.ToString(CultureInfo.InvariantCulture);
                bottom.Text = box.Bottom.ToString(CultureInfo.InvariantCulture);
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }

            // Organization of the editors is different when left vs right handed.
            switch (_type)
            {
            case BoxType.Box2:
            case BoxType.Box2i:
                hBoxContainer.AddChild(left);
                hBoxContainer.AddChild(bottom);
                hBoxContainer.AddChild(right);
                hBoxContainer.AddChild(top);
                break;

            case BoxType.UIBox2:
            case BoxType.UIBox2i:
                hBoxContainer.AddChild(left);
                hBoxContainer.AddChild(top);
                hBoxContainer.AddChild(right);
                hBoxContainer.AddChild(bottom);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            void OnEntered(LineEdit.LineEditEventArgs e)
            {
                switch (_type)
                {
                case BoxType.Box2:
                {
                    var leftVal   = float.Parse(left.Text, CultureInfo.InvariantCulture);
                    var topVal    = float.Parse(top.Text, CultureInfo.InvariantCulture);
                    var rightVal  = float.Parse(right.Text, CultureInfo.InvariantCulture);
                    var bottomVal = float.Parse(bottom.Text, CultureInfo.InvariantCulture);
                    ValueChanged(new Box2(leftVal, bottomVal, rightVal, topVal));
                    break;
                }

                case BoxType.Box2i:
                {
                    var leftVal   = int.Parse(left.Text, CultureInfo.InvariantCulture);
                    var topVal    = int.Parse(top.Text, CultureInfo.InvariantCulture);
                    var rightVal  = int.Parse(right.Text, CultureInfo.InvariantCulture);
                    var bottomVal = int.Parse(bottom.Text, CultureInfo.InvariantCulture);
                    ValueChanged(new Box2i(leftVal, bottomVal, rightVal, topVal));
                    break;
                }

                case BoxType.UIBox2:
                {
                    var leftVal   = float.Parse(left.Text, CultureInfo.InvariantCulture);
                    var topVal    = float.Parse(top.Text, CultureInfo.InvariantCulture);
                    var rightVal  = float.Parse(right.Text, CultureInfo.InvariantCulture);
                    var bottomVal = float.Parse(bottom.Text, CultureInfo.InvariantCulture);
                    ValueChanged(new UIBox2(leftVal, topVal, rightVal, bottomVal));
                    break;
                }

                case BoxType.UIBox2i:
                {
                    var leftVal   = int.Parse(left.Text, CultureInfo.InvariantCulture);
                    var topVal    = int.Parse(top.Text, CultureInfo.InvariantCulture);
                    var rightVal  = int.Parse(right.Text, CultureInfo.InvariantCulture);
                    var bottomVal = int.Parse(bottom.Text, CultureInfo.InvariantCulture);
                    ValueChanged(new UIBox2i(leftVal, topVal, rightVal, bottomVal));
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            if (!ReadOnly)
            {
                left.OnTextEntered   += OnEntered;
                top.OnTextEntered    += OnEntered;
                right.OnTextEntered  += OnEntered;
                bottom.OnTextEntered += OnEntered;
            }

            return(hBoxContainer);
        }
        public ServerInfo()
        {
            Orientation = LayoutOrientation.Vertical;

            _richTextLabel = new RichTextLabel
            {
                VerticalExpand = true
            };
            AddChild(_richTextLabel);

            var buttons = new BoxContainer
            {
                Orientation = LayoutOrientation.Horizontal
            };

            AddChild(buttons);

            var uriOpener = IoCManager.Resolve <IUriOpener>();

            var rulesButton = new Button()
            {
                Text = Loc.GetString("server-info-rules-button")
            };

            rulesButton.OnPressed += args => new RulesAndInfoWindow().Open();

            var discordButton = new Button {
                Text = Loc.GetString("server-info-discord-button")
            };

            discordButton.OnPressed += args => uriOpener.OpenUri(UILinks.Discord);

            var websiteButton = new Button {
                Text = Loc.GetString("server-info-website-button")
            };

            websiteButton.OnPressed += args => uriOpener.OpenUri(UILinks.Website);

            var reportButton = new Button {
                Text = Loc.GetString("server-info-report-button")
            };

            reportButton.OnPressed += args => uriOpener.OpenUri(UILinks.BugReport);

            var creditsButton = new Button {
                Text = Loc.GetString("server-info-credits-button")
            };

            creditsButton.OnPressed += args => new CreditsWindow().Open();

            var changelogButton = new ChangelogButton
            {
                HorizontalExpand    = true,
                HorizontalAlignment = HAlignment.Right
            };

            buttons.AddChild(rulesButton);
            buttons.AddChild(discordButton);
            buttons.AddChild(websiteButton);
            buttons.AddChild(reportButton);
            buttons.AddChild(creditsButton);
            buttons.AddChild(changelogButton);
        }
예제 #28
0
            public ApcWindow()
            {
                Title = "APC";
                var rows = new BoxContainer
                {
                    Orientation = LayoutOrientation.Vertical
                };

                var statusHeader = new Label {
                    Text = "Power Status: "
                };

                rows.AddChild(statusHeader);

                var breaker = new BoxContainer
                {
                    Orientation = LayoutOrientation.Horizontal
                };
                var breakerLabel = new Label {
                    Text = "Main Breaker: "
                };

                BreakerButton = new CheckButton {
                    Text = "Toggle"
                };
                breaker.AddChild(breakerLabel);
                breaker.AddChild(BreakerButton);
                rows.AddChild(breaker);

                var externalStatus = new BoxContainer
                {
                    Orientation = LayoutOrientation.Horizontal
                };
                var externalStatusLabel = new Label {
                    Text = "External Power: "
                };

                ExternalPowerStateLabel = new Label {
                    Text = "Good"
                };
                ExternalPowerStateLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateGood);
                externalStatus.AddChild(externalStatusLabel);
                externalStatus.AddChild(ExternalPowerStateLabel);
                rows.AddChild(externalStatus);

                var charge = new BoxContainer
                {
                    Orientation = LayoutOrientation.Horizontal
                };
                var chargeLabel = new Label {
                    Text = "Charge:"
                };

                ChargeBar = new ProgressBar
                {
                    HorizontalExpand = true,
                    MinValue         = 0.0f,
                    MaxValue         = 1.0f,
                    Page             = 0.0f,
                    Value            = 0.5f
                };
                ChargePercentage = new Label();
                charge.AddChild(chargeLabel);
                charge.AddChild(ChargeBar);
                charge.AddChild(ChargePercentage);
                rows.AddChild(charge);

                Contents.AddChild(rows);
            }
        public SandboxWindow()
        {
            Resizable = false;
            _gameHud  = IoCManager.Resolve <IGameHud>();

            Title = Loc.GetString("sandbox-window-title");

            var vBox = new BoxContainer
            {
                Orientation        = LayoutOrientation.Vertical,
                SeparationOverride = 4
            };

            Contents.AddChild(vBox);

            RespawnButton = new Button {
                Text = Loc.GetString("sandbox-window-respawn-button")
            };
            vBox.AddChild(RespawnButton);

            SpawnEntitiesButton = new Button {
                Text = Loc.GetString("sandbox-window-spawn-entities-button")
            };
            vBox.AddChild(SpawnEntitiesButton);

            SpawnTilesButton = new Button {
                Text = Loc.GetString("sandbox-window-spawn-tiles-button")
            };
            vBox.AddChild(SpawnTilesButton);

            SpawnDecalsButton = new Button {
                Text = Loc.GetString("sandbox-window-spawn-decals-button")
            };
            vBox.AddChild(SpawnDecalsButton);

            GiveFullAccessButton = new Button {
                Text = Loc.GetString("sandbox-window-grant-full-access-button")
            };
            vBox.AddChild(GiveFullAccessButton);

            GiveAghostButton = new Button {
                Text = Loc.GetString("sandbox-window-ghost-button")
            };
            vBox.AddChild(GiveAghostButton);

            ToggleLightButton = new Button {
                Text = Loc.GetString("sandbox-window-toggle-lights-button"), ToggleMode = true, Pressed = !IoCManager.Resolve <ILightManager>().Enabled
            };
            vBox.AddChild(ToggleLightButton);

            ToggleFovButton = new Button {
                Text = Loc.GetString("sandbox-window-toggle-fov-button"), ToggleMode = true, Pressed = !IoCManager.Resolve <IEyeManager>().CurrentEye.DrawFov
            };
            vBox.AddChild(ToggleFovButton);

            ToggleShadowsButton = new Button {
                Text = Loc.GetString("sandbox-window-toggle-shadows-button"), ToggleMode = true, Pressed = !IoCManager.Resolve <ILightManager>().DrawShadows
            };
            vBox.AddChild(ToggleShadowsButton);

            ToggleSubfloorButton = new Button {
                Text = Loc.GetString("sandbox-window-toggle-subfloor-button"), ToggleMode = true, Pressed = EntitySystem.Get <SubFloorHideSystem>().ShowAll
            };
            vBox.AddChild(ToggleSubfloorButton);

            SuicideButton = new Button {
                Text = Loc.GetString("sandbox-window-toggle-suicide-button")
            };
            vBox.AddChild(SuicideButton);

            ShowMarkersButton = new Button {
                Text = Loc.GetString("sandbox-window-show-spawns-button"), ToggleMode = true, Pressed = EntitySystem.Get <MarkerSystem>().MarkersVisible
            };
            vBox.AddChild(ShowMarkersButton);

            ShowBbButton = new Button {
                Text = Loc.GetString("sandbox-window-show-bb-button"), ToggleMode = true, Pressed = (EntitySystem.Get <DebugPhysicsSystem>().Flags & PhysicsDebugFlags.Shapes) != 0x0
            };
            vBox.AddChild(ShowBbButton);

            MachineLinkingButton = new Button {
                Text = Loc.GetString("sandbox-window-link-machines-button"), ToggleMode = true
            };
            vBox.AddChild(MachineLinkingButton);
        }
        private async void PopulateServerComponents(bool request = true)
        {
            _serverComponents.DisposeAllChildren();

            _serverComponents.AddChild(_serverComponentsSearchBar = new LineEdit
            {
                PlaceHolder      = Loc.GetString("view-variable-instance-entity-server-components-search-bar-placeholder"),
                HorizontalExpand = true,
            });

            _serverComponents.AddChild(_serverComponentsAddButton = new Button()
            {
                Text             = Loc.GetString("view-variable-instance-entity-server-components-add-component-button-placeholder"),
                HorizontalExpand = true,
            });

            _serverComponentsSearchBar.OnTextChanged += OnServerComponentsSearchBarChanged;
            _serverComponentsAddButton.OnPressed     += OnServerComponentsAddButtonPressed;

            if (!request || _entitySession == null)
            {
                return;
            }

            var componentsBlob = await ViewVariablesManager.RequestData <ViewVariablesBlobEntityComponents>(_entitySession, new ViewVariablesRequestEntityComponents());

            componentsBlob.ComponentTypes.Sort();

            var componentTypes = componentsBlob.ComponentTypes.AsEnumerable();

            if (!string.IsNullOrEmpty(_serverComponentsSearchBar.Text))
            {
                componentTypes = componentTypes
                                 .Where(t => t.Stringified.Contains(_serverComponentsSearchBar.Text,
                                                                    StringComparison.InvariantCultureIgnoreCase));
            }

            componentTypes = componentTypes.OrderBy(t => t.Stringified);

            foreach (var componentType in componentTypes)
            {
                var button = new Button {
                    Text = componentType.Stringified, TextAlign = Label.AlignMode.Left
                };
                var removeButton = new TextureButton()
                {
                    StyleClasses        = { DefaultWindow.StyleClassWindowCloseButton },
                    HorizontalAlignment = HAlignment.Right
                };
                button.OnPressed += _ =>
                {
                    ViewVariablesManager.OpenVV(
                        new ViewVariablesComponentSelector(_entity, componentType.FullName));
                };
                removeButton.OnPressed += _ =>
                {
                    // We send a command to remove the component.
                    IoCManager.Resolve <IClientConsoleHost>().RemoteExecuteCommand(null, $"rmcomp {_entity} {componentType.ComponentName}");
                    PopulateServerComponents();
                };
                button.AddChild(removeButton);
                _serverComponents.AddChild(button);
            }
        }