public BlockDesigner(Engine engine, Tileset tileset, BlockPlacer parentScreen)
            : base("Block Designer")
        {
            this.parentScreen = parentScreen;
            this.tileset = tileset;
            this.EditMode = false;
            this.CurrentBlock = new Block("", 0, tileset, true, true);

            SetUpScreen(engine);
        }
 public BlockSettings(Engine engine, Block block)
     : base("Block Settings")
 {
     this.block = block;
     this.DemandPriority = true;
     CullingButton = new ScreenButton(this, "Toggle Culling", "Culling: False", engine.FontMain);
     AddElement(CullingButton);
     SolidButton = new ScreenButton(this, "Toggle Solid", "Solid: False", engine.FontMain);
     AddElement(SolidButton);
     AddCloseButton(engine);
     Center(engine);
     UpdateButtons();
 }
        public BlockDesigner(Engine engine, Tileset tileset, BlockPlacer parentScreen, Block block)
            : base("Block Designer")
        {
            this.parentScreen = parentScreen;
            this.tileset = tileset;
            this.EditMode = true;
            this.CurrentBlock = block;

            SetUpScreen(engine);

            ScreenButton _but = new ScreenButton(this, "Delete", "Del", engine.FontMain);
            _but.Position.X = Screen.boarderSize * 6 + 2 * 32 + 48 + 64 + 48;
            _but.Position.Y = PrevBox.Y + PrevBoxSize + boarderSize;;
            _but.Size.X = 32;
            this.AddElement(_but);
        }
        /// <summary>
        /// Updates the window and controls the block selector.
        /// </summary>
        public override void Update(Engine engine, bool Selected)
        {
            // If box is to be placed.
            if (Selected)
            {
                if (engine.screenManager.NoFocus)
                {
                    if ((engine.inputManager.mouse.LeftButton == ButtonState.Pressed && !parentEditor.StackBlocks) || (engine.inputManager.MouseLeftButtonTapped && parentEditor.StackBlocks))
                    {
                        if (engine.room.GetGridBlockSafe(parentEditor.Cursor3D) != null)
                        {
                            engine.room.GridArray[(int)parentEditor.Cursor3D.X, (int)parentEditor.Cursor3D.Y, (int)parentEditor.Cursor3D.Z] = SelectedBlock;
                            engine.room.UpdateRoomVertices();
                            engine.primManager.myEffect.UpdateShadowMap(engine);
                        }
                    }
                }
            }

            base.Update(engine, Selected);

            if (!Minimized && Selected)
            {
                MouseBlock = null;

                // Draws yellow under blocks the mouse is selecting.
                int i = 0;
                int xx = 0;
                foreach (Block block in PageList)
                {
                    // Changes rows and such.
                    if (i == PrevMaximumRows)
                    {
                        i = 0;
                        xx++;
                        if (xx == PrevMaximumColumns)
                            break;
                    }

                    // If mouse is within region.
                    if (engine.inputManager.mouse.X > Position.X + PrevPosition.X + xx * PrevBoxWidth && engine.inputManager.mouse.X < Position.X + PrevPosition.X + PrevBoxWidth + xx * PrevBoxWidth
                        && engine.inputManager.mouse.Y > Position.Y + PrevPosition.Y + i * PrevBoxHeight && engine.inputManager.mouse.Y < Position.Y + PrevPosition.Y + (i + 1) * PrevBoxHeight)
                    {
                        MouseBlock = block;
                        if (engine.inputManager.MouseLeftButtonTapped)
                        {
                            SelectedBlock = engine.room.BlockSet.Blocks.FindIndex(block.Equals);
                            if (SelectedBlock == -1)
                                throw new Exception("Block selected does not match any block in the current room blockset.");
                        }
                    }
                    i++;
                }

                angle += 0.01f;

                if (PreviousInput != InputField.InputString)
                    FilterBlocks(engine);
                PreviousInput = InputField.InputString;
            }
        }