示例#1
0
        private void updateDisplayInfo()
        {
            shipLayout.UpdateButtons();

            if (scrollingList.HasSelection)
            {
                if (scrollingList.GetSelection().GetType() != typeof(Ship))
                {
                    InventoryListItem selection = (InventoryListItem)scrollingList.GetSelection();
                    Item item = selection.InventorySlot.Item;

                    descriptionBox.Text = string.Format("-{0}-\nWeight: {1}/{2}\n\n{3}",
                                                        item.Name,
                                                        item.Weight,
                                                        selection.InventorySlot.TotalWeight,
                                                        item.Description);
                }
            }
            else
            {
                descriptionBox.Text = string.Empty;
            }

            shipDesignationTitle.Text = shipLayout.Ship.Name;
            shipModelTitle.Text       = shipLayout.Ship.Model;

            shipAttackTitle.Text  = string.Format(" Attack: {0}", shipLayout.Ship.FirePower);
            shipDefenseTitle.Text = string.Format("Defense: {0}", shipLayout.Ship.DefenseRating);
            shipCargoTitle.Text   = string.Format("  Cargo: {0}/{1}", shipLayout.Ship.Inventory.TotalWeight, shipLayout.Ship.CargoCapacity);
            shipJumpTitle.Text    = string.Format("   Jump: {0}", shipLayout.Ship.JumpRadius);
        }
示例#2
0
    public void UpdateList()
    {
        Dictionary <Item, int> items = InventoryTarget.QueryInventory();

        foreach (KeyValuePair <Item, int> entry in items.ToArray())
        {
            if (!currentlyDisplayed.ContainsKey(entry.Key))
            {
                InventoryListItem instance = GameObject.Instantiate(
                    ListPrefab,
                    new Vector3(0, 0, 0),
                    Quaternion.identity,
                    transform);

                instance.SetData(entry.Key.icon, entry.Key.id, entry.Value.ToString());

                currentlyDisplayed.Add(entry.Key, instance);
            }
            else
            {
                currentlyDisplayed[entry.Key].count.text = entry.Value.ToString();
            }
        }

        // clean up items that have disappeared
        foreach (KeyValuePair <Item, InventoryListItem> entry in currentlyDisplayed)
        {
            if (!items.ContainsKey(entry.Key))
            {
                Destroy(entry.Value.gameObject);
                currentlyDisplayed.Remove(entry.Key);
            }
        }
    }
示例#3
0
    public InventoryListItem AddItemToList(Item item, ItemDetailsMenu.ItemDetailMenuContextType context)
    {
        InventoryListItem listItem = Instantiate(itemTemplate);

        listItem.gameObject.SetActive(true);

        listItem.GetComponent <InventoryListItem>().SetText(item, context);
        listItem.transform.SetParent(itemTemplate.transform.parent, false);

        return(listItem);
    }
        private void removeWineButton_Click(object sender, EventArgs e)
        {
            InventoryListItem item = (InventoryListItem)inventoryListView.SelectedObject;

            if (item != null)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure?", "Delete wine " + item.WineName, MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    AppDatabase.WineTable.DeleteWine(item.WineId);
                    inventoryListView.RemoveObject(item);
                }
            }
        }
示例#5
0
    public void SetSelected(InventoryListItem item)
    {
        if (_current == item)
        {
            return;
        }

        if (_current)
        {
            _current.SetSelected(false);
        }

        _current = item;
    }
        private void addWineButton_Click(object sender, EventArgs e)
        {
            // TODO: Implement add new wine entry.

            AddWineDialog dialog = new AddWineDialog();

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                InventoryItem inventoryItem = new InventoryItem(AddWineDialog.AddedWineId, AppDatabase.InventoryTable.GetQuantity(AddWineDialog.AddedWineId));

                InventoryListItem inventoryListItem = new InventoryListItem(AppDatabase.WineTable.GetWineById(AddWineDialog.AddedWineId), inventoryItem);

                inventoryListView.AddObject(inventoryListItem);
            }
        }
    public void handleSelectAndDeselect(InventoryListItem selectedItem)
    {
        bool isAnItemHighlighted = false;

        foreach (InventoryListItem listItem in itemsInList)
        {
            if (listItem != selectedItem)
            {
                listItem.SetIsHighlighted(false);
            }
            else
            {
                if (listItem.GetIsHighlighted())
                {
                    isAnItemHighlighted = true;
                }
            }
        }

        if (isAnItemHighlighted)
        {
            detailsButton.interactable = true;
        }
        else
        {
            detailsButton.interactable = false;
        }

        switch (context)
        {
        case ItemDetailsMenu.ItemDetailMenuContextType.Loadout:
            loadoutEquipmentMenu.HandleSelectedItem(selectedItem.GetItem(), selectedItem.GetIsHighlighted());
            break;

        case ItemDetailsMenu.ItemDetailMenuContextType.Shop:
            shopMenu.HandleSelectItem(selectedItem.GetItem(), selectedItem.GetIsHighlighted());
            break;
        }
    }
