Beispiel #1
0
        public LatheQueueMenu(LatheBoundUserInterface owner)
        {
            Owner   = owner;
            SetSize = MinSize = (300, 450);
            Title   = Loc.GetString("Lathe Queue");

            var vBox = new VBoxContainer();

            var hBox = new HBoxContainer()
            {
                HorizontalExpand      = true,
                SizeFlagsStretchRatio = 2,
            };

            _icon = new TextureRect()
            {
                HorizontalExpand      = true,
                SizeFlagsStretchRatio = 2,
            };

            var vBoxInfo = new VBoxContainer()
            {
                VerticalExpand        = true,
                SizeFlagsStretchRatio = 3,
            };

            _nameLabel = new Label()
            {
                RectClipContent = true,
            };

            _description = new Label()
            {
                RectClipContent   = true,
                VerticalAlignment = VAlignment.Stretch,
                VerticalExpand    = true
            };

            _queueList = new ItemList()
            {
                VerticalExpand        = true,
                SizeFlagsStretchRatio = 3,
                SelectMode            = ItemList.ItemListSelectMode.None
            };

            vBoxInfo.AddChild(_nameLabel);
            vBoxInfo.AddChild(_description);

            hBox.AddChild(_icon);
            hBox.AddChild(vBoxInfo);

            vBox.AddChild(hBox);
            vBox.AddChild(_queueList);

            Contents.AddChild(vBox);

            ClearInfo();
        }
Beispiel #2
0
        public LatheMenu(LatheBoundUserInterface owner = null)
        {
            IoCManager.InjectDependencies(this);

            Owner = owner;

            Title = "Lathe Menu";

            var margin = new MarginContainer()
            {
                SizeFlagsVertical   = SizeFlags.FillExpand,
                SizeFlagsHorizontal = SizeFlags.FillExpand,
            };

            var vBox = new VBoxContainer()
            {
                SizeFlagsVertical  = SizeFlags.FillExpand,
                SeparationOverride = 5,
            };

            var hBoxButtons = new HBoxContainer()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
            };

            QueueButton = new Button()
            {
                Text                  = "Queue",
                TextAlign             = Label.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsStretchRatio = 1,
            };

            ServerConnectButton = new Button()
            {
                Text                  = "Server list",
                TextAlign             = Label.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsStretchRatio = 1,
            };

            ServerSyncButton = new Button()
            {
                Text                  = "Sync",
                TextAlign             = Label.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsStretchRatio = 1,
            };

            var spacer = new Control()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3,
            };

            var hBoxFilter = new HBoxContainer()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1
            };

            _searchBar = new LineEdit()
            {
                PlaceHolder           = "Search Designs",
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3
            };

            _searchBar.OnTextChanged += Populate;

            var filterButton = new Button()
            {
                Text                  = "Filter",
                TextAlign             = Label.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsStretchRatio = 1,
                Disabled              = true,
            };

            _items = new ItemList()
            {
                SizeFlagsStretchRatio = 8,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SelectMode            = ItemList.ItemListSelectMode.Button,
            };

            _items.OnItemSelected += ItemSelected;

            _amountLineEdit = new LineEdit()
            {
                PlaceHolder         = "Amount",
                Text                = "1",
                SizeFlagsHorizontal = SizeFlags.FillExpand,
            };

            _amountLineEdit.OnTextChanged += PopulateDisabled;

            _materials = new ItemList()
            {
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3
            };

            hBoxButtons.AddChild(spacer);
            if (Owner?.Database is ProtolatheDatabaseComponent database)
            {
                hBoxButtons.AddChild(ServerConnectButton);
                hBoxButtons.AddChild(ServerSyncButton);
                database.OnDatabaseUpdated += Populate;
            }
            hBoxButtons.AddChild(QueueButton);

            hBoxFilter.AddChild(_searchBar);
            hBoxFilter.AddChild(filterButton);

            vBox.AddChild(hBoxButtons);
            vBox.AddChild(hBoxFilter);
            vBox.AddChild(_items);
            vBox.AddChild(_amountLineEdit);
            vBox.AddChild(_materials);

            margin.AddChild(vBox);

            Contents.AddChild(margin);
        }