예제 #1
0
        public CargoOrderRow()
        {
            SizeFlagsHorizontal = SizeFlags.FillExpand;

            var hBox = new HBoxContainer
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                MouseFilter         = MouseFilterMode.Ignore
            };

            Icon = new TextureRect
            {
                CustomMinimumSize = new Vector2(32.0f, 32.0f),
                MouseFilter       = MouseFilterMode.Ignore,
                RectClipContent   = true
            };
            hBox.AddChild(Icon);

            var vBox = new VBoxContainer
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                SizeFlagsVertical   = SizeFlags.FillExpand
            };

            ProductName = new Label
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                StyleClasses        = { NanoStyle.StyleClassLabelSubText },
                ClipText            = true
            };
            Description = new Label
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                StyleClasses        = { NanoStyle.StyleClassLabelSubText },
                ClipText            = true
            };
            vBox.AddChild(ProductName);
            vBox.AddChild(Description);
            hBox.AddChild(vBox);

            Approve = new Button
            {
                Text         = "Approve",
                StyleClasses = { NanoStyle.StyleClassLabelSubText }
            };
            hBox.AddChild(Approve);

            Cancel = new Button
            {
                Text         = "Cancel",
                StyleClasses = { NanoStyle.StyleClassLabelSubText }
            };
            hBox.AddChild(Cancel);

            AddChild(hBox);
        }
예제 #2
0
        private void SetupGameMenu(Texture backgroundTexture)
        {
            // building the game container
            _gameRootContainer = new VBoxContainer();

            _levelLabel = new Label
            {
                Align = Label.AlignMode.Center,
                SizeFlagsHorizontal = SizeFlags.FillExpand
            };
            _gameRootContainer.AddChild(_levelLabel);
            _gameRootContainer.AddChild(new Control
            {
                CustomMinimumSize = new Vector2(1, 5)
            });

            _pointsLabel = new Label
            {
                Align = Label.AlignMode.Center,
                SizeFlagsHorizontal = SizeFlags.FillExpand
            };
            _gameRootContainer.AddChild(_pointsLabel);
            _gameRootContainer.AddChild(new Control
            {
                CustomMinimumSize = new Vector2(1, 10)
            });

            var gameBox = new HBoxContainer();

            gameBox.AddChild(SetupHoldBox(backgroundTexture));
            gameBox.AddChild(new Control
            {
                CustomMinimumSize = new Vector2(10, 1)
            });
            gameBox.AddChild(SetupGameGrid(backgroundTexture));
            gameBox.AddChild(new Control
            {
                CustomMinimumSize = new Vector2(10, 1)
            });
            gameBox.AddChild(SetupNextBox(backgroundTexture));

            _gameRootContainer.AddChild(gameBox);

            _gameRootContainer.AddChild(new Control
            {
                CustomMinimumSize = new Vector2(1, 10)
            });

            _pauseButton = new Button
            {
                Text      = "Pause",
                TextAlign = Label.AlignMode.Center
            };
            _pauseButton.OnPressed += (e) => TryPause();
            _gameRootContainer.AddChild(_pauseButton);
        }
예제 #3
0
    public void ItemButtonReleased()
    {
        if (_inventory.SelectedItemId < 0)
        {
            return;
        }

        Item.ItemStack selectedItemStack = _itemList[_inventory.SelectedItemId];

        if (_alchemyStage == AlchemyStage.MortarPestle && _mortarPestleStage == MortarPestleStage.PickReagents && _potionReagents.Count < 4)
        {
            if (selectedItemStack.stackCount > 1)
            {
                _itemList[_inventory.SelectedItemId] = Item.DecreaseItemStackCount(selectedItemStack, 1);
            }
            else
            {
                _itemList.RemoveAt(_inventory.SelectedItemId);
            }

            _inventory.Update();

            HBoxContainer itemInfo = new HBoxContainer();
            itemInfo.Set("custom_constants/separation", 10f);

            Control itemIcon = new Control();
            itemIcon.RectMinSize = new Vector2(16f, 16f);

            Sprite itemBG = new Sprite();
            itemBG.Texture  = _singleItemSlot;
            itemBG.Centered = false;

            Sprite itemSprite = new Sprite();
            itemSprite.Texture  = selectedItemStack.item.IconTex;
            itemSprite.Centered = false;
            itemSprite.Position = new Vector2(2f, 2f);
            itemBG.AddChild(itemSprite);
            itemIcon.AddChild(itemBG);
            itemInfo.AddChild(itemIcon);

            Label itemName = new Label();
            itemName.Text = selectedItemStack.item.Name;
            itemName.AddFontOverride("font", _smallFont);
            itemName.MarginLeft = 4f;
            itemInfo.AddChild(itemName);

            _potionReagentsBox.AddChild(itemInfo);

            _potionReagents.Add(selectedItemStack.item);
            _proceedToCrush.Disabled = false;
        }

        GD.Print("Selected: " + selectedItemStack.item.Name);
    }
