Esempio n. 1
0
void
TextScroller::draw(Compositor& compositor)
{
  auto& context = compositor.make_context();

  context.color().draw_filled_rect(Vector(0, 0), Vector(static_cast<float>(context.get_width()), static_cast<float>(context.get_height())),
                           Color(0.6f, 0.7f, 0.8f, 0.5f), 0);
  context.color().draw_surface_part(background, Rectf(0, 0,
                                                      static_cast<float>(background->get_width()),
                                                      static_cast<float>(background->get_height())),
                                    Rectf(0, 0,
                                          static_cast<float>(context.get_width()),
                                          static_cast<float>(context.get_height())), 0);


  float y = static_cast<float>(context.get_height()) - scroll;
  for (auto& line : lines) {
    if (y + line->get_height() >= 0 && static_cast<float>(context.get_height()) - y >= 0) {
      line->draw(context, Rectf(LEFT_BORDER, y, static_cast<float>(context.get_width()) - 2*LEFT_BORDER, y), LAYER_GUI);
    }

    y += line->get_height();
  }

  if(y < 0 && !fading ) {
    fading = true;
    ScreenManager::current()->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
  }
}
Esempio n. 2
0
void
ScreenManager::draw(Compositor& compositor)
{
  assert(!m_screen_stack.empty());

  static Uint32 fps_ticks = SDL_GetTicks();

  // draw the actual screen
  m_screen_stack.back()->draw(compositor);

  // draw effects and hud
  auto& context = compositor.make_context(true);
  m_menu_manager->draw(context);

  if (m_screen_fade)
  {
    m_screen_fade->draw(context);
  }

  Console::current()->draw(context);

  if (g_config->show_fps)
  {
    draw_fps(context, m_fps);
  }

  if (g_config->show_player_pos)
  {
    draw_player_pos(context);
  }

  // render everything
  compositor.render();

  /* Calculate frames per second */
  if (g_config->show_fps)
  {
    static int frame_count = 0;
    ++frame_count;

    if (SDL_GetTicks() - fps_ticks >= 500)
    {
      m_fps = static_cast<float>(frame_count) / 0.5f;
      frame_count = 0;
      fps_ticks = SDL_GetTicks();
    }
  }
}
Esempio n. 3
0
void
TitleScreen::draw(Compositor& compositor)
{
  auto& context = compositor.make_context();

  Sector& sector  = m_titlesession->get_current_sector();
  sector.draw(context);

  context.color().draw_surface_scaled(m_frame,
                                      Rectf(0, 0, static_cast<float>(context.get_width()), static_cast<float>(context.get_height())),
                                      LAYER_FOREGROUND1);

  context.color().draw_text(Resources::small_font,
                            m_copyright_text,
                            Vector(5.0f, static_cast<float>(context.get_height()) - 50.0f),
                            ALIGN_LEFT, LAYER_FOREGROUND1);

  context.color().draw_text(Resources::small_font,
                            m_videosystem_name,
                            Vector(static_cast<float>(context.get_width()) - 5.0f,
                                   static_cast<float>(context.get_height()) - 14.0f),
                            ALIGN_RIGHT, LAYER_FOREGROUND1);
}