Exemple #1
0
        public CraftingTab(GameState gameState, List <Recipe> recipies = null) : base(gameState)
        {
            Icon         = new Sprite(Ressources.TileIcons, new Point(4, 2));
            CraftingList = new ListWidget
            {
                Dock       = Dock.Fill,
                ItemHeight = 64,
            };

            var craftButton = new Button
            {
                Text = "Craft",
                Dock = Dock.Bottom,
            };

            craftButton.MouseClick += Craft;

            foreach (var recipe in recipies ?? RECIPIES.HandCrafted)
            {
                CraftingList.AddItem(new CraftingListItem(recipe, GameState.LocalPlayer.Entity.GetComponent <Inventory>().Content));
            }

            Content = new Container()
            {
                Childrens =
                {
                    new Label {
                        Text = "Crafting", Font = Ressources.FontAlagard, Dock = Dock.Top
                    },
                    craftButton, CraftingList,
                }
            };
        }
Exemple #2
0
        public TabLoadWorld()
        {
            Icon = new Sprite(Ressources.TileIcons, new Point(2, 2));

            var title = new Label
            {
                Text = "Load World",
                Font = Ressources.FontAlagard,
                Dock = Dock.Top
            };

            var saveList = new ListWidget()
            {
                Dock = Dock.Fill
            };

            var loadButton = new Button
            {
                Text = "Load",
                Dock = Dock.Bottom
            }
            .RegisterMouseClickEvent((sender) =>
            {
                if (saveList.SelectedItem != null)
                {
                    var item = (ListItemText)saveList.SelectedItem;
                    Game.Play(item.Text);
                }
            });

            Content = new Container(title, loadButton, saveList);

            var s = Directory.GetDirectories(Game.GetSaveFolder());

            foreach (var save in s)
            {
                saveList.AddItem(new ListItemText(save));
            }
        }
Exemple #3
0
        public TabNewWorld()
        {
            Icon = new Sprite(Ressources.TileIcons, new Point(1, 2));

            var worldNameTextBox = new SingleLineTextBoxWidget(24, "new world", Ressources.FontRomulus)
            {
                Padding = new Margins(8)
            };

            var worldSeedtextBox = new SingleLineTextBoxWidget(24, Rise.Rnd.Next().ToString(), Ressources.FontRomulus)
            {
                Padding = new Margins(8)
            };

            var worldTypeList = new ListWidget()
            {
                UnitBound = new Rectangle(0, 0, 256, 128), AlowUnselecting = false
            };

            foreach (var item in GENERATOR.GENERATORS)
            {
                worldTypeList.AddItem(new ListItemText(item.Key));
            }

            worldTypeList.SelectFirst();

            var generateButton = new Button {
                Text = "Generate", Dock = Dock.Bottom
            }
            .RegisterMouseClickEvent((s) => Game.New(worldNameTextBox.Text.String, worldSeedtextBox.Text.String, GENERATOR.GENERATORS[((ListItemText)worldTypeList.SelectedItem).Text]));

            var worldOptions = new FlowLayout
            {
                Flow      = FlowDirection.TopToBottom,
                Dock      = Dock.Fill,
                Childrens =
                {
                    new Label {
                        Text = "World name:", Padding = new Margins(8), TextAlignement = DrawText.Alignement.Left
                    },
                    worldNameTextBox,
                    new Label {
                        Text = "Seed:", Padding = new Margins(8), TextAlignement = DrawText.Alignement.Left
                    },
                    worldSeedtextBox,
                    new Label {
                        Text = "World type:", Padding = new Margins(8), TextAlignement = DrawText.Alignement.Left
                    },
                    worldTypeList
                }
            };

            Content = new Container()
            {
                Childrens =
                {
                    new Label {
                        Text = "New World", Font = Ressources.FontAlagard, Dock = Dock.Top
                    },
                    generateButton,
                    worldOptions,
                }
            };
        }