// Jason Brillante "Damdoshi"
// Hanged Bunny Studio 2014-2015
//
// Sewer Glue

#include		"SewerGlue.hpp"
#include		"Menu.hpp"

void			hbs::Menu::Display(sf::RenderTarget		&screen)
{
  int			i;
  int			j;

  screen.draw(sprites[BACKGROUND]);

  for (i = title_back; i < title_pos; ++i)
    Text(screen, "Sewer Glue", i, i, title_back + 1 != title_pos ? 1 : -1);
  Text(screen, "Sewer Glue", i, i, 0);

  i = sg->GetScreenHeight() / 2;
  if (intro_step >= 3)
    {
      if (cursor == 0)
	Text(screen, "Start", 5 - 1, i - 1, 1);
      else
	Text(screen, "Start", 5 - 1, i - 1, -1);
      Text(screen, "Start", 5, i + 1, -1);
      Text(screen, "Start", 5 + 1, i, -1);
      Text(screen, "Start", 5, i, 0);
      i += sprites[FONT].getGlobalBounds().height * 1.1;
    }
  if (intro_step >= 4)
    {
      if (cursor == 1)
	Text(screen, "Credit", 10 - 1, i - 1, 1);
      else
	Text(screen, "Credit", 10 - 1, i - 1, -1);
      Text(screen, "Credit", 10, i + 1, -1);
      Text(screen, "Credit", 10 + 1, i, -1);
      Text(screen, "Credit", 10, i, 0);
      i += sprites[FONT].getGlobalBounds().height * 1.1;
    }
  if (intro_step >= 5)
    {
      if (cursor == 2)
	Text(screen, "Exit", 20 - 1, i - 1, 1);
      else
	Text(screen, "Exit", 20 - 1, i - 1, -1);
      Text(screen, "Exit", 20, i + 1, -1);
      Text(screen, "Exit", 20 + 1, i, -1);
      Text(screen, "Exit", 20, i, 0);
      i += sprites[FONT].getGlobalBounds().height * 1.1;
    }

  screen.draw(sprites[MONSTER]);

  if (warping)
    for (j = 0; j < sg->GetScreenHeight(); j += 7)
      for (i = 0; i < sg->GetScreenWidth(); i += 5)
	{
	  sprites[FONT].setColor(sf::Color::Black);
	  sprites[FONT].setTextureRect(sf::IntRect(('!' - warp_animation - 1) * 5, 0, 5, 7));
	  sprites[FONT].setPosition(i, j);
	  screen.draw(sprites[FONT]);
	}

  if (arriving)
    for (j = 0; j < sg->GetScreenHeight(); j += 7)
      for (i = 0; i < sg->GetScreenWidth(); i += 5)
	{
	  sprites[FONT].setColor(sf::Color::Black);
	  sprites[FONT].setTextureRect(sf::IntRect(('!' - arriving - 1) * 5, 0, 5, 7));
	  sprites[FONT].setPosition(i, j);
	  screen.draw(sprites[FONT]);
	}
}

