//------------------------------------------------------------------------------
 // Method: Draw
 // Author: Neil Holmes
 // Summary: draws the achievement unlocked display
 //------------------------------------------------------------------------------
 public void Draw(Rectangle displayArea, ICAchievementColorMode colorMode)
 {
     DrawAchievement(false, displayArea, colorMode);
 }
        //------------------------------------------------------------------------------
        // Method: DrawAchievement
        // Author: Neil Holmes
        // Summary: draws an achievement
        //------------------------------------------------------------------------------
        public void DrawAchievement(bool listMode, Rectangle displayArea, ICAchievementColorMode colorMode)
        {
            Color bannerColor;
            Color messageTextColor;
            Color valueTextColor;

            // bail out if we have nothing to display
            if (display == false && listMode == false) return;

            // store the current scissor rectangle settings so we can restore them after we finish drawing
            Rectangle storedScissorRect = graphicsDevice.ScissorRectangle;

            //---

            // setup colours based on requested colour mode
            if (colorMode == ICAchievementColorMode.normal)
            {
                bannerColor = normalBannerColor;
                messageTextColor = normalMessageTextColor;
                valueTextColor = normalValueTextColor;
            }
            else
            {
                bannerColor = invertedBannerColor;
                messageTextColor = invertedMessageTextColor;
                valueTextColor = invertedValueTextColor;
            }

            //----

            // start drawing the banner
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

            // draw the banner
            spriteBatch.Draw(bannerTexture, bannerRect, bannerColor);

            // finished drawing
            spriteBatch.End();

            //----

            // calculate the position and width of the scissor rectangle we will use & clip it to the current scissor region to
            // ensure that we don't try to draw outside of the screen area etc
            Rectangle scissorRect = bannerRect;
            if (scissorRect.X < 0)
            {
                scissorRect.Width += scissorRect.X;
                scissorRect.X = 0;
            }
            if (scissorRect.X > graphicsDevice.ScissorRectangle.Width)
            {
                scissorRect.X = graphicsDevice.ScissorRectangle.Width;
                scissorRect.Width = 0;
            }
            if (scissorRect.X + scissorRect.Width > graphicsDevice.ScissorRectangle.Width)
            {
                scissorRect.Width = graphicsDevice.ScissorRectangle.Width - scissorRect.X;
            }
            if (scissorRect.Y + scissorRect.Height > graphicsDevice.ScissorRectangle.Height)
            {
                scissorRect.Height = graphicsDevice.ScissorRectangle.Height - scissorRect.Y;
            }

            // set the scissor region to the banner area
            graphicsDevice.ScissorRectangle = scissorRect;

            // start dawring
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearClamp, DepthStencilState.None, new RasterizerState { ScissorTestEnable = true });

            // draw the achievement icon
            spriteBatch.Draw(iconTexture, iconRect, null, iconColor);

            // if we are in list mode check the colour of the icon and draw a padlock if required
            if (listMode && iconColor == Color.Gray) spriteBatch.Draw(padlockTexture, iconRect, null, Color.White);

            // finished drawing the icon
            spriteBatch.End();

            // adjust the scissor region to the text area
            scissorRect.Width -= (iconRect.Width + (iconBorderSize * 2));
            if (scissorRect.Width < 0) scissorRect.Width = 0;
            graphicsDevice.ScissorRectangle = scissorRect;

            // start dawring the text with the new scissor rectangle set
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearClamp, DepthStencilState.None, new RasterizerState { ScissorTestEnable = true });

            // draw the text
            if (listMode == false)
            {
                // draw the achievement name
                spriteBatch.DrawString(messageFont, achievementText, textPosition, messageTextColor);

                // draw the value
                spriteBatch.DrawString(valueFont, valueText, valuePosition, valueTextColor);
            }
            else
            {
                // draw the achievement name
                spriteBatch.DrawString(valueFont, achievementText, textPosition, messageTextColor);

                // draw the description
                spriteBatch.DrawString(messageFont, valueText, valuePosition, valueTextColor);
            }

            // finished drawing the text
            spriteBatch.End();

            // restore the previous scissor rectangle settings
            graphicsDevice.ScissorRectangle = storedScissorRect;

            //----

            if (listMode == false)
            {
                // start dawring the badge
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

                // draw the badge
                spriteBatch.Draw(badgeTexture, badgeRect, null, new Color(255, 255, 255, alpha));

                // finished drawing the badge
                spriteBatch.End();
            }
        }
        //------------------------------------------------------------------------------
        // Method: Draw
        // Author: Neil Holmes
        // Summary: draws the achievement list display
        //------------------------------------------------------------------------------
        public void Draw(Rectangle displayArea, int displayWidth, ICAchievementColorMode colorMode, bool useSafeZone = false)
        {
            // set the first achievement to be displayed
            uint achievementIndex = achievementDisplayIndex;

            // ensure that the supplied display area is inside the screen
            if (displayArea.Left < 0)
            {
                displayArea.Width += displayArea.Left;
                displayArea.X = 0;
            }
            if (displayArea.Right > graphicsDevice.Viewport.Width)
            {
                displayArea.Width -= (displayArea.Right - graphicsDevice.Viewport.Width);
            }
            if (displayArea.Top < 0)
            {
                displayArea.Height += displayArea.Top;
                displayArea.Y = 0;
            }
            if (displayArea.Bottom > graphicsDevice.Viewport.Height)
            {
                displayArea.Height -= (displayArea.Bottom - graphicsDevice.Viewport.Height);
            }

            // clamp display width to min and max
            if (displayWidth < (minDisplayWidth * displayScale)) displayWidth = (int)(minDisplayWidth * displayScale);
            if (displayWidth > (maxDisplayWidth * displayScale)) displayWidth = (int)(maxDisplayWidth * displayScale);

            // preset size and intial display position of the first achievement in the list
            bannerRect.X = displayArea.X + (displayArea.Width - displayWidth) / 2;
            if (useSafeZone)
                bannerRect.Y = displayArea.Y + (int)(displayArea.Height * safeZoneScaleValue);
            else
                bannerRect.Y = displayArea.Y;
            bannerRect.Height = (int)(bannerHeight * displayScale);
            bannerRect.Width = displayWidth;

            // set the text position
            textPosition.X = bannerRect.X + (textOffsetX * displayScale);
            textPosition.Y = bannerRect.Y + (textOffsetY * displayScale);

            // set the value position
            valuePosition.X = textPosition.X;
            valuePosition.Y = bannerRect.Y + (valueOffsetY * displayScale);

            // set the icon position
            iconRect.Y = bannerRect.Y + (int)(iconBorderSize * displayScale);
            iconRect.Height = bannerRect.Height - (int)((iconBorderSize * 2) * displayScale);
            iconRect.Width = iconRect.Height;
            iconRect.X = bannerRect.X + bannerRect.Width - (int)(iconBorderSize * displayScale) - iconRect.Width;

            // loop through and display as many achievemnts as possible on the screen...
            for (; achievementIndex < achievementGroup.AchievementCount; achievementIndex++)
            {
                // bail out if the bottom of the banner rectangle is outside the safe zone
                if (useSafeZone)
                {
                    if (bannerRect.Y + bannerRect.Height > (displayArea.Y + displayArea.Height - (int)(displayArea.Height * safeZoneScaleValue))) break;
                }
                else
                {
                    if (bannerRect.Y + bannerRect.Height > displayArea.Y + displayArea.Height) break;
                }

                // setup the information for this achievement
                CoAchievement achievementData = achievementGroup.GetAchievementFromIndex(achievementIndex);
                int width;
                int heightPixels;
                achievementData.Image.GetDimensions(out width, out heightPixels);
                Byte[] pixelData = (Byte[])achievementData.Image.PixelData;
                iconTexture = new Texture2D(graphicsDevice, width, heightPixels, false, SurfaceFormat.Color);
                iconTexture.SetData<Byte>(pixelData);
                achievementText = (int)achievementData.TrueValue + " - " + String.Copy(achievementData.Title);
                valueText = String.Copy(achievementData.Description);

                // set the color of the achievement icon
                if (userAchievementList != null && userAchievementList.IsAchievementUnlocked(achievementData.AchievementId))
                {
                    iconColor = Color.White;
                }
                else
                {
                    iconColor = Color.Gray;
                }

                // draw this achievement
                DrawAchievement(true, displayArea, colorMode);

                // move on to the next achievement in the list
                bannerRect.Y += (int)(listSpacingY * displayScale);
                iconRect.Y += (int)(listSpacingY * displayScale);
                valuePosition.Y += (int)(listSpacingY * displayScale);
                textPosition.Y += (int)(listSpacingY * displayScale);
            }

            // store the number of achievements that were displayed
            if (achievementIndex - achievementDisplayIndex > achievementsDisplayed)
                achievementsDisplayed = achievementIndex - achievementDisplayIndex;
        }