Пример #1
0
        public static void Update(Menu menu)
        {
            if (InputMapper.STRICTDOWN)
            {
                menu.NextMenuItem();
            }

            if (InputMapper.STRICTUP)
            {
                menu.PreviousMenuItem();
            }

            menu.ResolveMouseSelection();

            if (InputMapper.STRICTACTION || ShortcutProvider.LeftButtonClickedNowButNotLastFrame())
            {
                menu.SelectMenuItem();
            }
        }
Пример #2
0
        public override void Update()
        {
            if (Confirmation)
            {
                confirmDialog.Update();
                return;
            }

            if (ShortcutProvider.KeyPressedNowButNotLastFrame(Keys.Down))
            {
                NextMenuItem();
            }

            if (ShortcutProvider.KeyPressedNowButNotLastFrame(Keys.Up))
            {
                PreviousMenuItem();
            }

            ResolveMouseSelection();

            if (ShortcutProvider.KeyPressedNowButNotLastFrame(Keys.Enter) || ShortcutProvider.LeftButtonClickedNowButNotLastFrame())
            {
                SelectMenuItem();
            }

            foreach (MenuItem menuItem in menuItems)
            {
                menuItem.Update();
            }
            if (InputMapper.STRICTCANCEL)
            {
                StateManager.MenuState = MenuStates.Main;
            }
            if (TextBuffer.Length == 0)
            {
                menuItems[0].IsSelected = false;
                menuItems[1].IsSelected = true;
            }
        }
Пример #3
0
        protected override void Update(GameTime gameTime)
        {
            if (Form.ActiveForm == parentForm)
            {
                if (CurrentMap != null)
                {
                    Viewport.Location = new Location(hscroll.Value, vscroll.Value);
                    Camera.Position   = new Vector2(hscroll.Value, vscroll.Value);
                    InputProvider.Update();
                    CurrentMap.Update(gameTime.ElapsedGameTime.Milliseconds);

                    MouseState ms = InputProvider.MouseState;
                    if ((ms.X > 0) && (ms.Y > 0) && (ms.X < Camera.ViewPortWidth) && (ms.Y < Camera.ViewPortHeight))
                    {
                        Vector2 mouseLoc = Camera.ScreenToWorld(new Vector2(ms.X, ms.Y));
                        int     cellX    = (int)MathHelper.Clamp(TileMap.GetCellByPixelX((int)mouseLoc.X), 0, TileMap.MapWidth - 1);
                        int     cellY    = (int)MathHelper.Clamp(TileMap.GetCellByPixelY((int)mouseLoc.Y), 0, TileMap.MapHeight - 1);

                        if (Camera.WorldRectangle.Contains((int)mouseLoc.X, (int)mouseLoc.Y))
                        {
                            if (!RectangleMode)
                            {
                                if (ShortcutProvider.LeftButtonClicked())
                                {
                                    TileMap.GetMapSquareAtCell(cellX, cellY).Passable = Passable;
                                }
                                if (ShortcutProvider.RightButtonClicked())
                                {
                                    if (SetCode)
                                    {
                                        ((EditorForm)parentForm).SetCodeList(cellX, cellY);
                                    }
                                    else
                                    {
                                        ((EditorForm)parentForm).GetCodeList(TileMap.GetCellCodes(cellX, cellY));
                                    }
                                }
                            }
                            else
                            {
                                if (ShortcutProvider.LeftButtonClickedNowButNotLastFrame())
                                {
                                    if (!waitingForSecondClick)
                                    {
                                        startCell             = new Vector2(cellX, cellY);
                                        waitingForSecondClick = true;
                                    }
                                    else
                                    {
                                        Vector2 endCell = new Vector2(cellX, cellY);
                                        waitingForSecondClick = false;

                                        for (int cellx = (int)startCell.X; cellx <= endCell.X; ++cellx)
                                        {
                                            for (int celly = (int)startCell.Y; celly <= endCell.Y; ++celly)
                                            {
                                                TileMap.GetMapSquareAtCell(cellx, celly).Passable = Passable;
                                            }
                                        }
                                    }
                                }
                                else if (ShortcutProvider.RightButtonClickedButNotLastFrame())
                                {
                                    if (!waitingForSecondClick)
                                    {
                                        startCell             = new Vector2(cellX, cellY);
                                        waitingForSecondClick = true;
                                    }
                                    else
                                    {
                                        Vector2 endCell = new Vector2(cellX, cellY);
                                        waitingForSecondClick = false;

                                        for (int cellx = (int)startCell.X; cellx <= endCell.X; ++cellx)
                                        {
                                            for (int celly = (int)startCell.Y; celly <= endCell.Y; ++celly)
                                            {
                                                if (SetCode)
                                                {
                                                    ((EditorForm)parentForm).SetCodeList(cellx, celly);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            base.Update(gameTime);
        }