예제 #4
0
            protected override void Initialize()
            {
                base.Initialize();

                ActualButton = new Button("Button")
                {
                    SizeFlagsHorizontal = SizeFlags.FillExpand,
                    SizeFlagsVertical   = SizeFlags.FillExpand,
                    ToggleMode          = true,
                    MouseFilter         = MouseFilterMode.Stop
                };
                AddChild(ActualButton);

                var hBoxContainer = new HBoxContainer("HBoxContainer")
                {
                    MouseFilter = MouseFilterMode.Ignore
                };

                EntitySpriteView = new SpriteView("SpriteView")
                {
                    CustomMinimumSize = new Vector2(32.0f, 32.0f), MouseFilter = MouseFilterMode.Ignore
                };
                EntityName = new Label("Name")
                {
                    SizeFlagsVertical = SizeFlags.ShrinkCenter,
                    Text        = "Backpack",
                    MouseFilter = MouseFilterMode.Ignore
                };
                hBoxContainer.AddChild(EntitySpriteView);
                hBoxContainer.AddChild(EntityName);

                EntityControl = new Control("Control")
                {
                    SizeFlagsHorizontal = SizeFlags.FillExpand, MouseFilter = MouseFilterMode.Ignore
                };
                EntitySize = new Label("Size")
                {
                    SizeFlagsVertical = SizeFlags.ShrinkCenter,
                    Text         = "Size 6",
                    Align        = Label.AlignMode.Right,
                    AnchorLeft   = 1.0f,
                    AnchorRight  = 1.0f,
                    AnchorBottom = 0.5f,
                    AnchorTop    = 0.5f,
                    MarginLeft   = -38.0f,
                    MarginTop    = -7.0f,
                    MarginRight  = -5.0f,
                    MarginBottom = 7.0f
                };

                EntityControl.AddChild(EntitySize);
                hBoxContainer.AddChild(EntityControl);
                AddChild(hBoxContainer);
            }
            public SolarControlWindow(IGameTiming igt)
            {
                Title = "Solar Control Window";

                var rows = new GridContainer();
                rows.Columns = 2;

                // little secret: the reason I put the values
                // in the first column is because otherwise the UI
                // layouter autoresizes the window to be too small
                rows.AddChild(new Label {Text = "Output Power:"});
                rows.AddChild(new Label {Text = ""});

                rows.AddChild(OutputPower = new Label {Text = "?"});
                rows.AddChild(new Label {Text = "W"});

                rows.AddChild(new Label {Text = "Sun Angle:"});
                rows.AddChild(new Label {Text = ""});

                rows.AddChild(SunAngle = new Label {Text = "?"});
                rows.AddChild(new Label {Text = "°"});

                rows.AddChild(new Label {Text = "Panel Angle:"});
                rows.AddChild(new Label {Text = ""});

                rows.AddChild(PanelRotation = new LineEdit());
                rows.AddChild(new Label {Text = "°"});

                rows.AddChild(new Label {Text = "Panel Angular Velocity:"});
                rows.AddChild(new Label {Text = ""});

                rows.AddChild(PanelVelocity = new LineEdit());
                rows.AddChild(new Label {Text = "°/min."});

                rows.AddChild(new Label {Text = "Press Enter to confirm."});
                rows.AddChild(new Label {Text = ""});

                PanelRotation.SizeFlagsHorizontal = SizeFlags.FillExpand;
                PanelVelocity.SizeFlagsHorizontal = SizeFlags.FillExpand;
                rows.SizeFlagsHorizontal = SizeFlags.Fill;
                rows.SizeFlagsVertical = SizeFlags.Fill;

                NotARadar = new SolarControlNotARadar(igt);

                var outerColumns = new HBoxContainer();
                outerColumns.AddChild(rows);
                outerColumns.AddChild(NotARadar);
                outerColumns.SizeFlagsHorizontal = SizeFlags.Fill;
                outerColumns.SizeFlagsVertical = SizeFlags.Fill;
                Contents.AddChild(outerColumns);
                Resizable = false;
            }
            public EntityButton()
            {
                ActualButton = new Button
                {
                    SizeFlagsHorizontal = SizeFlags.FillExpand,
                    SizeFlagsVertical   = SizeFlags.FillExpand,
                    ToggleMode          = true,
                    MouseFilter         = MouseFilterMode.Stop
                };
                AddChild(ActualButton);

                var hBoxContainer = new HBoxContainer {
                    MouseFilter = MouseFilterMode.Ignore
                };

                EntitySpriteView = new SpriteView
                {
                    CustomMinimumSize = new Vector2(32.0f, 32.0f), MouseFilter = MouseFilterMode.Ignore
                };
                EntityName = new Label
                {
                    SizeFlagsVertical = SizeFlags.ShrinkCenter,
                    Text        = "Backpack",
                    MouseFilter = MouseFilterMode.Ignore
                };
                hBoxContainer.AddChild(EntitySpriteView);
                hBoxContainer.AddChild(EntityName);

                EntityControl = new Control
                {
                    SizeFlagsHorizontal = SizeFlags.FillExpand, MouseFilter = MouseFilterMode.Ignore
                };
                EntitySize = new Label
                {
                    SizeFlagsVertical = SizeFlags.ShrinkCenter,
                    Text  = "Size 6",
                    Align = Label.AlignMode.Right,

                    /*AnchorLeft = 1.0f,
                     * AnchorRight = 1.0f,
                     * AnchorBottom = 0.5f,
                     * AnchorTop = 0.5f,
                     * MarginLeft = -38.0f,
                     * MarginTop = -7.0f,
                     * MarginRight = -5.0f,
                     * MarginBottom = 7.0f*/
                };

                EntityControl.AddChild(EntitySize);
                hBoxContainer.AddChild(EntityControl);
                AddChild(hBoxContainer);
            }
