Ejemplo n.º 1
0
        public void SetupRebindPanel()
        {
            GridContainer Container = new GridContainer()
            {
                Columns = 2,
            };

            Container.AddConstantOverride("hseparation", 25);
            Container.AddConstantOverride("vseparation", 5);

            rebindPanel.GetChild(0).AddChild(Container);

            Container.AddChild(new Label() { Text = "Action"});
            Container.AddChild(new Label() { Text = "Keyboard" });


            for (int i = 0; i < allActions.Length; i++)
            {
                if (allActions[i].KeyboardBinding != null)
                {
                    for (int j = 0; j < allActions[i].KeyboardBinding.Length; j++)
                    {
                        Container.AddChild(new Label() { Text = allActions[i].KeyboardBinding[j].Name });
                        Container.AddChild(new Button() { Text = ((KeyList)(allActions[i].KeyboardBinding[j].Key)).ToString()  });
                    }
                }
            }
        }
Ejemplo n.º 2
0
    public void SetHeight(int height)
    {
        // add more
        if (this.height < height)
        {
            for (int i = width * this.height; i < width * height; i++)
            {
                ColorRect rect = new ColorRect();
                rect.SetFrameColor(wallColour);

                rect.SetCustomMinimumSize(blockSize);
                container.AddChild(rect);

                map.Add(false);
            }
        }
        // remove more
        else
        {
            for (int i = width * height; i < width * this.height; i++)
            {
                container.GetChild(i).QueueFree();
            }
            map.RemoveRange(width * height, (this.height - height) * width);
        }

        this.height = height;
    }
Ejemplo n.º 3
0
        public void TestBasic()
        {
            var grid = new GridContainer {
                Columns = 2
            };
            var child1 = new Control {
                CustomMinimumSize = (50, 50)
            };
            var child2 = new Control {
                CustomMinimumSize = (50, 50)
            };
            var child3 = new Control {
                CustomMinimumSize = (50, 50)
            };
            var child4 = new Control {
                CustomMinimumSize = (50, 50)
            };
            var child5 = new Control {
                CustomMinimumSize = (50, 50)
            };

            grid.AddChild(child1);
            grid.AddChild(child2);
            grid.AddChild(child3);
            grid.AddChild(child4);
            grid.AddChild(child5);

            Assert.That(grid.CombinedMinimumSize, Is.EqualTo(new Vector2(104, 158)));

            Assert.That(child1.Position, Is.EqualTo(Vector2.Zero));
            Assert.That(child2.Position, Is.EqualTo(new Vector2(54, 0)));
            Assert.That(child3.Position, Is.EqualTo(new Vector2(0, 54)));
            Assert.That(child4.Position, Is.EqualTo(new Vector2(54, 54)));
            Assert.That(child5.Position, Is.EqualTo(new Vector2(0, 108)));
        }
Ejemplo n.º 4
0
        public GridContainer CreateAnimation(string buttonText, Color boxColor, CoreTriggerAction animation)
        {
            var box = new BoxView()
            {
                HeightRequest   = 28,
                WidthRequest    = 28,
                BackgroundColor = boxColor
            };

            animation.Animation.Target = box;

            var trigger = new EventTrigger()
            {
                Event   = "Clicked",
                Actions = { animation }
            };

            var btn = new CoreButton()
            {
                Text     = buttonText,
                Style    = CoreStyles.LightOrange,
                Triggers = { trigger }
            };

            var grid = new GridContainer(true);

            grid.AddChild(box, 0, 0);
            grid.AddChild(btn, 0, 1);
            return(grid);
        }
