private void DrawInfoBar(SpriteBatch spriteBatch, int shiftValue)
{
//If the world is locked, do not display the level info
if (!_mLevels[_mCurrentWorld * 6 + _mCurrentIndex].Unlocked) return;
//Region where the infobar goes; Shift with the scrolling worlds and slightly up to hide some lines
var infoBarLoc = _mLevelRegions[_mCurrentWorld * 6 + _mCurrentIndex];
infoBarLoc.Offset(0, -shiftValue - (int)(infoBarLoc.Height * .04));
//Draw the info bg
spriteBatch.Draw(_mLevelInfoBg, infoBarLoc, Color.White);
//Measure the size of the level's name
var name = _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].Name;
Vector2 size = _mFont.MeasureString(name);
//If the size is too big, we need to arrange characters so that it looks pleasing
if (size.X > infoBarLoc.Width * 15 / 16 && name.Contains(' '))
{
var spaceIndex = name.LastIndexOf(' ');
//Draw the string from beginning to the last space
size = _mFont.MeasureString(name.Substring(0, spaceIndex));
spriteBatch.DrawString(_mFont, name.Substring(0, spaceIndex),
new Vector2(infoBarLoc.Center.X - size.X / 2, infoBarLoc.Top + infoBarLoc.Height / 8 - size.Y * 11 / 16), Color.White);
//Draw the string from the last space to the end
size = _mFont.MeasureString(name.Substring(spaceIndex + 1));
spriteBatch.DrawString(_mFont, name.Substring(spaceIndex + 1),
new Vector2(infoBarLoc.Center.X - size.X / 2, infoBarLoc.Top + infoBarLoc.Height / 8 - size.Y * 1 / 16), Color.White);
}
else
//Otherwise just draw it normally
spriteBatch.DrawString(_mFont, name,
new Vector2(infoBarLoc.Center.X - size.X / 2, infoBarLoc.Top + infoBarLoc.Height / 8 - size.Y * 5 / 16), Color.White);
//Draw the acheivment data on the info bar, as long as they have stars but not all of them
if (_mLevels[_mCurrentWorld * 6 + _mCurrentIndex].StarCount() > 0 && !_mLevels[_mCurrentWorld * 6 + _mCurrentIndex].TenthStar())
{
size = _mFont.MeasureString("Time:");
spriteBatch.DrawString(_mFont, "Time:",
new Vector2(infoBarLoc.Left + infoBarLoc.Width / 16, infoBarLoc.Top + infoBarLoc.Height * 5 / 16 - size.Y * 5 / 16), Color.White);
size = _mFont.MeasureString("Gems:");
spriteBatch.DrawString(_mFont, "Gems:",
new Vector2(infoBarLoc.Left + infoBarLoc.Width / 16, infoBarLoc.Top + infoBarLoc.Height / 2 - size.Y * 5 / 16), Color.White);
size = _mFont.MeasureString("Deaths:");
spriteBatch.DrawString(_mFont, "Deaths:",
new Vector2(infoBarLoc.Left + infoBarLoc.Width / 16, infoBarLoc.Top + infoBarLoc.Height * 11 / 16 - size.Y * 5 / 16), Color.White);
//This will align the stars together
double startXPos = infoBarLoc.Left + infoBarLoc.Width / 16 + size.X;
//Stars for time
for (var i = 0; i < _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].GetStar(LevelInfo.StarTypes.Time); i++)
spriteBatch.Draw(_mStar, new Rectangle((int)(startXPos + 3 * size.Y / 4 * i),
(int)(infoBarLoc.Top + infoBarLoc.Height * 5 / 16 - size.Y * 3 / 16),
3 * (int)size.Y / 4, 3 * (int)size.Y / 4), Color.White);
//Stars for gems
for (var i = 0; i < _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].GetStar(LevelInfo.StarTypes.Collection); i++)
spriteBatch.Draw(_mStar, new Rectangle((int)(startXPos + 3 * size.Y / 4 * i),
(int)(infoBarLoc.Top + infoBarLoc.Height / 2 - size.Y * 3 / 16),
3 * (int)size.Y / 4, 3 * (int)size.Y / 4), Color.White);
//Stars for death
for (var i = 0; i < _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].GetStar(LevelInfo.StarTypes.Death); i++)
spriteBatch.Draw(_mStar, new Rectangle((int)(startXPos + 3 * size.Y / 4 * i),
(int)(infoBarLoc.Top + infoBarLoc.Height * 11 / 16 - size.Y * 3 / 16),
3 * (int)size.Y / 4, 3 * (int)size.Y / 4), Color.White);
}
//If it does have all 10
else if (_mLevels[_mCurrentWorld * 6 + _mCurrentIndex].TenthStar())
{
size = _mFont.MeasureString("All 10 stars");
spriteBatch.DrawString(_mFont, "All 10 stars",
new Vector2(infoBarLoc.Center.X - size.X / 2, infoBarLoc.Center.Y - size.Y / 2), Color.White);
//Draw 10 stars in 2 rows of 5
for (var i = 0; i < 2; i++)
for (var j = 0; j < 5; j++)
spriteBatch.Draw(_mStar, new Rectangle(infoBarLoc.Left + 5*infoBarLoc.Width / 16 + j * infoBarLoc.Width / 12,
(int)(infoBarLoc.Center.Y- size.Y + size.Y/5 - i * infoBarLoc.Height / 12), infoBarLoc.Width / 12, infoBarLoc.Height / 12), Color.White);
size = _mFont.MeasureString("collected");
spriteBatch.DrawString(_mFont, "collected",
new Vector2(infoBarLoc.Center.X - size.X / 2, infoBarLoc.Center.Y + size.Y / 2), Color.White);
}
//Otherwise, let the user know they have no stars
else
{
size = _mFont.MeasureString("No Stars");
spriteBatch.DrawString(_mFont, "No Stars",
new Vector2(infoBarLoc.Center.X - size.X / 2, infoBarLoc.Center.Y - size.Y / 2), Color.White);
size = _mFont.MeasureString("collected");
spriteBatch.DrawString(_mFont, "collected",
new Vector2(infoBarLoc.Center.X - size.X / 2, infoBarLoc.Center.Y + size.Y / 2), Color.White);
}
}