예제 #7
0
        public override void Initialize(ViewVariablesInstanceObject instance)
        {
            base.Initialize(instance);
            if (instance.Object == null)
            {
                DebugTools.Assert(instance.Session != null);
                _networked        = true;
                _networkSemaphore = new SemaphoreSlim(1, 1);
            }
            else
            {
                var enumerable = (IEnumerable)instance.Object;
                _enumerator = enumerable.GetEnumerator();
            }

            var outerVBox = new VBoxContainer();

            _controlsHBox = new HBoxContainer
            {
                SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter
            };

            {
                // Page navigational controls.
                _leftButton = new Button {
                    Text = "<<", Disabled = true
                };
                _pageLabel = new LineEdit {
                    Text = "0"
                };
                _rightButton = new Button {
                    Text = ">>"
                };

                _leftButton.OnPressed    += _leftButtonPressed;
                _pageLabel.OnTextEntered += _lineEditTextEntered;
                _rightButton.OnPressed   += _rightButtonPressed;

                _controlsHBox.AddChild(_leftButton);
                _controlsHBox.AddChild(_pageLabel);
                _controlsHBox.AddChild(_rightButton);
            }

            outerVBox.AddChild(_controlsHBox);

            _elementsVBox = new VBoxContainer();
            outerVBox.AddChild(_elementsVBox);

            _cache = new List <object>();

            instance.AddTab("IEnumerable", outerVBox);
        }
예제 #8
0
        // Adds a row
        public void AddItem(string name, string status)
        {
            var hbox = new HBoxContainer
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
            };

            // 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
                    }
                },
                SizeFlagsHorizontal = SizeFlags.FillExpand
            });
            // 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
                    }
                },
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 0.2f,
            });

            _vBox.AddChild(hbox);
        }