Ejemplo n.º 5
0
    public void BuildUI()
    {
        this.UI              = new Panel();
        this.UI.RectMinSize  = new Vector2(240, 32 + Props.Length * 27);
        this.UI.MarginBottom = 10;

        HBoxContainer btnRow = new HBoxContainer();

        btnRow.RectPosition = new Vector2(141, 0);

        Button btnClose = new Button();

        btnClose.Text = " X ";

        Button btnUp = new Button();

        btnUp.Text = " ^ ";

        Button btnDown = new Button();

        btnDown.Text = " v ";

        btnRow.AddChild(btnUp);
        btnRow.AddChild(btnDown);
        btnRow.AddChild(btnClose);

        btnClose.Connect("pressed", this, nameof(OnRemove));
        btnUp.Connect("pressed", FilterStack.instance, nameof(FilterStack.instance.MoveFilter), new Godot.Collections.Array {
            this, true
        });
        btnDown.Connect("pressed", FilterStack.instance, nameof(FilterStack.instance.MoveFilter), new Godot.Collections.Array {
            this, false
        });

        GridContainer UIGrid = new GridContainer();

        UIGrid.Columns = 2;

        Label labelName = new Label();

        labelName.Name = "Labelname";
        labelName.Text = this.Name;
        this.UI.AddChild(labelName);
        this.UI.AddChild(btnRow);

        foreach (var cProp in this.Props)
        {
            HBoxContainer HBox      = new HBoxContainer();
            Label         propLabel = new Label();
            propLabel.Text = cProp.NameUI;

            UIGrid.AddChild(propLabel);
            UIGrid.AddChild(cProp.BuildUI());
        }
        UIGrid.RectPosition = new Vector2(0, 32);
        this.UI.AddChild(UIGrid);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Display column titles for the Student's CreatedLevels
    /// </summary>
    private void DisplayHeader()
    {
        //Student Name
        Label lbl = new Label();

        lbl.AddFontOverride("font", dFont);
        lbl.Text = "Game Name" + "       ";
        lbl.AddColorOverride("font_color", new Color(0, 0, 0));

        gridContainer.AddChild(lbl);

        Label lbl3 = new Label();

        lbl3.AddFontOverride("font", dFont);
        lbl3.Text = "           ";
        lbl3.AddColorOverride("font_color", new Color(0, 0, 0));
        gridContainer.AddChild(lbl3);

        Label lbl4 = new Label();

        lbl4.AddFontOverride("font", dFont);
        lbl4.Text = "   ";
        lbl4.AddColorOverride("font_color", new Color(0, 0, 0));
        gridContainer.AddChild(lbl4);

        Label lbl5 = new Label();

        lbl5.AddFontOverride("font", dFont);
        lbl5.Text = "   ";
        lbl5.AddColorOverride("font_color", new Color(0, 0, 0));
        gridContainer.AddChild(lbl5);
    }
Ejemplo n.º 7
0
            /// <summary>
            /// Creates a grid container filled with slot buttons loaded from an inventory template
            /// </summary>
            /// <param name="TemplateName"></param>
            public void CreateInventory(string TemplateName)
            {
                Type      type      = AppDomain.CurrentDomain.GetAssemblyByName("Content.Shared").GetType("Content.Shared.GameObjects." + TemplateName);
                Inventory inventory = (Inventory)Activator.CreateInstance(type);

                elements_x = inventory.Columns;

                GridContainer         = (GridContainer)Contents.GetChild("PanelContainer").GetChild("CenterContainer").GetChild("GridContainer");
                GridContainer.Columns = elements_x;
                IndexedSlots          = new List <Slots>(inventory.SlotMasks);

                foreach (Slots slot in IndexedSlots)
                {
                    InventoryButton newbutton = new InventoryButton(slot);

                    if (slot == Slots.NONE)
                    {
                        //TODO: Re-enable when godot grid container maintains grid with invisible elements
                        //newbutton.Visible = false;
                    }
                    else
                    {
                        //Store slot button and give it the default onpress behavior for empty elements
                        newbutton.GetChild <Button>("Button").OnPressed += AddToInventory;
                        InventorySlots.Add(slot, newbutton);
                    }

                    if (SlotNames.ContainsKey(slot))
                    {
                        newbutton.GetChild <Button>("Button").Text = SlotNames[slot];
                    }

                    GridContainer.AddChild(newbutton);
                }
            }
Ejemplo n.º 8
0
    public void DrawPlayerUnits()
    {
        ClearGridChildren();

        var cellIndex = 0;

        foreach (var playerUnit in _playerUnits)
        {
            var spawnCellScene = ResourceLoader.Load <PackedScene>("res://Assets/UI/SpawnQueue/SpawnCell.tscn");

            if (spawnCellScene != null)
            {
                var spawnCellInstance = (SpawnCell)spawnCellScene.Instance();

                _gridContainer.AddChild(spawnCellInstance);

                var cellSprite    = playerUnit.GetAnimatedSprite();
                var spriteTexture = cellSprite.Frames.GetFrame("down", 1);

                spawnCellInstance.SetCellIndex(cellIndex);
                spawnCellInstance.SetCellSprite(spriteTexture);

                spawnCellInstance.Connect("SpawnCellClicked", this, "_On_SpawnCellClicked");

                cellIndex++;
            }
        }

        HighlightCell(0);
        SetSelectedPlayerUnit(0);
    }
Ejemplo n.º 9
0
    public override void _Ready()
    {
        sprites = new GridSprite[Instance.maxX][];
        grid    = GetNode <GridContainer>("NumberGrid");
        Grid   g    = new Grid(5, 5);
        Random rand = new Random(2);
        var    path = g.RandomPath(rand);

        g.FillPath(30, 90, path, rand);
        grid.Columns = Instance.maxX;
        for (int x = 0; x < Instance.maxX; x++)
        {
            sprites[x] = new GridSprite[Instance.maxY];
            for (int y = 0; y < Instance.maxY; y++)
            {
                sprites[x][y] = new GridSprite
                {
                    type   = g.At(x, y).op,
                    number = g.At(x, y).value
                };
                grid.AddChild(sprites[x][y]);
            }
        }

        foreach (var xy in path)
        {
            sprites[xy.x][xy.y].Modulate = Color.ColorN("red");
        }
    }
            /// <summary>
            ///     Creates a grid container filled with slot buttons loaded from an inventory template
            /// </summary>
            public void CreateInventory(Inventory inventory)
            {
                elements_x = inventory.Columns;

                GridContainer         = (GridContainer)GetChild("CenterContainer").GetChild("GridContainer");
                GridContainer.Columns = elements_x;
                IndexedSlots          = new List <Slots>(inventory.SlotMasks);

                foreach (Slots slot in IndexedSlots)
                {
                    InventoryButton newbutton = new InventoryButton(slot);

                    if (slot == Slots.NONE)
                    {
                        //TODO: Re-enable when godot grid container maintains grid with invisible elements
                        //newbutton.Visible = false;
                    }
                    else
                    {
                        //Store slot button and give it the default onpress behavior for empty elements
                        newbutton.GetChild <Button>("Button").OnPressed += AddToInventory;
                        InventorySlots.Add(slot, newbutton);
                    }

                    if (SlotNames.ContainsKey(slot))
                    {
                        var button = newbutton.GetChild <Button>("Button");
                        button.Text = button.ToolTip = SlotNames[slot];
                    }

                    GridContainer.AddChild(newbutton);
                }
            }
Ejemplo n.º 11
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        width  = 79;
        height = 45;
        map    = new List <bool>();
        timer  = new Timer();
        AddChild(timer);
        AddUserSignal("finished");
        AddUserSignal("finished_generating");
        AddUserSignal("finished_pathfinding", new Godot.Collections.Array {
            this, new Godot.Collections.Array <int> (), new Godot.Collections.Array <int>()
        });

        container = GetNode("GridContainer") as GridContainer;
        container.SetColumns(width);

        for (int i = 0; i < width * height; i++)
        {
            ColorRect rect = new ColorRect();
            rect.SetFrameColor(wallColour);

            rect.SetCustomMinimumSize(blockSize);
            container.AddChild(rect);

            map.Add(false);
        }

        ResizeBlock();
    }
