Beispiel #1
0
void
SliderBox::draw(DrawingContext& gc)
{
  if (globals::developer_mode)
    gc.draw_rect(rect, Color(0, 255, 255));

  if (value == 0)
  {
    gc.print_center(Fonts::chalk_normal, Vector2i(rect.left + rect.get_width()/2, rect.top), "off");
  }
  else
  {
    for(int i = 0; i < m_steps; ++i)
    {
      if (i < value)
        gc.print_left(Fonts::chalk_normal, Vector2i(rect.left + i*(rect.get_width()-12)/m_steps + 6, rect.top), "|");
      //gc.print_left(Fonts::chalk_normal, rect.left + i*(rect.get_width()-12)/20 + 6, rect.top, "l");
    }
  }

  gc.print_left(Fonts::chalk_normal, Vector2i(rect.left, rect.top),
                "[");
  gc.print_right(Fonts::chalk_normal, Vector2i(rect.right, rect.top),
                 "]");
}
Beispiel #2
0
void 
Checkbox::draw(DrawingContext& gc)
{
	gc.draw_rect(pos.x, pos.y, pos.x + width, pos.y + height, 
                     Color(0,0,0));
	if (is_checked)
		gc.draw(checkmark, pos);
	
	gc.print_right(Fonts::pingus_small, pos.x, pos.y, label);
}
Beispiel #3
0
void
SmallMap::draw(DrawingContext& gc)
{
  // FIXME: This is potentially dangerous, since we don't know how
  // long 'gc' will be alive. Should use a DrawingContext for caching.
  gc_ptr = &gc;

  World* const& world  = server->get_world();

  Vector2i of = playfield->get_pos();
  Rect view_rect;

  if (world->get_width() > gc.get_width())
  {
    int rwidth = int(gc.get_width()  * rect.get_width()  / world->get_width());
    view_rect.left  = rect.left + (of.x * rect.get_width()  / world->get_width()) - rwidth/2;
    view_rect.right = view_rect.left + rwidth;
  }
  else
  {
    view_rect.left  = rect.left;
    view_rect.right = rect.left + rect.get_width();
  }

  if (world->get_height() > gc.get_height())
  {
    int rheight = int(gc.get_height() * rect.get_height() / world->get_height());
    view_rect.top    = rect.top + (of.y * rect.get_height() / world->get_height()) - rheight/2;
    view_rect.bottom = view_rect.top + rheight;
  }
  else
  {
    view_rect.top    = rect.top;
    view_rect.bottom = rect.top + rect.get_height();
  }

  gc.draw(image->get_surface(), Vector2i(rect.left, rect.top));
  gc.draw_rect(view_rect, Color(0, 255, 0));

  server->get_world()->draw_smallmap(this);

  // Draw Pingus
  PinguHolder* pingus = world->get_pingus();
  for(PinguIter i = pingus->begin(); i != pingus->end(); ++i)
  {
    int x = static_cast<int>(static_cast<float>(rect.left) + ((*i)->get_x() * static_cast<float>(rect.get_width())
                                                              / static_cast<float>(world->get_width())));
    int y = static_cast<int>(static_cast<float>(rect.top)  + ((*i)->get_y() * static_cast<float>(rect.get_height())
                                                              / static_cast<float>(world->get_height())));

    gc.draw_line(Vector2i(x, y), Vector2i(x, y-2), Color(255, 255, 0));
  }

  gc_ptr = 0;
}
Beispiel #4
0
void
Inputbox::draw(DrawingContext& gc)
{
  gc.draw_fillrect(rect, Color(255,255,255));
  gc.draw_rect(rect, has_focus() ? Color(255,128,0) : Color(0,0,0));
  
  gc.print_left(Fonts::verdana11, 
                Vector2i(rect.left + 5, 
                         rect.top + rect.get_height()/2 - Fonts::verdana11.get_height()/2),
                text);
}
Beispiel #5
0
void
Combobox::draw(DrawingContext &gc)
{
  { // draw the unopened box
    gc.draw_fillrect(rect, Color(255,255,255));
    gc.draw(sprite, Vector2i(rect.right - 12, rect.top));
    gc.draw_rect(rect, Color(0,0,0));

    if (current_item != -1)
    {
      gc.print_left(Fonts::verdana11, 
                    Vector2i(rect.left + 5, 
                             rect.top + rect.get_height()/2 - Fonts::verdana11.get_height()/2),
                    item_list[current_item].label);
    }
  }

  if (drop_down && !item_list.empty())
  {
    gc.draw_fillrect(list_rect, Color(255,255,255), 90);

    for (int i = 0; i < int(item_list.size()); ++i)
    {
      if (i == hover_item)
        gc.draw_fillrect(Rect(Vector2i(rect.left, list_rect.top + rect.get_height()*i),
                              Size(rect.get_width(), rect.get_height())),
                         Color(150,200,255), 95);

      gc.print_left(Fonts::verdana11, 
                    Vector2i(list_rect.left + 5, 
                             list_rect.top + i * rect.get_height() + rect.get_height()/2 - Fonts::verdana11.get_height()/2),
                    item_list[i].label, 100);
    }

    gc.draw_rect(list_rect, Color(0,0,0), 100);
  }
}
Beispiel #6
0
void
ChoiceBox::draw(DrawingContext& gc)
{
  if (globals::developer_mode)
    gc.draw_rect(rect, Color(0, 255, 255));  

  if (!choices.empty())
  {
    if (current_choice >= 0 && current_choice < int(choices.size()))
    {
      //if (current_choice != 0) 
      gc.print_left(Fonts::chalk_normal,  Vector2i(rect.left, rect.top), "<");

      //if (current_choice != int(choices.size())-1)
      gc.print_right(Fonts::chalk_normal, Vector2i(rect.right, rect.top), ">");

      gc.print_center(Fonts::chalk_normal, Vector2i(rect.left + rect.get_width()/2, rect.top), 
                      choices[current_choice]);
    }
  }
}
Beispiel #7
0
void
FileList::draw(DrawingContext& gc)
{
  GUIStyle::draw_lowered_box(gc, rect, Color(255, 255, 255));

  int end = (page+1) * items_per_page();
  if (end > int(directory.size()))
    end = static_cast<int>(directory.size());

  int x = rect.left;
  int y = rect.top;
  for(System::Directory::iterator i = directory.begin() + page * items_per_page();
      i != directory.begin() + end; ++i)
  {
    if (i->type == System::DE_DIRECTORY)
      gc.draw(directory_icon, Vector2i(x, y));
    else if (i->type == System::DE_FILE)
      gc.draw(file_icon, Vector2i(x, y));

    if ((click_item == -1 && (i - directory.begin()) == current_item) ||
        (i - directory.begin()) == click_item)
    {
      if (click_item == current_item)
        gc.draw_fillrect(Rect(x, y, x + hspace, y + vspace), Color(0, 0, 255));
      else
        gc.draw_rect(Rect(x, y, x + hspace, y + vspace), Color(0, 0, 255));
    }

    gc.print_left(Fonts::verdana11, Vector2i(x + 4, y + 3),
                  ((i->type == System::DE_DIRECTORY) ? "[DIR]  " : "[FILE] ") + i->name);

    y += 20;
    if (y > rect.bottom - vspace)
    {
      y = rect.top;
      x += hspace;
    }
  }
}
Beispiel #8
0
// Draw the sprite
void
LevelObj::draw(DrawingContext &gc)
{
  if (attribs & HAS_SURFACE || attribs & HAS_SURFACE_FAKE)
  {
    if (attribs & HAS_REPEAT)
    {
      for(int x = static_cast<int>(pos.x); x < static_cast<int>(pos.x) + sprite.get_width() * repeat; x += sprite.get_width())
      {
        gc.draw(sprite, Vector3f(static_cast<float>(x), pos.y, pos.z));
      }
    }
#if 0
    else if(attribs & HAS_STRETCH)
    {
      // Surface Background - tile it
      for (int x = 0; x < level->size.width; x += sprite.get_width())
        for (int y = 0; y < level->size.height; y += sprite.get_height())
          gc.draw(sprite, Vector3f((float)x, (float)y, pos.z));
    }
#endif
    else if (attribs & HAS_COLOR && section_name == "solidcolor-background")
    { // FIXME: Should we have the object type in non-string form?
      gc.draw_fillrect(get_rect(), color, pos.z);
      gc.draw(sprite, pos);
    }
    else
    {
      gc.draw(sprite, pos);
    }

    // If selected, draw a highlighted box around it
    if (selected)
    {
      gc.draw_fillrect(get_rect(), Color(255,0,0,50), pos.z);
      gc.draw_rect(get_rect(), Color(255,0,0), pos.z);
    }
  }
}
Beispiel #9
0
void
GenericLevelObj::draw_selection(DrawingContext &gc)
{
  gc.draw_fillrect(get_rect(), Color(255,0,0,50), pos.z);
  gc.draw_rect(get_rect(), Color(255,0,0), pos.z);
}