public override void Initialize()
        {
            base.Initialize();

            _window          = new HumanInventoryWindow(_loc, _resourceCache);
            _window.OnClose += () => _gameHud.InventoryButtonDown = false;
            foreach (var(slot, button) in _window.Buttons)
            {
                button.OnPressed        = (e) => AddToInventory(e, slot);
                button.OnStoragePressed = (e) => OpenStorage(e, slot);
                button.OnHover          = (e) => RequestItemHover(slot);
                _inventoryButtons.Add(slot, new List <ItemSlotButton> {
                    button
                });
            }

            void AddButton(out ItemSlotButton variable, Slots slot, string textureName)
            {
                var texture        = _resourceCache.GetTexture($"/Textures/Interface/Inventory/{textureName}.png");
                var storageTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/back.png");

                variable = new ItemSlotButton(texture, storageTexture)
                {
                    OnPressed        = (e) => AddToInventory(e, slot),
                    OnStoragePressed = (e) => OpenStorage(e, slot),
                    OnHover          = (e) => RequestItemHover(slot)
                };
                _inventoryButtons[slot].Add(variable);
            }

            AddButton(out _hudButtonPocket1, Slots.POCKET1, "pocket");
            AddButton(out _hudButtonPocket2, Slots.POCKET2, "pocket");
            AddButton(out _hudButtonBack, Slots.BACKPACK, "back");
            AddButton(out _hudButtonBelt, Slots.BELT, "belt");
            AddButton(out _hudButtonId, Slots.IDCARD, "id");

            _quickButtonsContainer = new HBoxContainer
            {
                Children =
                {
                    _hudButtonId,
                    _hudButtonBelt,
                    _hudButtonBack,
                    _hudButtonPocket1,
                    _hudButtonPocket2,
                }
            };
        }
Esempio n. 2
0
        public override void Initialize()
        {
            base.Initialize();

            _window = new HumanInventoryWindow(_loc, _resourceCache);

            foreach (var(slot, button) in _window.Buttons)
            {
                button.OnPressed = AddToInventory;
                _inventoryButtons.Add(slot, new List <InventoryButton> {
                    button
                });
            }

            void AddButton(out InventoryButton variable, Slots slot, string textureName)
            {
                var texture        = _resourceCache.GetTexture($"/Textures/UserInterface/Inventory/{textureName}.png");
                var storageTexture = _resourceCache.GetTexture($"/Textures/UserInterface/Inventory/back.png");

                variable = new InventoryButton(slot, texture, storageTexture)
                {
                    OnPressed        = AddToInventory,
                    OnStoragePressed = OpenStorage
                };
                _inventoryButtons[slot].Add(variable);
            }

            AddButton(out _hudButtonPocket1, Slots.POCKET1, "pocket");
            AddButton(out _hudButtonPocket2, Slots.POCKET2, "pocket");
            AddButton(out _hudButtonBack, Slots.BACKPACK, "back");
            AddButton(out _hudButtonBelt, Slots.BELT, "belt");

            _quickButtonsContainer = new HBoxContainer
            {
                Children =
                {
                    _hudButtonBelt,
                    _hudButtonBack,
                    _hudButtonPocket1,
                    _hudButtonPocket2,
                }
            };
        }