Ejemplo n.º 12
0
        public void UpdateHeldBlock(BlockGameBlock[] blocks)
        {
            _holdBlockGrid.RemoveAllChildren();
            if (blocks.Length == 0)
            {
                return;
            }
            var columnCount = blocks.Max(b => b.Position.X) + 1;
            var rowCount    = blocks.Max(b => b.Position.Y) + 1;

            _holdBlockGrid.Columns = columnCount;
            for (int y = 0; y < rowCount; y++)
            {
                for (int x = 0; x < columnCount; x++)
                {
                    var c = GetColorForPosition(blocks, x, y);
                    _holdBlockGrid.AddChild(new PanelContainer
                    {
                        PanelOverride = new StyleBoxFlat {
                            BackgroundColor = c
                        },
                        CustomMinimumSize  = blockSize,
                        RectDrawClipMargin = 0
                    });
                }
            }
        }
Ejemplo n.º 13
0
    public override void _Ready()
    {
        Alpha = GD.Load("res://UI/Textures/Alpha.png") as Texture;
        InventoryIconScene = GD.Load <PackedScene>("res://UI/InventoryIcon.tscn");

        PlayerVBox = GetNode <VBoxContainer>("HBoxContainer/PlayerCenter/PlayerVBox");
        OtherGrid  = GetNode <GridContainer>("HBoxContainer/OtherVBox/OtherCenter/OtherGrid");

        Game.PossessedPlayer.MatchSome(
            (Plr) => {
            PlayerIcons = new InventoryIcon[Plr.Inventory.Contents.Length];
            for (int Index = 0; Index < Plr.Inventory.Contents.Length; Index++)
            {
                InventoryIcon Icon = InstantiateIcon(Index, Plr);
                PlayerVBox.AddChild(Icon);
                PlayerIcons[Index] = Icon;
            }
        }
            );

        if (Other != null)
        {
            OtherIcons = new InventoryIcon[Other.Inventory.Contents.Length];
            for (int Index = 0; Index < Other.Inventory.Contents.Length; Index++)
            {
                InventoryIcon Icon = InstantiateIcon(Index, Other);
                OtherGrid.AddChild(Icon);
                OtherIcons[Index] = Icon;
            }
        }
    }
