Пример #1
0
        public ActionBar()
        {
            _box = new Rectangle((int)((Main.DefaultResWidth / 2) / Main.WidthRatio), (int)(Main.DefaultResHeight / Main.HeightRatio), (int)(184 / Main.WidthRatio), (int)(40 / Main.HeightRatio));
            _box.X -= _box.Width / 2;
            _box.Y -= _box.Height;
            _originalY = _box.Y;
            _box.Y = Main.UserResHeight + 300;

            _playButton = new PlayButton(new Vector2(12 + 64, 4), _box);

            _wallButton = new WallButton(new Vector2(20 + 128, 4), _box);

            _playButton.MouseClicked += PlayButton_MouseClicked;
            _wallButton.MouseClicked += WallButton_MouseClicked;

            _buttons.Add(_playButton);
            _buttons.Add(_wallButton);

            _properties = new WorldProperties();
        }
Пример #2
0
        public LevelSelection()
        {
            // Defines the bounding box for the Level Info List.
            int widthOfBounds = (int)(600 / Main.WidthRatio);
            int heightOfBounds = (int)(300 / Main.HeightRatio);
            _boundsTexture = ContentHelper.LoadTexture("Tiles/ui_spritemap");
            _boundsDrawRectangle = new Rectangle(Main.UserResWidth / 2, Main.UserResHeight / 2, widthOfBounds, heightOfBounds);
            _boundsDrawRectangle.X -= widthOfBounds / 2;
            _boundsDrawRectangle.Y -= heightOfBounds / 2;
            _boundsSourceRectangle = new Rectangle(376, 48, 300, 150);

            WidthOfBounds = widthOfBounds;
            HeightOfBounds = heightOfBounds;

            // Defines how big the level selection box will be based on the game's resolution.
            _scissorRectangle = new Rectangle(_boundsDrawRectangle.X + (int)(12 / Main.WidthRatio), _boundsDrawRectangle.Y + (int)(12 / Main.HeightRatio), _boundsDrawRectangle.Width - (int)(24 / Main.WidthRatio), _boundsDrawRectangle.Height - (int)(24 / Main.HeightRatio));

            // Defines where the function buttons will be.
            _functionButtonContainer = new Rectangle(_scissorRectangle.X + _scissorRectangle.Width - CalcHelper.ApplyHeightRatio(4 + 128 + 16 + 32), _scissorRectangle.Y + _scissorRectangle.Height + (int)(8 / Main.HeightRatio), (int)(184 / Main.WidthRatio), (int)(40 / Main.HeightRatio));
            _playButton = new PlayButton(new Vector2(4, 4), _functionButtonContainer);
            _editButton = new EditButton(new Vector2(4 + 32 + 4, 4), _functionButtonContainer);
            _renameButton = new RenameButton(new Vector2(4 + 64 + 8, 4), _functionButtonContainer);
            _deleteButton = new DeleteButton(new Vector2(4 + 96 + 12, 4), _functionButtonContainer);
            _newButton = new NewButton(new Vector2(4 + 128 + 16, 4), _functionButtonContainer);
            _backButton = new BackButton(new Vector2(-500 + 96 + 4, 4), _functionButtonContainer);

            _buttons = new List<FunctionButton>();
            _buttons.Add(_playButton);
            _buttons.Add(_editButton);
            _buttons.Add(_renameButton);
            _buttons.Add(_deleteButton);
            _buttons.Add(_newButton);
            _buttons.Add(_backButton);

            _playButton.MouseClicked += PlayButton_MouseClicked;
            _editButton.MouseClicked += EditButton_MouseClicked;
            _renameButton.MouseClicked += RenameButton_MouseClicked;
            _deleteButton.MouseClicked += DeleteButton_MouseClicked;
            _newButton.MouseClicked += NewButton_MouseClicked;
            _backButton.MouseClicked += BackButton_MouseClicked;

            // Define the spritefont for the "Select Level" header and its position.
            _headerFont = ContentHelper.LoadFont("Fonts/x64");
            _headerText = "Select a Level:";
            _headerPos = new Vector2(Main.UserResWidth / 2 - _headerFont.MeasureString(_headerText).X / 2, _scissorRectangle.Y - _headerFont.LineSpacing - CalcHelper.ApplyHeightRatio(10));
        }