예제 #1
0
void
ItemTextField::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
  std::string r_input = *input;
  bool fl = active && (int(g_real_time*2)%2);
  if ( fl ) {
    r_input += "_";
  }
  context.color().draw_text(Resources::normal_font, r_input,
                            Vector(pos.x + static_cast<float>(menu_width) - 16.0f - static_cast<float>(fl ? 0 : flickw),
                                   pos.y - Resources::normal_font->get_height() / 2.0f),
                            ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::field_color);
  context.color().draw_text(Resources::normal_font, get_text(),
                            Vector(pos.x + 16.0f,
                                   pos.y - static_cast<float>(Resources::normal_font->get_height()) / 2.0f),
                            ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
}
예제 #2
0
void
InvisibleWall::draw(DrawingContext& context)
{
  if (Editor::is_active()) {
    context.color().draw_filled_rect(m_col.m_bbox, Color(0.0f, 0.0f, 0.0f, 0.6f),
                             0.0f, LAYER_OBJECTS);
  }
}
예제 #3
0
void
SequenceTrigger::draw(DrawingContext& context)
{
  if (Editor::is_active()) {
    context.color().draw_filled_rect(bbox, Color(1.0f, 0.0f, 0.0f, 0.6f),
                             0.0f, LAYER_OBJECTS);
  }
}
예제 #4
0
void
SpriteChange::draw(DrawingContext& context)
{
  if (m_in_stay_action && !m_stay_action.empty()) {
    m_sprite->set_action(m_stay_action);
    m_sprite->draw(context.color(), m_pos * 32, LAYER_OBJECTS-1);
  }
}
예제 #5
0
void
MagicBlock::draw(DrawingContext& context){
  // Ask for update about lightmap at center of this block
  context.light().get_pixel( center, &light );

  MovingSprite::draw(context);
  context.color().draw_filled_rect( bbox, color, layer);
}
예제 #6
0
void
SpecialTile::draw(DrawingContext& context)
{
  if(invisible)
    return;

  sprite->draw(context.color(), pos*32 + Vector(16, 16), LAYER_OBJECTS - 1);
}
예제 #7
0
void
SequenceTrigger::draw(DrawingContext& context)
{
  if (Editor::is_active() || g_debug.show_collision_rects) {
    context.color().draw_filled_rect(m_col.m_bbox, Color(1.0f, 0.0f, 0.0f, 0.6f),
                             0.0f, LAYER_OBJECTS);
  }
}
예제 #8
0
void
ItemColorChannel::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active)
{
  MenuItem::draw(context, pos, menu_width, active);
  const float lw = float(menu_width - 32) * (*m_number);
  context.color().draw_filled_rect(Rectf(pos + Vector(16, -4),
                                         pos + Vector(16 + lw, 4)),
                                   m_channel, 0.0f, LAYER_GUI-1);
}
예제 #9
0
void
EditorScrollerWidget::draw(DrawingContext& context)
{
  if (!rendered) return;

  context.color().draw_filled_rect(Rectf(Vector(0, 0), Vector(SIZE, SIZE)),
                                     Color(0.9f, 0.9f, 1.0f, 0.6f),
                                     MIDDLE, LAYER_GUI-10);
  context.color().draw_filled_rect(Rectf(Vector(40, 40), Vector(56, 56)),
                                     Color(0.9f, 0.9f, 1.0f, 0.6f),
                                     8, LAYER_GUI-20);
  if (can_scroll()) {
    draw_arrow(context, m_mouse_pos);
  }

  draw_arrow(context, Vector(TOPLEFT, MIDDLE));
  draw_arrow(context, Vector(BOTTOMRIGHT, MIDDLE));
  draw_arrow(context, Vector(MIDDLE, TOPLEFT));
  draw_arrow(context, Vector(MIDDLE, BOTTOMRIGHT));
}
예제 #10
0
void
Flower::draw(DrawingContext& context)
{
  //Draw the Sprite.
  sprite->draw(context.color(), get_pos(), LAYER_OBJECTS, drawing_effect);
  //Draw the light when dark
  context.get_light( bbox.get_middle(), &light );
  if (light.red + light.green + light.blue < 3.0){
    lightsprite->draw(context.light(), bbox.get_middle(), 0);
  }
}
예제 #11
0
void
CoinRain::draw(DrawingContext& context)
{
  int layer;
  if (emerge_distance > 0) {
    layer = LAYER_OBJECTS - 5;
  } else {
    layer = LAYER_OBJECTS + 5;
  }
  sprite->draw(context.color(), position, layer);
}
예제 #12
0
void
PlayerStatus::draw(DrawingContext& context)
{
  int player_id = 0;

  if ((displayed_coins == DISPLAYED_COINS_UNSET) ||
      (std::abs(displayed_coins - coins) > 100)) {
    displayed_coins = coins;
    displayed_coins_frame = 0;
  }
  if (++displayed_coins_frame > 2) {
    displayed_coins_frame = 0;
    if (displayed_coins < coins) displayed_coins++;
    if (displayed_coins > coins) displayed_coins--;
  }
  displayed_coins = std::min(std::max(displayed_coins, 0), MAX_COINS);

  std::stringstream ss;
  ss << displayed_coins;
  std::string coins_text = ss.str();

  context.push_transform();
  context.set_translation(Vector(0, 0));

  if (coin_surface)
  {
    context.color().draw_surface(coin_surface,
                                 Vector(static_cast<float>(context.get_width()) - BORDER_X - static_cast<float>(coin_surface->get_width()) - Resources::fixed_font->get_text_width(coins_text),
                                        BORDER_Y + 1.0f + (Resources::fixed_font->get_text_height(coins_text) + 5) * static_cast<float>(player_id)),
                                   LAYER_HUD);
  }
  context.color().draw_text(Resources::fixed_font,
                            coins_text,
                            Vector(static_cast<float>(context.get_width()) - BORDER_X - Resources::fixed_font->get_text_width(coins_text),
                                   BORDER_Y + (Resources::fixed_font->get_text_height(coins_text) + 5.0f) * static_cast<float>(player_id)),
                            ALIGN_LEFT,
                            LAYER_HUD,
                            PlayerStatus::text_color);

  context.pop_transform();
}
예제 #13
0
void
EditorScrollerWidget::draw_arrow(DrawingContext& context, const Vector& pos)
{
  Vector dir = pos - Vector(MIDDLE, MIDDLE);
  if (dir.x != 0 || dir.y != 0) {
    // draw a triangle
    dir = dir.unit() * 8;
    Vector dir2 = Vector(-dir.y, dir.x);
    context.color().draw_triangle(pos + dir, pos - dir + dir2, pos - dir - dir2,
                                    Color(1, 1, 1, 0.5), LAYER_GUI-20);
  }
}
예제 #14
0
void
ItemScriptLine::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
  std::string r_input = *input;
  bool fl = active && (int(g_real_time*2)%2);
  if ( fl ) {
    r_input += "_";
  }
  context.color().draw_text(Resources::console_font, r_input,
                            Vector(pos.x + 16.0f,
                                   pos.y - Resources::console_font->get_height() / 2.0f),
                            ALIGN_LEFT, LAYER_GUI, ColorScheme::Menu::field_color);
}
예제 #15
0
void
InfoBox::draw(DrawingContext& context)
{
  float x1 = static_cast<float>(context.get_width()) / 2.0f - 200.0f;
  float y1 = static_cast<float>(context.get_height()) / 2.0f - 200.0f;
  float width = 400.0f;
  float height = 200.0f;

  context.color().draw_filled_rect(Rectf(Vector(x1, y1),
                                         Sizef(width, height)),
                                   Color(0.6f, 0.7f, 0.8f, 0.5f), LAYER_GUI - 1);

  float y = y1;
  bool linesLeft = false;
  for (size_t i = firstline; i < lines.size(); ++i) {
    if (y >= y1 + height) {
      linesLeft = true;
      break;
    }

    lines[i]->draw(context, Rectf(x1, y, x1+width, y), LAYER_GUI);
    y += lines[i]->get_height();
  }

  {
    // draw the scrolling arrows
    if (arrow_scrollup.get() && firstline > 0)
      context.color().draw_surface(arrow_scrollup,
                                   Vector(x1 + width  - static_cast<float>(arrow_scrollup->get_width()),  // top-right corner of box
                                          y1), LAYER_GUI);

    if (arrow_scrolldown.get() && linesLeft && firstline < lines.size()-1)
      context.color().draw_surface(arrow_scrolldown,
                                   Vector(x1 + width  - static_cast<float>(arrow_scrolldown->get_width()),  // bottom-light corner of box
                                          y1 + height - static_cast<float>(arrow_scrolldown->get_height())),
                                   LAYER_GUI);
  }
}
예제 #16
0
void
EditorToolboxWidget::draw(DrawingContext& context)
{
  //SCREEN_WIDTH SCREEN_HEIGHT
  context.color().draw_filled_rect(Rectf(Vector(static_cast<float>(m_Xpos), 0),
                                         Vector(static_cast<float>(context.get_width()),
                                                static_cast<float>(context.get_height()))),
                                     Color(0.9f, 0.9f, 1.0f, 0.6f),
                                     0.0f, LAYER_GUI-10);
  if (m_dragging) {
    context.color().draw_filled_rect(selection_draw_rect(), Color(0.2f, 0.4f, 1.0f, 0.6f),
                                       0.0f, LAYER_GUI+1);
  }

  if (m_hovered_item != HoveredItem::NONE)
  {
    context.color().draw_filled_rect(get_item_rect(m_hovered_item),
                                       Color(0.9f, 0.9f, 1.0f, 0.6f),
                                       0.0f, LAYER_GUI - 5);
  }

  context.color().draw_text(Resources::normal_font, _("Tilegroups"),
                            Vector(static_cast<float>(context.get_width()), 0),
                            ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::default_color);
  context.color().draw_text(Resources::normal_font, _("Objects"),
                            Vector(static_cast<float>(context.get_width()), 24),
                            ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::default_color);

  m_rubber->draw(context);
  m_select_mode->draw(context);
  m_move_mode->draw(context);
  m_settings_mode->draw(context);

  draw_tilegroup(context);
  draw_objectgroup(context);
}
예제 #17
0
void
Thunderstorm::draw(DrawingContext& context)
{
  if (!flash_display_timer.started()) return;

  float alpha = 0.33f;
  context.push_transform();
  context.set_translation(Vector(0, 0));
  context.color().draw_filled_rect(Vector(0, 0),
                                   Vector(static_cast<float>(context.get_width()),
                                          static_cast<float>(context.get_height())),
                                   Color(1, 1, 1, alpha), layer);
  context.pop_transform();

}
예제 #18
0
void
FloatingText::draw(DrawingContext& context)
{
  // make an alpha animation when disappearing
  float alpha;
  if(timer.get_timeleft() < FADING_TIME)
    alpha = timer.get_timeleft() * 255.0f / FADING_TIME;
  else
    alpha = 255.0f;

  context.push_transform();
  context.set_alpha(alpha);

  context.color().draw_text(Resources::normal_font, text, position, ALIGN_LEFT, LAYER_OBJECTS+1, FloatingText::text_color);

  context.pop_transform();
}
예제 #19
0
void
ScreenManager::draw_player_pos(DrawingContext& context)
{
  if (auto session = GameSession::current())
  {
    auto sector = session->get_current_sector();
    if (sector == nullptr)
      return;
    auto pos = sector->get_players()[0]->get_pos();
    auto pos_text = "X:" + std::to_string(int(pos.x)) + " Y:" + std::to_string(int(pos.y));

    context.color().draw_text(
      Resources::small_font, pos_text,
      Vector(static_cast<float>(context.get_width()) - Resources::small_font->get_text_width("99999x99999") - BORDER_X,
             BORDER_Y + 40.0f), ALIGN_LEFT, LAYER_HUD);
  }
}
예제 #20
0
파일: tux.cpp 프로젝트: HybridDog/supertux
void
Tux::draw(DrawingContext& context)
{
  if (m_worldmap->get_camera().is_panning()) return;

  std::string action = get_action_prefix_for_bonus(m_worldmap->get_savegame().get_player_status().bonus);
  if (!action.empty())
  {
    m_sprite->set_action(m_moving ? action + "-walking" : action + "-stop");
  }
  else
  {
    log_debug << "Bonus type not handled in worldmap." << std::endl;
    m_sprite->set_action("large-stop");
  }
  m_sprite->draw(context.color(), get_pos(), LAYER_OBJECTS);
}
예제 #21
0
void
ControllerHUD::draw(DrawingContext& context)
{
  Canvas& canvas = context.color();
  Controller& controller = InputManager::current()->get_controller();

  for(const auto& control: m_controls)
  {
    if (controller.pressed(control.first)) {
      canvas.draw_filled_rect(control.second, Color::WHITE, LAYER_HUD);
    } else if (controller.released(control.first)) {
      canvas.draw_filled_rect(control.second, Color::BLACK, LAYER_HUD);
    } else if (controller.hold(control.first)) {
      canvas.draw_filled_rect(control.second, Color::RED, LAYER_HUD);
    } else {
      canvas.draw_filled_rect(control.second, Color(0.5f, 0.5f, 0.5f), LAYER_HUD);
    }
  }
}
예제 #22
0
void
InvisibleBlock::draw(DrawingContext& context)
{
  if(visible || Editor::is_active())
    sprite->draw(context.color(), get_pos(), LAYER_OBJECTS);
}
예제 #23
0
void
SmokeCloud::draw(DrawingContext& context)
{
  sprite->draw(context.color(), position, LAYER_OBJECTS+1);
}
예제 #24
0
void SpawnPointMarker::draw(DrawingContext& context) {
  context.color().draw_surface(surface, bbox.p1, LAYER_FOREGROUND1);
}
예제 #25
0
void
Explosion::draw(DrawingContext& context)
{
  sprite->draw(context.color(), get_pos(), LAYER_OBJECTS+40);
  lightsprite->draw(context.light(), bbox.get_middle(), 0);
}
예제 #26
0
void
ObjectIcon::draw(DrawingContext& context, const Vector& pos) {
  context.color().draw_surface_part(surface, Rectf(Vector(0,0), surface->get_size()),
                                      Rectf(pos + offset, pos + Vector(32,32) - offset), LAYER_GUI - 9);
}
예제 #27
0
파일: root.cpp 프로젝트: HybridDog/supertux
void
Root::draw(DrawingContext& context)
{
  base_sprite->draw(context.color(), m_start_position, LAYER_TILES+1);
  if ((mystate != STATE_APPEARING) && (mystate != STATE_VANISHING)) BadGuy::draw(context);
}
예제 #28
0
void
TileMap::draw(DrawingContext& context)
{
  // skip draw if current opacity is 0.0
  if (m_current_alpha == 0.0f) return;

  context.push_transform();

  if (m_flip != NO_FLIP) context.set_flip(m_flip);

  if (m_editor_active) {
    if (m_current_alpha != 1.0f) {
      context.set_alpha(m_current_alpha);
    }
  } else {
    context.set_alpha(m_current_alpha/2);
  }

  const float trans_x = context.get_translation().x;
  const float trans_y = context.get_translation().y;
  const bool normal_speed = m_editor_active && Editor::is_active();
  context.set_translation(Vector(trans_x * (normal_speed ? 1.0f : m_speed_x),
                                 trans_y * (normal_speed ? 1.0f : m_speed_y)));

  Rectf draw_rect = context.get_cliprect();
  Rect t_draw_rect = get_tiles_overlapping(draw_rect);
  Vector start = get_tile_position(t_draw_rect.left, t_draw_rect.top);

  Vector pos;
  int tx, ty;

  std::unordered_map<SurfacePtr,
                     std::tuple<std::vector<Rectf>,
                                std::vector<Rectf>>> batches;

  for (pos.x = start.x, tx = t_draw_rect.left; tx < t_draw_rect.right; pos.x += 32, ++tx) {
    for (pos.y = start.y, ty = t_draw_rect.top; ty < t_draw_rect.bottom; pos.y += 32, ++ty) {
      int index = ty*m_width + tx;
      assert (index >= 0);
      assert (index < (m_width * m_height));

      if (m_tiles[index] == 0) continue;
      const Tile& tile = m_tileset->get(m_tiles[index]);

      if (g_debug.show_collision_rects) {
        tile.draw_debug(context.color(), pos, LAYER_FOREGROUND1);
      }

      const SurfacePtr& surface = Editor::is_active() ? tile.get_current_editor_surface() : tile.get_current_surface();
      if (surface) {
        std::get<0>(batches[surface]).emplace_back(surface->get_region());
        std::get<1>(batches[surface]).emplace_back(pos,
                                                   Sizef(static_cast<float>(surface->get_width()),
                                                         static_cast<float>(surface->get_height())));
      }
    }
  }

  Canvas& canvas = context.get_canvas(m_draw_target);

  for (auto& it : batches)
  {
    const SurfacePtr& surface = it.first;
    if (surface) {
      canvas.draw_surface_batch(surface,
                                std::move(std::get<0>(it.second)),
                                std::move(std::get<1>(it.second)),
                                m_current_tint, m_z_pos);
    }
  }

  context.pop_transform();
}
예제 #29
0
void
RainSplash::draw(DrawingContext& context)
{
  sprite->draw(context.color(), position, LAYER_OBJECTS);
}
예제 #30
0
void
Dialog::draw(DrawingContext& context)
{
  Rectf bg_rect(Vector(static_cast<float>(m_passive ?
                                          (static_cast<float>(context.get_width()) - m_text_size.width - 20.0f) :
                                          static_cast<float>(context.get_width()) / 2.0f - m_text_size.width / 2.0f),
                       static_cast<float>(m_passive ?
                                          (static_cast<float>(context.get_height()) - m_text_size.height - 65.0f) :
                                          (static_cast<float>(context.get_height()) / 2.0f - m_text_size.height / 2.0f))),
                Sizef(m_text_size.width,
                      m_text_size.height + 44));

  // draw background rect
  context.color().draw_filled_rect(bg_rect.grown(12.0f),
                                     Color(0.2f, 0.3f, 0.4f, m_passive ? 0.3f : 0.8f),
                                     16.0f,
                                     LAYER_GUI-10);

  context.color().draw_filled_rect(bg_rect.grown(8.0f),
                                     Color(0.6f, 0.7f, 0.8f, m_passive ? 0.2f : 0.5f),
                                     16.0f,
                                     LAYER_GUI-10);

  // draw text
  context.color().draw_text(Resources::normal_font, m_text,
                              Vector(bg_rect.get_left() + bg_rect.get_width()/2.0f,
                                     bg_rect.get_top()),
                              ALIGN_CENTER, LAYER_GUI);
  if (m_passive)
    return;

  // draw HL line
  context.color().draw_filled_rect(Rectf(Vector(bg_rect.get_left(), bg_rect.get_bottom() - 35),
                                         Sizef(bg_rect.get_width(), 4)),
                                   Color(0.6f, 0.7f, 1.0f, 1.0f), LAYER_GUI);
  context.color().draw_filled_rect(Rectf(Vector(bg_rect.get_left(), bg_rect.get_bottom() - 35),
                                         Sizef(bg_rect.get_width(), 2)),
                                   Color(1.0f, 1.0f, 1.0f, 1.0f), LAYER_GUI);

  // draw buttons
  for (int i = 0; i < static_cast<int>(m_buttons.size()); ++i)
  {
    float segment_width = bg_rect.get_width() / static_cast<float>(m_buttons.size());
    float button_width = segment_width;
    Vector pos(bg_rect.get_left() + segment_width/2.0f + static_cast<float>(i) * segment_width,
               bg_rect.get_bottom() - 12);

    if (i == m_selected_button)
    {
      float button_height = 24.0f;
      float blink = (sinf(g_real_time * math::PI * 1.0f)/2.0f + 0.5f) * 0.5f + 0.25f;
      context.color().draw_filled_rect(Rectf(Vector(pos.x - button_width/2, pos.y - button_height/2),
                                               Vector(pos.x + button_width/2, pos.y + button_height/2)).grown(2.0f),
                                         Color(1.0f, 1.0f, 1.0f, blink),
                                         14.0f,
                                         LAYER_GUI-10);
      context.color().draw_filled_rect(Rectf(Vector(pos.x - button_width/2, pos.y - button_height/2),
                                               Vector(pos.x + button_width/2, pos.y + button_height/2)),
                                         Color(1.0f, 1.0f, 1.0f, 0.5f),
                                         12.0f,
                                         LAYER_GUI-10);
    }

    context.color().draw_text(Resources::normal_font, m_buttons[i].text,
                              Vector(pos.x, pos.y - static_cast<float>(int(Resources::normal_font->get_height() / 2))),
                              ALIGN_CENTER, LAYER_GUI,
                              i == m_selected_button ? ColorScheme::Menu::active_color : ColorScheme::Menu::default_color);
  }
}