Ejemplo n.º 14
0
        private void RefreshList()
        {
            // Clear
            _grid.RemoveAllChildren();
            if (_decals == null)
            {
                return;
            }

            var filter = _search.Text;

            foreach (var(decal, tex) in _decals)
            {
                if (!decal.Contains(filter))
                {
                    continue;
                }

                var button = new TextureButton()
                {
                    TextureNormal = tex,
                    Name          = decal,
                    ToolTip       = decal,
                    Modulate      = _color
                };
                button.OnPressed += ButtonOnPressed;
                if (_selected == decal)
                {
                    var panelContainer = new PanelContainer()
                    {
                        PanelOverride = new StyleBoxFlat()
                        {
                            BackgroundColor = StyleNano.ButtonColorDefault,
                        },
                        Children =
                        {
                            button
                        }
                    };
                    _grid.AddChild(panelContainer);
                }
                else
                {
                    _grid.AddChild(button);
                }
            }
        }
Ejemplo n.º 15
0
        public void DropItems(string enemyName, Player playerInstance)
        {
            _playerInstance = playerInstance;
            var enemyRecord  = Autoload.Get <Data>().enemyData[enemyName];
            var coinsDropped = (int)GD.RandRange(
                enemyRecord.CoinDropAmount * MIN_COIN_DROP, enemyRecord
                .CoinDropAmount * MAX_COIN_DROP + 1);

            if (coinsDropped <= 0 && enemyRecord.CoinDropAmount > 0)
            {
                coinsDropped = 1;
            }

            _coinAmountLabel.Text  = $"{coinsDropped}";
            _playerInstance.Coins += coinsDropped;

            foreach (Node child in _itemsDroppedGrid.GetChildren())
            {
                child.QueueFree();
            }

            var items = new Dictionary <string, float>();

            if (!string.IsNullOrWhiteSpace(enemyRecord.ItemDrop1))
            {
                items.Add(enemyRecord.ItemDrop1, enemyRecord.ItemDrop1Chance);
            }

            if (!string.IsNullOrWhiteSpace(enemyRecord.ItemDrop2))
            {
                items.Add(enemyRecord.ItemDrop2, enemyRecord.ItemDrop2Chance);
            }

            if (!string.IsNullOrWhiteSpace(enemyRecord.ItemDrop3))
            {
                items.Add(enemyRecord.ItemDrop3, enemyRecord.ItemDrop3Chance);
            }

            for (var i = 0; i < enemyRecord.MaxItemDropped; i++)
            {
                var chance = Utility.Random.NextDouble();
                foreach (var item in items)
                {
                    if (chance < item.Value)
                    {
                        var itemDropped = ItemDroppedResource.Instance();
                        itemDropped.GetNode <TextureRect>("Item").Texture =
                            Utility.GetInventoryItemResource(item.Key);
                        _itemsDroppedGrid.AddChild(itemDropped);
                        playerInstance.Inventory.Add(item.Key);
                    }
                }
            }

            playerInstance.hudMargin.Visible = false;
            margin.Visible = true;
            _autoCloseTimer.Start();
        }