예제 #9
0
            public EntityButton()
            {
                ActualButton = new Button
                {
                    HorizontalExpand = true,
                    VerticalExpand   = true,
                    ToggleMode       = true,
                    MouseFilter      = MouseFilterMode.Stop
                };
                AddChild(ActualButton);

                var hBoxContainer = new HBoxContainer();

                EntitySpriteView = new SpriteView
                {
                    MinSize           = new Vector2(32.0f, 32.0f),
                    OverrideDirection = Direction.South
                };
                EntityName = new Label
                {
                    VerticalAlignment = VAlignment.Center,
                    Text = "Backpack",
                };
                hBoxContainer.AddChild(EntitySpriteView);
                hBoxContainer.AddChild(EntityName);

                EntityControl = new Control
                {
                    HorizontalExpand = true
                };
                EntitySize = new Label
                {
                    VerticalAlignment = VAlignment.Center,
                    Text  = "Size 6",
                    Align = Label.AlignMode.Right,

                    /*AnchorLeft = 1.0f,
                     * AnchorRight = 1.0f,
                     * AnchorBottom = 0.5f,
                     * AnchorTop = 0.5f,
                     * MarginLeft = -38.0f,
                     * MarginTop = -7.0f,
                     * MarginRight = -5.0f,
                     * MarginBottom = 7.0f*/
                };

                EntityControl.AddChild(EntitySize);
                hBoxContainer.AddChild(EntityControl);
                AddChild(hBoxContainer);
            }
예제 #10
0
        public ServerInfo()
        {
            _richTextLabel = new RichTextLabel
            {
                VerticalExpand = true
            };
            AddChild(_richTextLabel);

            var buttons = new HBoxContainer();

            AddChild(buttons);

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

            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(discordButton);
            buttons.AddChild(websiteButton);
            buttons.AddChild(reportButton);
            buttons.AddChild(creditsButton);
            buttons.AddChild(changelogButton);
        }
        public CargoProductRow()
        {
            SizeFlagsHorizontal = SizeFlags.FillExpand;

            MainButton = new Button
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                SizeFlagsVertical   = SizeFlags.FillExpand
            };
            AddChild(MainButton);

            var hBox = new HBoxContainer
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                MouseFilter         = MouseFilterMode.Ignore
            };

            Icon = new TextureRect
            {
                CustomMinimumSize = new Vector2(32.0f, 32.0f),
                MouseFilter       = MouseFilterMode.Ignore,
                RectClipContent   = true
            };
            hBox.AddChild(Icon);

            ProductName = new Label
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand
            };
            hBox.AddChild(ProductName);

            var panel = new PanelContainer
            {
                PanelOverride = new StyleBoxFlat {
                    BackgroundColor = new Color(37, 37, 42)
                },
                MouseFilter = MouseFilterMode.Ignore
            };

            PointCost = new Label
            {
                CustomMinimumSize = new Vector2(40.0f, 32.0f),
                Align             = Label.AlignMode.Right
            };
            panel.AddChild(PointCost);
            hBox.AddChild(panel);

            AddChild(hBox);
        }
예제 #12
0
    private void AddControl(KeyValuePair <string, CommandInfo> kvp)
    {
        HBoxContainer hb  = new HBoxContainer();
        Label         lbl = new Label();

        lbl.Text = kvp.Key;
        LineEdit le = new LineEdit();

        le.Name = kvp.Key;

        hb.AddChild(lbl);
        hb.AddChild(le);
        _controlsContainer.AddChild(hb);
        _playerControls.Add(le);
    }
예제 #13
0
        private void PerformLayout()
        {
            MouseFilter       = MouseFilterMode.Pass;
            ToolTip           = "Click to expand";
            CustomMinimumSize = new Vector2(0, 25);

            VBox = new VBoxContainer {
                SeparationOverride = 0
            };
            AddChild(VBox);

            TopContainer = new HBoxContainer {
                SizeFlagsVertical = SizeFlags.FillExpand
            };
            VBox.AddChild(TopContainer);

            BottomContainer = new HBoxContainer
            {
                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);
        }
예제 #14
0
    private void OnInputsChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        switch (e.Action)
        {
        case NotifyCollectionChangedAction.Add:
            foreach (InputEventItem newItem in e.NewItems)
            {
                inputEventsContainer.AddChild(newItem);
            }

            inputEventsContainer.MoveChild(addInputEvent, Inputs.Count);

            break;

        case NotifyCollectionChangedAction.Remove:
            foreach (InputEventItem oldItem in e.OldItems)
            {
                inputEventsContainer.RemoveChild(oldItem);
            }

            break;

        default:
            throw new NotSupportedException($"{e.Action} is not supported on {nameof(Inputs)}");
        }
    }
