Esempio n. 1
0
        public ItemInfoWindow(IconFactory iconFactory, InputsManager inputManager)
        {
            _iconFactory = iconFactory;
            Title        = "Information";
            Bounds       = new UniRectangle(700, 120, 200, 240);

            _cell = new InventoryCell(null, _iconFactory, new Vector2I(), inputManager)
            {
                DrawCellBackground = false,
                Bounds             = new UniRectangle(10, 30, 64, 64)
            };

            _nameLabel = new LabelControl
            {
                Bounds     = new UniRectangle(80, 50, 100, 20),
                Autosizing = true
            };

            _descriptionLabel = new LabelControl
            {
                Bounds     = new UniRectangle(10, 80, 180, 100),
                Autosizing = true
            };

            Children.Add(_descriptionLabel);
            Children.Add(_nameLabel);
            Children.Add(_cell);
        }
Esempio n. 2
0
        public InventoryWindowEventArgs CreateEventArgs(InventoryCell cell)
        {
            if (cell == null)
            {
                return(null);
            }

            var control = cell;
            var state   = _inputManager.MouseManager.Mouse.GetState();
            var bounds  = control.GetAbsoluteBounds();

            // slot offset
            var offset = new Point(
                (int)bounds.X - state.X,
                (int)bounds.Y - state.Y
                );

            return(new InventoryWindowEventArgs
            {
                SlotPosition = control.InventoryPosition,
                MouseState = state,
                Container = cell.Container,
                Offset = offset
            });
        }
Esempio n. 3
0
        private void InventoryUiCellMouseEnter(object sender, InventoryWindowCellMouseEventArgs e)
        {
            _hoverSlot = e.Cell;

            if (e.Cell.Slot == null)
            {
                return;
            }

            _infoWindow.ActiveItem = e.Cell.Slot.Item;
        }
Esempio n. 4
0
        public ToolBarUi(PlayerEntityManager player, IconFactory iconFactory, InputsManager inputManager, EntityFactory factory)
        {
            _playerManager = player;
            _factory       = factory;

            Name = "Toolbar";

            int nbrButton = _playerManager.PlayerCharacter.Toolbar.Count;

            _toolbarSlots = new List <InventoryCell>(nbrButton);

            //float fromX = ((bounds.Right.Offset - bounds.Left.Offset) - (ButtonSize * (nbrButton))) / 2;

            for (int x = 0; x < nbrButton; x++)
            {
                var btn = new InventoryCell(null, iconFactory, new Vector2I(0, x), inputManager)
                {
                    //Bounds = new UniRectangle(fromX + (x * ButtonSize), 0, ButtonSize, ButtonSize)
                    DrawCellBackground = false
                };
                btn.MouseDown  += BtnMouseDown;
                btn.MouseUp    += btn_MouseUp;
                btn.MouseEnter += btn_MouseEnter;
                btn.MouseLeave += btn_MouseLeave;

                var bluePrintId = _playerManager.PlayerCharacter.Toolbar[x];

                if (bluePrintId != 0)
                {
                    btn.Slot = _playerManager.PlayerCharacter.FindSlot(s => s.Item.BluePrintId == bluePrintId);

                    if (btn.Slot == null)
                    {
                        try
                        {
                            btn.Slot = new ContainedSlot
                            {
                                Item = (IItem)_factory.CreateFromBluePrint(bluePrintId)
                            };
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            _playerManager.PlayerCharacter.Toolbar[x] = 0;
                            logger.Error("Unable to create entity from Id = {0}. Configuration was probably changed.", bluePrintId);
                        }
                    }
                }

                _toolbarSlots.Add(btn);

                Children.Add(btn);
            }
        }
Esempio n. 5
0
        public virtual void InitializeComponent()
        {
            Children.Clear();

            _recipesList = new ListControl {
                SelectionMode = ListSelectionMode.Single
            };
            _recipesList.Bounds            = new UniRectangle(200, 200, 200, 120);
            _recipesList.SelectionChanged += RecipesListOnSelectionChanged;

            _hostModel = new ModelControl(_iconFactory.VoxelModelManager)
            {
                Bounds = new UniRectangle(20, 20, 210, 170)
            };
            _hostModel.AlterTransform = Matrix.Identity;

            Children.Add(_hostModel);


            // craft button

            const int buttonWidth  = 185;
            const int buttomHeight = 50;

            _craftButton = new ButtonControl
            {
                Text   = "Craft",
                Bounds = new UniRectangle(244, 330, buttonWidth, buttomHeight)
            };

            _resultModel = new ModelControl(_iconFactory.VoxelModelManager)
            {
                Bounds = new UniRectangle(210, 20, 190, 120)
            };

            _hostModel.Bounds.Size.X = 200;

            _ingredientsRect = new RectangleF(200, 145, 200, 42);

            _ingredientCells = new List <InventoryCell>();
            for (int i = 0; i < 6; i++)
            {
                var cell = new InventoryCell(null, _iconFactory, new Vector2I(), _inputsManager)
                {
                    DrawIconsGroupId      = 5,
                    DrawIconsActiveCellId = 6,
                    IsVisible             = false
                };

                _ingredientCells.Add(cell);
            }
        }