Ejemplo n.º 16
0
 static void Main(string[] args)
 {
     Console.OutputEncoding = Encoding.Unicode;
     ConsoleManager cm = new ConsoleManager();
     //Canvas canvas = new Canvas(ConsoleColor.Gray);
     GridContainer container = new GridContainer();
     var SmallBox1 = new BoxObject(4, 4);
     var SmallBox2 = new BoxObject(4, 4);
     var SmallBox3 = new BoxObject(4, 4);
     var SmallBox4 = new BoxObject(15, 15);
     var BigBox1 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.DoubleLine };
     var BigBox2 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.DoubleHorizontalSingleVertical };
     var BigBox3 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.SingleHorizontalDoubleVertical };
     cm.AddObject(container);
     container.AddChild(SmallBox1);
     container.AddChild(SmallBox2);
     container.AddChild(SmallBox3);
     Console.ReadLine();
     for (int i = 0; i < 20; i++ )
         SmallBox2.UpdateSize = new Point(i, i);
     for (int i = 20; i >= 4; i--)
         SmallBox2.UpdateSize = new Point(i, i);
     Console.ReadLine();
     SmallBox2.UpdateSize = new Point(50, 50);
     GridContainer container2 = new GridContainer();
     Console.ReadLine();
     SmallBox2.AddChild(container2);
     Console.ReadLine();
     container2.AddChild(new TextObject("This is an embedded element."));
     Console.ReadLine();
     container2.AddChild(SmallBox1);
     Console.ReadLine();
     container2.AddChild(BigBox1);
     Console.ReadLine();
     container2.AddChild(BigBox2);
     Console.ReadLine();
     container2.AddChild(BigBox3);
     Console.ReadLine();
     BigBox1.AddChild(SmallBox4);
     Console.ReadLine();
     SmallBox4.AddChild(new TextObject("Hello World"));
     Console.ReadLine();
     container.RemoveChild(BigBox1);
     Console.ReadLine();
 }