예제 #15
0
        public MicrowaveMenu(MicrowaveBoundUserInterface owner = null)
        {
            Owner = owner;
            Title = Loc.GetString("Microwave");
            var hSplit = new HBoxContainer
            {
                SizeFlagsHorizontal = SizeFlags.Fill,
                SizeFlagsVertical   = SizeFlags.Fill
            };

            IngredientsListReagents = new ItemList
            {
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SelectMode            = ItemList.ItemListSelectMode.Button,
                SizeFlagsStretchRatio = 2,
                CustomMinimumSize     = (100, 128)
            };

            IngredientsList = new ItemList
            {
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SelectMode            = ItemList.ItemListSelectMode.Button,
                SizeFlagsStretchRatio = 2,
                CustomMinimumSize     = (100, 128)
            };

            hSplit.AddChild(IngredientsListReagents);
            //Padding between the lists.
            hSplit.AddChild(new Control
            {
                CustomMinimumSize = (0, 5),
            });
예제 #16
0
    public void AddRuneToSpell(RuneButton runeButton)
    {
        Rune rune = CreateRune(runeButton.RuneID);

        runePanel.AddChild(rune);
        runes.Add(rune);
    }
예제 #17
0
파일: Arena.cs 프로젝트: exts/ld44
        private void DrawAmmoUiElements()
        {
            var empty = _player.MaxAmmo - _player.CurrentAmmo;

            for (var e = 0; e < empty; e++)
            {
                var emptyObject = (TextureRect)_ammoEmptyObject.Instance();
                _ammoContainer.AddChild(emptyObject);
            }

            for (var c = 0; c < _player.CurrentAmmo; c++)
            {
                var currentObject = (TextureRect)_ammoAvailableObject.Instance();
                _ammoContainer.AddChild(currentObject);
            }
        }
예제 #18
0
    public void FillDataPipe(IEnumerable <IEnumerable <int> > data)
    {
        int numPipe = 0;

        foreach (IEnumerable <int> pipe in data)
        {
            HBoxContainer actualHBoxContainer = new HBoxContainer();
            var           actualLabelPipe     = new Label();
            numPipe++;
            actualLabelPipe.Text = $" * tube n°{numPipe}";
            actualLabelPipe.AddFontOverride("font", ResourceLoader.Load <Font>("res://fonts/fontsmall.tres"));
            actualLabelPipe.AddColorOverride("font_color", Colors.Black);
            vBoxContainer.AddChild(actualLabelPipe);

            vBoxContainer.AddChild(actualHBoxContainer);
            var          hSeparator = new HSeparator();
            StyleBoxLine sbl        = new StyleBoxLine()
            {
                Color = new Color("ad4c4c"), Thickness = 5
            };
            hSeparator.AddStyleboxOverride("separator", sbl);
            vBoxContainer.AddChild(hSeparator);

            foreach (int length in pipe)
            {
                actualHBoxContainer.AddChild(CreateLabelPipeDraw(length));
            }
        }
        RectSize = new Vector2(RectSize.x, (numPipe) * 68);
    }
예제 #19
0
    public void makeGoal(int max, Texture texture, String value)
    {
        GoalPrefab goal = (GoalPrefab)GoalPrefab.Instance();

        goalConatiner.AddChild(goal);
        goal.SetGoalValues(max, texture, value);
    }
예제 #20
0
    /// <summary>
    ///   Sets up the inputs and adds them as children.
    /// </summary>
    public override void _Ready()
    {
        if (string.IsNullOrEmpty(InputName))
        {
            throw new InvalidOperationException($"{nameof(InputName)} can't be empty");
        }

        if (DisplayName == null)
        {
            throw new InvalidOperationException($"{nameof(DisplayName)} can't be null");
        }

        if (Inputs == null)
        {
            throw new InvalidOperationException($"{nameof(Inputs)} can't be null");
        }

        inputActionHeader    = GetNode <Label>(InputActionHeaderPath);
        inputEventsContainer = GetNode <HBoxContainer>(InputEventsContainerPath);
        addInputEvent        = GetNode <Button>(AddInputEventPath);

        addInputEvent.RegisterToolTipForControl("addInputButton", "options");

        inputActionHeader.Text = DisplayName;

        foreach (var input in Inputs)
        {
            input.AssociatedAction = new WeakReference <InputActionItem>(this);
            inputEventsContainer.AddChild(input);
        }

        inputEventsContainer.MoveChild(addInputEvent, Inputs.Count);

        Inputs.CollectionChanged += OnInputsChanged;
    }
예제 #21
0
 private void Refresh()
 {
     container.QueueFreeChildren();
     foreach (CharacterEntity entity in Game.data.family.alive)
     {
         container.AddChild(CharacterTable.Create(entity));
     }
 }
        public LobbyCharacterPreviewPanel(IEntityManager entityManager,
                                          ILocalizationManager localization,
                                          IClientPreferencesManager preferencesManager)
        {
            _preferencesManager = preferencesManager;
            _previewDummy       = entityManager.SpawnEntityAt("HumanMob_Dummy", MapCoordinates.Nullspace);

            var header = new NanoHeading
            {
                Text = localization.GetString("Character setup")
            };

            CharacterSetupButton = new Button
            {
                Text = localization.GetString("Customize"),
                SizeFlagsHorizontal = SizeFlags.None
            };

            _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 VBoxContainer();

            vBox.AddChild(header);
            vBox.AddChild(CharacterSetupButton);

            vBox.AddChild(_summaryLabel);

            var hBox = new HBoxContainer();

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

            vBox.AddChild(hBox);

            AddChild(vBox);

            UpdateUI();
        }
예제 #23
0
 //new game
 public void createPlayerListDatas(string[] datas)
 {
     foreach (string dataPlayer in datas)
     {
         PlayerListViewElement plve = plvElementPrefab.Instance() as PlayerListViewElement;
         playersListView.AddChild(plve);
         plve.setData(dataPlayer);
     }
 }
예제 #24
0
    private DynamicPart CreateDynamicPart(int offset, IEnumerable <string> texts, int columns, Font overrideFont = null)
    {
        if (columns <= 1)
        {
            return(CreateDynamicPart(offset, string.Join("\n", texts)));
        }

        var splitTexts = Enumerable.Range(0, columns).Select(_ => new StringBuilder()).ToList();

        using (var textEnumerator = texts.GetEnumerator())
        {
            bool done = false;
            while (!done)
            {
                foreach (var column in splitTexts)
                {
                    if (!textEnumerator.MoveNext())
                    {
                        done = true;
                        break;
                    }

                    column.AppendLine(textEnumerator.Current);
                }
            }
        }

        var hBox = new HBoxContainer
        {
            // 0.7 == 15% shrink of middle spacing for 2 columns and move position to center.
            RectPosition = new Vector2(columns == 2 ? RectSize.x * 0.15f : 0, 0),
            RectMinSize  = new Vector2(columns == 2 ? RectSize.x * 0.7f : RectSize.x, 0),
        };

        foreach (var columnText in splitTexts)
        {
            var label = new Label
            {
                Text  = columnText.ToString(),
                Align = Label.AlignEnum.Center,
                SizeFlagsHorizontal = (int)SizeFlags.ExpandFill,
            };

            if (overrideFont != null)
            {
                label.AddFontOverride("font", overrideFont);
            }

            hBox.AddChild(label);
        }

        var dynamicPart = new DynamicPart(offset, hBox);

        AddDynamicItem(dynamicPart);
        return(dynamicPart);
    }
예제 #25
0
        public ServerInfo()
        {
            _richTextLabel = new RichTextLabel
            {
                VerticalExpand = true
            };
            AddChild(_richTextLabel);

            var buttons = new HBoxContainer();

            AddChild(buttons);

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

            var discordButton = new Button {
                Text = Loc.GetString("Discord")
            };

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

            var websiteButton = new Button {
                Text = Loc.GetString("Website")
            };

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

            var reportButton = new Button {
                Text = Loc.GetString("Report Bugs")
            };

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

            var creditsButton = new Button {
                Text = Loc.GetString("Credits")
            };

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

            buttons.AddChild(discordButton);
            buttons.AddChild(websiteButton);
            buttons.AddChild(reportButton);
            buttons.AddChild(creditsButton);
        }
예제 #26
0
            protected override void Initialize()
            {
                base.Initialize();

                ActualButton = new Button("Button")
                {
                    SizeFlagsHorizontal = SizeFlags.FillExpand,
                    SizeFlagsVertical   = SizeFlags.FillExpand,
                    ToggleMode          = true,
                };
                AddChild(ActualButton);

                var hBoxContainer = new HBoxContainer("HBoxContainer")
                {
                    MouseFilter = MouseFilterMode.Ignore,
                };
                var textureWrap = new Control("TextureWrap")
                {
                    CustomMinimumSize = new Vector2(32.0f, 32.0f),
                    MouseFilter       = MouseFilterMode.Ignore,
                    RectClipContent   = true
                };

                EntityTextureRect = new TextureRect("TextureRect")
                {
                    AnchorRight         = 1.0f,
                    AnchorBottom        = 1.0f,
                    MouseFilter         = MouseFilterMode.Ignore,
                    SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
                    SizeFlagsVertical   = SizeFlags.ShrinkCenter
                };
                textureWrap.AddChild(EntityTextureRect);

                EntityLabel = new Label("Label")
                {
                    SizeFlagsVertical = SizeFlags.ShrinkCenter,
                    Text = "Backpack"
                };

                hBoxContainer.AddChild(textureWrap);
                hBoxContainer.AddChild(EntityLabel);
                AddChild(hBoxContainer);
            }
        public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner)
        {
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("Communications Console");
            Owner = owner;

            _countdownLabel = new RichTextLabel()
            {
                CustomMinimumSize = new Vector2(0, 200)
            };
            _emergencyShuttleButton            = new Button();
            _emergencyShuttleButton.OnPressed += (e) => Owner.EmergencyShuttleButtonPressed();

            var vbox = new VBoxContainer()
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand
            };

            vbox.AddChild(_countdownLabel);
            vbox.AddChild(_emergencyShuttleButton);

            var hbox = new HBoxContainer()
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand
            };

            hbox.AddChild(new Control()
            {
                CustomMinimumSize = new Vector2(100, 0), SizeFlagsHorizontal = SizeFlags.FillExpand
            });
            hbox.AddChild(vbox);
            hbox.AddChild(new Control()
            {
                CustomMinimumSize = new Vector2(100, 0), SizeFlagsHorizontal = SizeFlags.FillExpand
            });

            Contents.AddChild(hbox);

            UpdateCountdown();
            Timer.SpawnRepeating(1000, UpdateCountdown, _timerCancelTokenSource.Token);
        }
