Example #1
0
        public void CreateBuyTab()
        {
            TabSelector.Tab buyTab = Tabs.AddTab("Buy");

            GridLayout buyBoxLayout = new GridLayout(GUI, buyTab, 10, 4);

            BuySelector = new ItemSelector(GUI, buyBoxLayout, "Items", false, false)
            {
                Columns = new List <ItemSelector.Column>()
                {
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.PricePerItem,
                    ItemSelector.Column.ArrowRight
                },
                NoItemsMessage = "Nothing to buy",
                ToolTip        = "Click items to add them to the shopping cart"
            };

            buyBoxLayout.SetComponentPosition(BuySelector, 0, 0, 2, 10);

            BuySelector.Items.AddRange(GetResources(1.0f));
            BuySelector.ReCreateItems();


            ShoppingCart = new ItemSelector(GUI, buyBoxLayout, "Order", false, false)
            {
                Columns = new List <ItemSelector.Column>()
                {
                    ItemSelector.Column.ArrowLeft,
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.Amount,
                    ItemSelector.Column.TotalPrice
                },
                NoItemsMessage = "Nothing",
                ToolTip        = "Click items to remove them from the shopping cart",
                PerItemCost    = 1.00f
            };
            ShoppingCart.ReCreateItems();
            buyBoxLayout.SetComponentPosition(ShoppingCart, 2, 0, 2, 9);

            BuySelector.OnItemRemoved  += ShoppingCart.AddItem;
            ShoppingCart.OnItemRemoved += BuySelector.AddItem;
            ShoppingCart.OnItemChanged += shoppingCart_OnItemChanged;

            Button buyButton = new Button(GUI, buyBoxLayout, "Buy", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Click to order items in the shopping cart"
            };

            buyBoxLayout.SetComponentPosition(buyButton, 3, 9, 1, 2);

            BuyTotal = new Label(GUI, buyBoxLayout, "Order Total: $0.00", GUI.DefaultFont)
            {
                WordWrap = true,
                ToolTip  = "Order total"
            };


            buyBoxLayout.SetComponentPosition(BuyTotal, 2, 9, 1, 2);

            buyButton.OnClicked += buyButton_OnClicked;
        }
Example #2
0
        public void CreateSellTab()
        {
            TabSelector.Tab sellTab = Tabs.AddTab("Sell");

            GridLayout sellBoxLayout = new GridLayout(GUI, sellTab, 10, 4);

            SellSelector = new ItemSelector(GUI, sellBoxLayout, "Items", false, false)
            {
                Columns = new List <ItemSelector.Column>()
                {
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.Amount,
                    ItemSelector.Column.TotalPrice,
                    ItemSelector.Column.ArrowRight
                },
                NoItemsMessage = "No goods in our stockpiles",
                ToolTip        = "Click items to put them in the sell order"
            };

            sellBoxLayout.SetComponentPosition(SellSelector, 0, 0, 2, 10);

            SellSelector.Items.AddRange(GetResources(Faction.ListResources().Values.ToList()));
            SellSelector.ReCreateItems();


            SellCart = new ItemSelector(GUI, sellBoxLayout, "Order", false, false)
            {
                Columns = new List <ItemSelector.Column>()
                {
                    ItemSelector.Column.ArrowLeft,
                    ItemSelector.Column.Image,
                    ItemSelector.Column.Name,
                    ItemSelector.Column.Amount,
                    ItemSelector.Column.TotalPrice
                },
                NoItemsMessage = "No items selected",
                ToolTip        = "Click items to remove them from the sell order"
            };
            SellCart.ReCreateItems();
            sellBoxLayout.SetComponentPosition(SellCart, 2, 0, 2, 9);

            SellSelector.OnItemRemoved += SellCart.AddItem;
            SellCart.OnItemRemoved     += SellSelector.AddItem;

            Button sellButton = new Button(GUI, sellBoxLayout, "Sell", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Click to sell items in the order"
            };

            sellBoxLayout.SetComponentPosition(sellButton, 3, 9, 1, 2);

            sellButton.OnClicked += sellButton_OnClicked;

            SellTotal = new Label(GUI, sellBoxLayout, "Order Total: $0.00", GUI.DefaultFont)
            {
                WordWrap = true,
                ToolTip  = "Order total"
            };

            sellBoxLayout.SetComponentPosition(SellTotal, 2, 9, 1, 2);

            SellCart.OnItemChanged += SellCart_OnItemChanged;
        }