Ejemplo n.º 17
0
        private async void UpdateInventoryUI()
        {
            if (_chestInstance == null)
            {
                GD.PushError("Chest instance not found");
                return;
            }

            var movableInventory = new List <string>(_playerInstance.Inventory);

            movableInventory.Remove(_playerInstance.EquippedWeapon);
            movableInventory.Remove(_playerInstance.EquippedArmor);

            foreach (Node child in _inventoryContents.GetChildren())
            {
                child.QueueFree();
            }

            var childCount = _inventoryContents.GetChildCount();

            if (childCount > 0)
            {
                await ToSignal(_inventoryContents.GetChild(childCount - 1),
                               "tree_exited");
            }

            foreach (var itemName in movableInventory)
            {
                var inventoryItem = (ChestItems)ChestItemResource.Instance();
                inventoryItem.ItemName = itemName;
                _inventoryContents.AddChild(inventoryItem);
            }

            for (var i = 0; i < 8; i++)
            {
                var inventoryItem = (ChestItems)ChestItemResource.Instance();
                _inventoryContents.AddChild(inventoryItem);
            }

            foreach (ChestItems inventoryItems in _inventoryContents.GetChildren())
            {
                inventoryItems.Connect(nameof(ChestItems.LeftClicked), this,
                                       nameof(OnInventoryItem_LeftClicked));
            }
        }
Ejemplo n.º 18
0
 void Start()
 {
     panel = GridContainer.Create(new Vector3(.2f, .2f), new Vector2(300, 300), 3, 3);
     for (int g = 0; g < 9; g++)
     {
         panel.AddChild(BaseImage.Create("GUI/Button", new Vector3()));
         panel.elements[g].Click += EternityGUITester_Click;
     }
 }
Ejemplo n.º 19
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     container = GetNode <GridContainer>("GridContainer");
     container.AddChild(new Label()
     {
         Text = "hej"
     });
     JsonParser.DeserializeJsonFile(JsonParser.Path);
     // ReadXml();
 }
Ejemplo n.º 20
0
 private void Refresh()
 {
     container.QueueFreeChildren();
     foreach (Item item in Game.data.inventory.items)
     {
         var itemTable = Visual.Tables.ItemTable.New();
         container.AddChild(itemTable);
         itemTable.SetItem(item);
     }
 }
Ejemplo n.º 21
0
        public GridContainer CreateDataTrigger()
        {
            var box = new BoxView()
            {
                HeightRequest   = 28,
                WidthRequest    = 28,
                BackgroundColor = Color.Crimson
            };

            var fadeAnimation = new CoreTriggerAction()
            {
                Animation = new CoreFadeToAnimation()
                {
                    Target   = box,
                    Duration = "300",
                    Opacity  = 0
                }
            };

            var trigger = new DataTrigger(typeof(Button))
            {
                Binding      = new Binding(path: "ClickCount", mode: BindingMode.TwoWay),
                Value        = 3,
                EnterActions = { fadeAnimation }
            };


            var btn = new CoreButton()
            {
                Text     = "Data Trigger (3)",
                Style    = CoreStyles.LightOrange,
                Triggers = { trigger }
            };

            btn.SetBinding(CoreButton.CommandProperty, "ClickEvent");

            var grid = new GridContainer(true);

            grid.AddChild(box, 0, 0);
            grid.AddChild(btn, 0, 1);
            return(grid);
        }
Ejemplo n.º 22
0
 private void Refresh()
 {
     if (Visible)
     {
         container.QueueFreeChildren();
         foreach (CharacterEntity entity in Family.familyMembers)
         {
             container.AddChild(Visual.Tables.JobTable.Create(entity));
         }
     }
 }
Ejemplo n.º 23
0
        public void TestUnevenLimitSize()
        {
            // when uneven sizes are used and limiting by size, they should all be treated as equal size cells based on the
            // max minwidth / minheight among them.
            // Note that when limiting by count, the behavior is different - rows and columns are individually
            // expanded based on the max size of their elements
            var grid = new GridContainer {
                MaxGridWidth = 125
            };
            var child1 = new Control {
                MinSize = (12, 24)
            };
            var child2 = new Control {
                MinSize = (30, 50)
            };
            var child3 = new Control {
                MinSize = (40, 20)
            };
            var child4 = new Control {
                MinSize = (20, 12)
            };
            var child5 = new Control {
                MinSize = (50, 10)
            };

            grid.AddChild(child1);
            grid.AddChild(child2);
            grid.AddChild(child3);
            grid.AddChild(child4);
            grid.AddChild(child5);

            grid.Arrange(new UIBox2(0, 0, 250, 250));

            Assert.That(grid.DesiredSize, Is.EqualTo(new Vector2(104, 158)));

            Assert.That(child1.Position, Is.EqualTo(Vector2.Zero));
            Assert.That(child2.Position, Is.EqualTo(new Vector2(54, 0)));
            Assert.That(child3.Position, Is.EqualTo(new Vector2(0, 54)));
            Assert.That(child4.Position, Is.EqualTo(new Vector2(54, 54)));
            Assert.That(child5.Position, Is.EqualTo(new Vector2(0, 108)));
        }