예제 #28
0
    private void onStoryEnded()
    {
        CanvasItem endOfStory = new VBoxContainer();

        endOfStory.AddChild(new HSeparator());
        CanvasItem endOfStoryLine = new HBoxContainer();

        endOfStory.AddChild(endOfStoryLine);
        endOfStory.AddChild(new HSeparator());
        Control separator = new HSeparator();

        separator.SizeFlagsHorizontal = (int)(SizeFlags.Fill | SizeFlags.Expand);
        Label endOfStoryText = new Label();

        endOfStoryText.Text = "End of story";
        endOfStoryLine.AddChild(separator);
        endOfStoryLine.AddChild(endOfStoryText);
        endOfStoryLine.AddChild(separator.Duplicate());
        addToStory(endOfStory);
    }
예제 #29
0
        protected Number <float> CreateComponent()
        {
            var component = new Number <float>();

            component.SizeFlagsHorizontal = (int)Control.SizeFlags.ExpandFill;

            component.ValueSet += _ => ValueSet();

            hBox.AddChild(component);
            return(component);
        }
        public HairPickerWindow(IResourceCache resourceCache, ILocalizationManager localization)
        {
            Title         = "Hair";
            ResourceCache = resourceCache;
            var vBox = new VBoxContainer();

            Contents.AddChild(vBox);

            var colorHBox = new HBoxContainer();

            vBox.AddChild(colorHBox);

            var colorLabel = new Label
            {
                Text = localization.GetString("Color: ")
            };

            colorHBox.AddChild(colorLabel);

            var colorEdit = new LineEdit
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand
            };

            colorEdit.OnTextChanged += args =>
            {
                var color = Color.TryFromHex(args.Text);
                if (color.HasValue)
                {
                    OnHairColorPicked?.Invoke(color.Value);
                }
            };
            colorHBox.AddChild(colorEdit);

            Items = new ItemList
            {
                SizeFlagsVertical = SizeFlags.FillExpand,
            };
            vBox.AddChild(Items);
            Items.OnItemSelected += ItemSelected;
        }