示例#8
0
 private void RemoveListItem(InventoryListItem listItem)
 {
     listItems.Remove(listItem);
     Destroy(listItem.gameObject);
 }
示例#9
0
        public ShipScreen(InterfaceManager manager)
            : base(manager)
        {
            shipDesignationTitle           = new Title(null, "USS Ravioli", 1, 1, Title.TextAlignModes.Left);
            shipDesignationTitle.TextColor = Color4.White;
            shipModelTitle           = new Title(null, "Disney Gummi mk1*", 1, 2, Title.TextAlignModes.Left);
            shipModelTitle.TextColor = Color4.Gray;

            backButton        = new Button(null, "Back", 0, GraphicConsole.BufferHeight - 3);
            backButton.Click += (sender, e) => InterfaceManager.ChangeInterface("Travel");

            equipButton   = new Button(null, "Equip", 14, GraphicConsole.BufferHeight - 3);
            unequipButton = new Button(null, "Unequip", 21, GraphicConsole.BufferHeight - 3);

            shipLayout          = new ShipLayout(null, 28, 19);
            shipLayout.Position = new System.Drawing.Point(1, GraphicConsole.BufferHeight - shipLayout.Size.Y - 3);

            previousShip = new Button(null, "◄", 1, shipLayout.Position.Y - 3);
            nextShip     = new Button(null, "►", shipLayout.Size.X - 2, shipLayout.Position.Y - 3);

            scrollingList            = new ScrollingList(null, 30, 2, GraphicConsole.BufferWidth - 31, 21);
            scrollingList.FillColor  = new Color4(50, 50, 50, 255);
            descriptionBox           = new TextBox(null, 30, 24, GraphicConsole.BufferWidth - 31, 12);
            descriptionBox.FillColor = new Color4(50, 50, 50, 255);

            Title inventoryTitle = new Title(null, "== Inventory ==", 30 + (GraphicConsole.BufferWidth - 31) / 2, 1, Title.TextAlignModes.Center);

            RegisterControl(inventoryTitle);

            shipAttackTitle  = new Title(null, " Attack: 0", 1, 4, Title.TextAlignModes.Left);
            shipDefenseTitle = new Title(null, "Defense: 0", 1, 5, Title.TextAlignModes.Left);
            shipCargoTitle   = new Title(null, "  Cargo: 0", 1, 6, Title.TextAlignModes.Left);
            shipJumpTitle    = new Title(null, "   Jump: 0", 1, 7, Title.TextAlignModes.Left);

            filterReset    = new Button(null, "Rst", 30, 1, 3, 1);
            materialFilter = new Button(null, "Min", 34, 1, 3, 1);
            modFilter      = new Button(null, "Mod", 38, 1, 3, 1);
            shipFilter     = new Button(null, "Ship", 42, 1, 4, 1);

            #region Control Events
            scrollingList.Selected += (sender, index) =>
            {
                //Selection can be an inventory item or a ship, check
                Type typeOfSelection = scrollingList.GetSelection().GetType();
                if (typeOfSelection == typeof(Ship))
                {
                    Ship ship = (Ship)scrollingList.GetSelection();
                    descriptionBox.Text = ship.Description;
                    shipLayout.SetShip(ship);

                    updateDisplayInfo();
                }
                else
                {
                    InventoryListItem selection = (InventoryListItem)scrollingList.GetSelection();
                    Item item = selection.InventorySlot.Item;

                    descriptionBox.Text = string.Format("-{0}-\nWeight: {1}/{2}\n\n{3}",
                                                        item.Name,
                                                        item.Weight,
                                                        selection.InventorySlot.TotalWeight,
                                                        item.Description);
                }
                InterfaceManager.DrawStep();
            };
            scrollingList.Deselected += (sender) =>
            {
                descriptionBox.Text = string.Empty;
                InterfaceManager.DrawStep();
            };
            shipLayout.NodeSelect += (sender, e) =>
            {
                ShipNode node = e.SelectedShipNode;
                setItemList(GameManager.PlayerShip.Inventory.GetInventoryList(node.ModType));
                inventoryTitle.Text = string.Format("== Inventory - Filter: {0} ==", node.ModType);

                //Display equipped Mod's description
                if (!node.Empty)
                {
                    descriptionBox.Text = string.Format("-{0}-\n{1}", node.Module.Name, node.Module.Description);
                }
                else
                {
                    descriptionBox.Text = string.Empty;
                }
            };
            equipButton.Click += (sender, e) =>
            {
                if (!scrollingList.HasSelection)
                {
                    return;
                }

                ListItem selectedItem = scrollingList.GetSelection();

                if (selectedItem.GetType() == typeof(Ship))
                {
                    Ship ship = (Ship)selectedItem;
                    GameManager.ChangePlayerShip(ship);

                    filterReset.Press(); //Trigger inventory reset
                }
                else
                {
                    InventorySlot slot = ((InventoryListItem)selectedItem).InventorySlot;
                    if (slot.Item.ItemType != ItemTypes.ShipMod)
                    {
                        return;
                    }

                    if (shipLayout.HasNodeSelected)
                    {
                        GameManager.PlayerShip.EquipModule(shipLayout.SelectedNode, (ShipMod)slot.Item, true);
                    }
                    else
                    {
                        GameManager.PlayerShip.EquipModule((ShipMod)slot.Item, true);
                    }

                    setItemList(GameManager.PlayerShip.Inventory.GetInventoryList());
                    inventoryTitle.Text = "== Inventory ==";
                }

                updateDisplayInfo();
                InterfaceManager.DrawStep();
            };
            unequipButton.Click += (sender, e) =>
            {
                if (!shipLayout.HasNodeSelected)
                {
                    return;
                }
                GameManager.PlayerShip.UnequipModule(shipLayout.SelectedNode, true);

                updateDisplayInfo();
                InterfaceManager.DrawStep();
            };
            filterReset.Click += (sender, e) =>
            {
                setItemList(GameManager.PlayerShip.Inventory.GetInventoryList());
                inventoryTitle.Text = "== Inventory ==";
                scrollingList.ClearSelection();
                shipLayout.SetShip(GameManager.PlayerShip);
                updateDisplayInfo();
            };
            materialFilter.Click += (sender, e) =>
            {
                setItemList(GameManager.PlayerShip.Inventory.GetInventoryList(ItemTypes.RawMaterial));
                inventoryTitle.Text = string.Format("== Inventory - Filter: {0} ==", ItemTypes.RawMaterial);
                scrollingList.ClearSelection();
                shipLayout.SetShip(GameManager.PlayerShip);
                updateDisplayInfo();
            };
            modFilter.Click += (sender, e) =>
            {
                setItemList(GameManager.PlayerShip.Inventory.GetInventoryList(ItemTypes.ShipMod));
                inventoryTitle.Text = string.Format("== Inventory - Filter: {0} ==", ItemTypes.ShipMod);
                scrollingList.ClearSelection();
                shipLayout.SetShip(GameManager.PlayerShip);
                updateDisplayInfo();
            };
            shipFilter.Click += (sender, e) =>
            {
                scrollingList.SetList(GameManager.PlayerFaction.OwnedShips);
                inventoryTitle.Text = string.Format("== Owned Ships ==");
                scrollingList.ClearSelection();
                shipLayout.SetShip(GameManager.PlayerShip);
                updateDisplayInfo();
            };
            #endregion

            #region Control Registration
            //Titles
            RegisterControl(shipDesignationTitle);
            RegisterControl(shipModelTitle);
            RegisterControl(shipAttackTitle);
            RegisterControl(shipDefenseTitle);
            RegisterControl(shipCargoTitle);
            RegisterControl(shipJumpTitle);

            //Buttons
            RegisterControl(backButton);
            RegisterControl(equipButton);
            RegisterControl(unequipButton);
            //RegisterControl(previousShip);
            //RegisterControl(nextShip);
            RegisterControl(filterReset);
            RegisterControl(materialFilter);
            RegisterControl(modFilter);
            RegisterControl(shipFilter);

            //Other
            RegisterControl(scrollingList);
            RegisterControl(descriptionBox);
            RegisterControl(shipLayout);
            #endregion
        }
        /// <summary>
        /// Populate the inventoryListView object with wine data.
        /// </summary>
        private void InitializeInventoryList()
        {
            pulledInventoryData = InventoryListItem.ConstructFromLists(AppDatabase.WineTable.GetAllWine(), AppDatabase.InventoryTable.GetInventory());

            inventoryListView.SetObjects(pulledInventoryData);
        }