Esempio n. 6
0
        public void BuildGrid(Point offset)
        {
            var width  = _content.GridSize.X * CellSize + GridOffset.X + 4;
            var height = _content.GridSize.Y * CellSize + GridOffset.Y + 22 + 4; // 22 = bottom line, 4 - bottom side

            //Bounds = new UniRectangle(_windowStartPosition.X, _windowStartPosition.Y, width, height);

            if (UiGrid != null)
            {
                for (int x = 0; x <= UiGrid.GetUpperBound(0); x++)
                {
                    for (int y = 0; y <= UiGrid.GetUpperBound(1); y++)
                    {
                        var cell = UiGrid[x, y];
                        cell.MouseDown  -= ControlMouseDown;
                        cell.MouseEnter -= ControlMouseEnter;
                        cell.MouseLeave -= ControlMouseLeave;
                        cell.MouseUp    -= ControlMouseUp;
                        Children.Remove(cell);
                    }
                }
            }

            var container = _content;

            UiGrid = new InventoryCell[container.GridSize.X, container.GridSize.Y];

            for (var x = 0; x < container.GridSize.X; x++)
            {
                for (var y = 0; y < container.GridSize.Y; y++)
                {
                    var control = new InventoryCell(_content, _iconFactory, new Vector2I(x, y), _inputManager)
                    {
                        Bounds      = new UniRectangle(offset.X + x * CellSize, offset.Y + y * CellSize, CellSize, CellSize),
                        Name        = "Cell" + x + "," + y,
                        DrawGroupId = DrawGroupId,
                    };
                    control.MouseDown  += ControlMouseDown;
                    control.MouseEnter += ControlMouseEnter;
                    control.MouseLeave += ControlMouseLeave;
                    control.MouseUp    += ControlMouseUp;
                    Children.Add(control);

                    UiGrid[x, y] = control;
                }
            }

            CellsCreated();
        }
Esempio n. 7
0
        public override void LoadContent(DeviceContext context)
        {
            _infoWindow = new ItemInfoWindow(_iconFactory, _inputManager);

            _cubeRenderer.LoadContent(context);

            ContainerInventoryWindow.CubeRenderer = _cubeRenderer;
            ContainerInventoryWindow.VoxelEffect  = ToDispose(new HLSLVoxelModel(_engine.Device, Path.Combine(ClientSettings.EffectPack, @"Entities\VoxelModel.hlsl"), VertexVoxel.VertexDeclaration));

            _dragControl = new InventoryCell(null, _iconFactory, new Vector2I(), _inputManager)
            {
                Bounds             = new UniRectangle(-100, -100, InventoryWindow.CellSize, InventoryWindow.CellSize),
                DrawCellBackground = false,
                IsClickTransparent = true,
                DrawGroupId        = 1
            };
        }
Esempio n. 8
0
        protected InventoryCell BuildBodyslot(EquipmentSlotType inventorySlot, int x, int y, int size = 32)
        {
            var bodyCell = new InventoryCell(
                _playerEntityManager.PlayerCharacter.Equipment,
                _iconFactory,
                new Vector2I(0, (int)inventorySlot),
                _inputManager
                );

            bodyCell.DrawGroupId = DrawGroupId;
            bodyCell.Name        = inventorySlot.ToString();
            bodyCell.Bounds      = new UniRectangle(x, y, size, size);
            bodyCell.MouseDown  += ControlMouseDown;
            bodyCell.MouseEnter += ControlMouseEnter;
            bodyCell.MouseLeave += ControlMouseLeave;
            bodyCell.MouseUp    += ControlMouseUp;
            Children.Add(bodyCell);
            return(bodyCell);
        }
Esempio n. 9
0
 private void InventoryUiCellMouseLeave(object sender, InventoryWindowCellMouseEventArgs e)
 {
     _hoverSlot             = null;
     _infoWindow.ActiveItem = null;
 }
Esempio n. 10
0
 void _toolBar_SlotEnter(object sender, InventoryWindowCellMouseEventArgs e)
 {
     _hoverSlot = e.Cell;
 }
Esempio n. 11
0
 void _toolBar_SlotLeave(object sender, InventoryWindowCellMouseEventArgs e)
 {
     _hoverSlot = null;
 }