Ejemplo n.º 24
0
        private Control SetupHoldBox(Texture panelTex)
        {
            var previewBack = new StyleBoxTexture
            {
                Texture  = panelTex,
                Modulate = Color.FromHex("#4a4a51")
            };

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

            var grid = new GridContainer
            {
                Columns               = 1,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 20
            };

            var holdBlockPanel = new PanelContainer
            {
                PanelOverride       = previewBack,
                CustomMinimumSize   = blockSize * 6.5f,
                SizeFlagsHorizontal = SizeFlags.None,
                SizeFlagsVertical   = SizeFlags.None
            };
            var holdCenterContainer = new CenterContainer();

            _holdBlockGrid = new GridContainer
            {
                HSeparationOverride = 1,
                VSeparationOverride = 1
            };
            holdCenterContainer.AddChild(_holdBlockGrid);
            holdBlockPanel.AddChild(holdCenterContainer);
            grid.AddChild(holdBlockPanel);

            grid.AddChild(new Label {
                Text = "Hold", Align = Label.AlignMode.Center
            });

            return(grid);
        }
Ejemplo n.º 25
0
 private void CreateInventoryCells()
 {
     for (int i = 0; i < PlayerInventory.Items.Count; i++)
     {
         var inventoryCell = _resourcePreloader.InstanceScene <InventoryCell>();
         _gridContainer.AddChild(inventoryCell);
         inventoryCell.Connect(nameof(InventoryCell.Selected), this, nameof(OnCellSelected), new Godot.Collections.Array()
         {
             i
         });
     }
 }
        public CargoConsoleOrderMenu()
        {
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("cargo-console-order-menu-title");

            var vBox          = new VBoxContainer();
            var gridContainer = new GridContainer {
                Columns = 2
            };

            var requesterLabel = new Label {
                Text = Loc.GetString("cargo-console-order-menu-requester-label")
            };

            Requester = new LineEdit();
            gridContainer.AddChild(requesterLabel);
            gridContainer.AddChild(Requester);

            var reasonLabel = new Label {
                Text = Loc.GetString("cargo-console-order-menu-reason-label:")
            };

            Reason = new LineEdit();
            gridContainer.AddChild(reasonLabel);
            gridContainer.AddChild(Reason);

            var amountLabel = new Label {
                Text = Loc.GetString("cargo-console-order-menu-amount-label:")
            };

            Amount = new SpinBox
            {
                HorizontalExpand = true,
                Value            = 1
            };
            Amount.SetButtons(new List <int>()
            {
                -3, -2, -1
            }, new List <int>()
            {
                1, 2, 3
            });
            Amount.IsValid = (n) => {
                return(n > 0);
            };
            gridContainer.AddChild(amountLabel);
            gridContainer.AddChild(Amount);

            vBox.AddChild(gridContainer);

            SubmitButton = new Button()
            {
                Text      = Loc.GetString("cargo-console-order-menu-submit-button"),
                TextAlign = Label.AlignMode.Center,
            };
            vBox.AddChild(SubmitButton);

            Contents.AddChild(vBox);
        }
