コード例 #1
0
        public override void Draw(GameTime aGameTime)
        {
            SpriteBatch lSpriteBatch = ScreenManager.SpriteBatch;

            lSpriteBatch.Begin();

            //Draw the background images
            lSpriteBatch.Draw(mBackgroundTexture, mBackgroundPos, Color.White);

            //Draw each menu entry in turn
            for (int i = 0; i < MenuEntries.Count; ++i)
            {
                MenuEntry lMenuEntry  = MenuEntries[i];
                bool      lIsSelected = IsActive && (i == mSelectedEntry);
                lMenuEntry.Draw(this, lIsSelected, aGameTime);
            }

            //Draw the description text for the selected entry
            MenuEntry lSelectedMenuEntry = SelectedMenuEntry;

            if ((lSelectedMenuEntry != null) &&
                !String.IsNullOrEmpty(lSelectedMenuEntry.Description))
            {
                Vector2 lTextSize = Fonts.DescriptionFont.MeasureString(lSelectedMenuEntry.Description);
                Vector2 lTextPos  = mDescriptionAreaPos + new Vector2(
                    (float)Math.Floor((mDescriptionAreaTexture.Width - lTextSize.X) / 2),
                    0f);
                lSpriteBatch.DrawString(Fonts.DescriptionFont, lSelectedMenuEntry.Description, lTextPos, Color.White);
            }

            //Draw the select instruction
            lSpriteBatch.Draw(mSelectTexture, mSelectPos, Color.White);
            lSpriteBatch.DrawString(Fonts.ButtonNamesFont, "Select",
                                    new Vector2(
                                        mSelectPos.X - Fonts.ButtonNamesFont.MeasureString("Select").X - 5,
                                        mSelectPos.Y + 5), Color.White);

            //If we are in-game, draw the back instruction
            if (Session.IsActive)
            {
                lSpriteBatch.Draw(mBackTexture, mBackPos, Color.White);
                lSpriteBatch.DrawString(Fonts.ButtonNamesFont, "Resume",
                                        new Vector2(mBackPos.X + 55, mBackPos.Y + 5), Color.White);
            }

            lSpriteBatch.End();
        }
コード例 #2
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        /// <param name="aGameTime"></param>
        public override void Draw(GameTime aGameTime)
        {
            SpriteBatch lSpriteBatch = ScreenManager.SpriteBatch;

            lSpriteBatch.Begin();

            //Draw each menu in turn
            for (int i = 0; i < mMenuEntries.Count; ++i)
            {
                MenuEntry lMenuEntry  = mMenuEntries[i];
                bool      lIsSelected = IsActive && (i == mSelectedEntry);

                lMenuEntry.Draw(this, lIsSelected, aGameTime);
            }

            lSpriteBatch.End();
        }