Ejemplo n.º 27
0
        public CargoConsoleOrderMenu()
        {
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("Order Form");

            var vBox          = new VBoxContainer();
            var gridContainer = new GridContainer {
                Columns = 2
            };

            var requesterLabel = new Label {
                Text = Loc.GetString("Name:")
            };

            Requester = new LineEdit();
            gridContainer.AddChild(requesterLabel);
            gridContainer.AddChild(Requester);

            var reasonLabel = new Label {
                Text = Loc.GetString("Reason:")
            };

            Reason = new LineEdit();
            gridContainer.AddChild(reasonLabel);
            gridContainer.AddChild(Reason);

            var amountLabel = new Label {
                Text = Loc.GetString("Amount:")
            };

            Amount = new SpinBox
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                Value = 1
            };
            Amount.SetButtons(new List <int>()
            {
                -100, -10, -1
            }, new List <int>()
            {
                1, 10, 100
            });
            Amount.IsValid = (n) => {
                return(n > 0);
            };
            gridContainer.AddChild(amountLabel);
            gridContainer.AddChild(Amount);

            vBox.AddChild(gridContainer);

            SubmitButton = new Button()
            {
                Text      = Loc.GetString("OK"),
                TextAlign = Label.AlignMode.Center,
            };
            vBox.AddChild(SubmitButton);

            Contents.AddChild(vBox);
        }
Ejemplo n.º 28
0
    /// <summary>
    /// Display the header for Leaderboard
    /// </summary>
    private void AddHeader()
    {
        dFont          = new DynamicFont();
        dFont.FontData = ResourceLoader.Load("res://Fonts/Candy Beans.otf") as DynamicFontData;
        dFont.Size     = 26;

        Label rank = new Label();

        rank.AddFontOverride("font", dFont);
        rank.Text = "Rank                               ";
        rank.AddColorOverride("font_color", new Color(0, 0, 0));
        gridContainer.AddChild(rank);

        Label lbl = new Label();

        lbl.AddFontOverride("font", dFont);
        lbl.Text = "Name                                    ";
        lbl.AddColorOverride("font_color", new Color(0, 0, 0));
        gridContainer.AddChild(lbl);

        Label lbl2 = new Label();

        lbl2.AddFontOverride("font", dFont);
        lbl2.Text = "Score";
        lbl2.AddColorOverride("font_color", new Color(0, 0, 0));
        gridContainer.AddChild(lbl2);
    }
Ejemplo n.º 29
0
        private Control CreateBottomMenuControl()
        {
            var container = new GridContainer()
            {
                RectMinSize = new Vector2(100, 100),
            };
            var button = new Button {
                Text = "Refresh"
            };

            button.Connect("pressed", this, nameof(OnRefreshPressed));
            container.AddChild(button);
            return(container);
        }
Ejemplo n.º 30
0
    /// <summary>
    /// Display the Credits
    /// </summary>
    private void DisplayCredits()
    {
        Godot.File file = new Godot.File();
        file.Open("res://Credits/credits.txt", Godot.File.ModeFlags.Read);
        string content = file.GetAsText();

        file.Close();
        Label name = new Label();

        name.AddFontOverride("font", dFont);
        name.Text = content;
        name.AddColorOverride("font_color", new Color(0, 0, 0));
        gridContainer.AddChild(name);
    }
Ejemplo n.º 31
0
        public virtual Node GetOptionEntry()
        {
            var grid = new GridContainer {
                Columns = 2
            };
            var label = new Label {
                Text = Name,
                SizeFlagsHorizontal = (int)Control.SizeFlags.Expand
            };


            grid.AddChild(label);
            return(grid);
        }
Ejemplo n.º 32
0
    public override void _Ready()
    {
        invGrid  = (GridContainer)GetNode("inv_grid");
        Tooltip  = (Tooltip)GetNode("tooltip_layer/tooltip_panel");
        invSlots = new InvSlot[20];
        for (int i = 0; i < invSlots.Length; i++)
        {
            invSlots[i]       = new InvSlot();
            invSlots[i].Theme = invGrid.Theme;
            invGrid.AddChild(invSlots[i]);
        }

        Instance = this;
    }