Ejemplo n.º 1
0
void
SurfaceButton::draw (DrawingContext& gc)
{
  if (pressed && mouse_over)
    gc.draw(button_pressed_surface, Vector2i(x_pos, y_pos));
  else if (!pressed && mouse_over)
    gc.draw(button_mouse_over_surface, Vector2i(x_pos, y_pos));
  else
    gc.draw(button_surface, Vector2i(x_pos, y_pos));
}
Ejemplo n.º 2
0
void
TextObject::draw(DrawingContext& context)
{
  context.push_transform();
  context.set_translation(Vector(0, 0));
  if(fading > 0) {
    context.set_alpha((fadetime-fading) / fadetime);
  } else if(fading < 0) {
    context.set_alpha(-fading / fadetime);
  } else if(!visible) {
    context.pop_transform();
    return;
  }

  float width  = 500;
  float height = 70;
  Vector spos = pos + get_anchor_pos(Rectf(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
                                     width, height, anchor);

  context.draw_filled_rect(spos, Vector(width, height),
                           Color(0.6f, 0.7f, 0.8f, 0.5f), LAYER_GUI-50);
  if (centered) {
    context.draw_center_text(font, text, spos, LAYER_GUI-40, TextObject::default_color);
  } else {
    context.draw_text(font, text, spos + Vector(10, 10), ALIGN_LEFT, LAYER_GUI-40, TextObject::default_color);
  }

  context.pop_transform();
}
Ejemplo n.º 3
0
void
ItemHorizontalLine::draw(DrawingContext& context, Vector pos, int menu_width, bool active) {
  // TODO
  /* Draw a horizontal line with a little 3d effect */
  context.draw_filled_rect(Vector(pos.x, pos.y - 6),
                           Vector(menu_width, 4),
                           Color(0.6f, 0.7f, 1.0f, 1.0f), LAYER_GUI);
  context.draw_filled_rect(Vector(pos.x, pos.y - 6),
                           Vector(menu_width, 2),
                           Color(1.0f, 1.0f, 1.0f, 1.0f), LAYER_GUI);
}
Ejemplo n.º 4
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);
  }
}
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
void
LiveFire::draw(DrawingContext& context)
{
  //Draw the Sprite.
  sprite->draw(context, get_pos(), LAYER_OBJECTS);
  //Draw the light
  context.push_target();
  context.set_target(DrawingContext::LIGHTMAP);
  lightsprite->draw(context, get_bbox().get_middle(), 0);
  context.pop_target();
}
Ejemplo n.º 7
0
void
GUIStyle::draw_lowered_box(DrawingContext& gc, const Rect& rect, const Color& color, int border)
{
  // FIXME: Should use draw_line
  gc.draw_fillrect(rect,
                   Color(169, 157, 140));
  gc.draw_fillrect(Rect(rect.left+border, rect.top+border, rect.right, rect.bottom),
                   Color(255, 255, 255));
  gc.draw_fillrect(Rect(rect.left+border, rect.top+border, rect.right-border, rect.bottom-border),
                   color);  
}
Ejemplo n.º 8
0
void
StoryDot::draw_hover(DrawingContext& gc)
{
    gc.draw (m_story_dot_highlight, pos);

    gc.print_center(Fonts::pingus_small,
                    Vector2i(static_cast<int>(pos.x),
                             static_cast<int>(pos.y) - 44),
                    _(m_name),
                    10000);
}
Ejemplo n.º 9
0
static void
pop_state(void* _context)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->PopState();

	BPoint p(0, 0);
	context->ConvertToScreenForDrawing(&p);
	context->GetDrawingEngine()->SetDrawState(context->CurrentState(),
		(int32)p.x, (int32)p.y);
}
Ejemplo n.º 10
0
void
MrCandle::draw(DrawingContext& context) {
  BadGuy::draw(context);

  if (!frozen) {
    context.push_target();
    context.set_target(DrawingContext::LIGHTMAP);
    candle_light->draw(context, bbox.get_middle(), 0);
    context.pop_target();
  }
}
Ejemplo n.º 11
0
static void
draw_arc(void* _context, const BPoint& center, const BPoint& radii,
	float startTheta, float arcTheta, bool fill)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);

	BRect rect(center.x - radii.x, center.y - radii.y,
		center.x + radii.x - 1, center.y + radii.y - 1);
	context->ConvertToScreenForDrawing(&rect);
	context->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, fill);
}
Ejemplo n.º 12
0
static void
set_font_family(void* _context, const char* _family, size_t length)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	BString family(_family, length);

	FontStyle* fontStyle = gFontManager->GetStyleByIndex(family, 0);
	ServerFont font;
	font.SetStyle(fontStyle);
	context->CurrentState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
}
Ejemplo n.º 13
0
void
ScreenManager::draw_fps(DrawingContext& context, float fps_fps)
{
  char str[60];
  snprintf(str, sizeof(str), "%3.1f", fps_fps);
  const char* fpstext = "FPS";
  context.draw_text(Resources::small_font, fpstext,
                    Vector(SCREEN_WIDTH - Resources::small_font->get_text_width(fpstext) - Resources::small_font->get_text_width(" 99999") - BORDER_X,
                           BORDER_Y + 20), ALIGN_LEFT, LAYER_HUD);
  context.draw_text(Resources::small_font, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y + 20), ALIGN_RIGHT, LAYER_HUD);
}
Ejemplo n.º 14
0
void
Climbable::draw(DrawingContext& context)
{
  if (climbed_by && !message.empty()) {
    context.push_transform();
    context.set_translation(Vector(0, 0));
    Vector pos = Vector(0, SCREEN_HEIGHT/2 - Resources::normal_font->get_height()/2);
    context.draw_center_text(Resources::normal_font, _(message), pos, LAYER_HUD, Climbable::text_color);
    context.pop_transform();
  }
}
Ejemplo n.º 15
0
static void
set_line_mode(void* _context, cap_mode capMode, join_mode joinMode,
	float miterLimit)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	DrawState* state = context->CurrentState();
	state->SetLineCapMode(capMode);
	state->SetLineJoinMode(joinMode);
	state->SetMiterLimit(miterLimit);
	context->GetDrawingEngine()->SetStrokeMode(capMode, joinMode, miterLimit);
}
Ejemplo n.º 16
0
void
ItemHorizontalLine::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
  // TODO
  /* Draw a horizontal line with a little 3d effect */
  context.color().draw_filled_rect(Rectf(Vector(pos.x, pos.y - 6.0f),
                                         Sizef(static_cast<float>(menu_width), 4.0f)),
                                   Color(0.6f, 0.7f, 1.0f, 1.0f), LAYER_GUI);
  context.color().draw_filled_rect(Rectf(Vector(pos.x, pos.y - 6.0f),
                                         Sizef(static_cast<float>(menu_width), 2.0f)),
                                   Color(1.0f, 1.0f, 1.0f, 1.0f), LAYER_GUI);
}
Ejemplo n.º 17
0
void HorizontalLine::Draw(DrawingContext & drawingContext)
{
    auto transform = GetTransform() * drawingContext.Top();

    renderCommand.SetInvoker([this, transform](PolygonBatch & polygonBatch) {
        auto offset = Vector2{transform(2, 0), transform(2, 1)};
        auto start = offset + Vector2{0.0f, 0.0f};
        auto end = offset + Vector2{static_cast<float>(GetWidth()), 0.0f};
        polygonBatch.DrawLine(start, end, Color{92, 91, 90, 255}, 1.0f);
    });
    drawingContext.PushCommand(renderCommand);
}
Ejemplo n.º 18
0
static void
draw_rect(void* _context, const BRect& _rect, bool fill)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	BRect rect = _rect;

	context->ConvertToScreenForDrawing(&rect);
	if (fill)
		context->GetDrawingEngine()->FillRect(rect);
	else
		context->GetDrawingEngine()->StrokeRect(rect);
}
Ejemplo n.º 19
0
void
TreeWillOWisp::draw(DrawingContext& context)
{
  sprite->draw(context, get_pos(), layer);

  context.push_target();
  context.set_target(DrawingContext::LIGHTMAP);

  sprite->draw(context, get_pos(), layer);

  context.pop_target();
}
Ejemplo n.º 20
0
void
Lantern::draw(DrawingContext& context){
  //Draw the Sprite.
  MovingSprite::draw(context);
  //Let there be light.
  context.push_target();
  context.set_target(DrawingContext::LIGHTMAP);

  lightsprite->draw(context, bbox.get_middle(), 0);

  context.pop_target();
}
Ejemplo n.º 21
0
void
WillOWisp::draw(DrawingContext& context)
{
  sprite->draw(context, get_pos(), LAYER_OBJECTS);
  
  context.push_target();
  context.set_target(DrawingContext::LIGHTMAP);

  sprite->draw(context, get_pos(), LAYER_OBJECTS);
  
  context.pop_target();
}
void ParticleSystem_Interactive::draw(DrawingContext& context)
{
  context.push_transform();

  std::vector<Particle*>::iterator i;
  for(i = particles.begin(); i != particles.end(); ++i) {
    Particle* particle = *i;
    context.draw_surface(particle->texture, particle->pos, z_pos);
  }

  context.pop_transform();
}
Ejemplo n.º 23
0
static void
draw_round_rect(void* _context, const BRect& _rect, const BPoint& radii,
	bool fill)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	BRect rect = _rect;

	context->ConvertToScreenForDrawing(&rect);
	float scale = context->CurrentState()->CombinedScale();
	context->GetDrawingEngine()->DrawRoundRect(rect, radii.x * scale,
		radii.y * scale, fill);
}
Ejemplo n.º 24
0
void
Tip::draw(DrawingContext& context, Vector pos) {
  pos.y += 35;
  context.draw_text(Resources::normal_font, header, pos,
                    ALIGN_LEFT, LAYER_GUI-11, ColorScheme::Menu::label_color);

  for(const auto& str : strings) {
    pos.y += 22;
    context.draw_text(Resources::normal_font, str, pos,
                      ALIGN_LEFT, LAYER_GUI-11, ColorScheme::Menu::default_color);
  }
}
Ejemplo n.º 25
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.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT), Color(1, 1, 1, alpha), layer);
  context.pop_transform();

}
void ParticleSystem_Interactive::draw(DrawingContext& context)
{
  if(!enabled)
    return;

  context.push_transform();

  for(auto& particle : particles) {
    context.draw_surface(particle->texture, particle->pos, z_pos);
  }

  context.pop_transform();
}
Ejemplo n.º 27
0
void
PowerUp::draw(DrawingContext& context)
{
  sprite->draw(context.color(), get_pos(), layer);

  // Stars are brighter
  if (sprite_name == "images/powerups/star/star.sprite")
  {
    sprite->draw(context.color(), get_pos(), layer);
  }

  lightsprite->draw(context.light(), bbox.get_middle(), 0);
}
Ejemplo n.º 28
0
void
IceCrusher::draw(DrawingContext& context)
{
  m_sprite->draw(context.color(), get_pos(), m_layer+2);
  if (!(state == CRUSHING) && m_sprite->has_action("whites"))
  {
    // draw icecrusher's eyes slightly behind
    lefteye->draw(context.color(), get_pos()+eye_position(false), m_layer+1);
    righteye->draw(context.color(), get_pos()+eye_position(true), m_layer+1);
    // draw the whites of icecrusher's eyes even further behind
    whites->draw(context.color(), get_pos(), m_layer);
  }
}
Ejemplo n.º 29
0
static void
set_font_style(void* _context, const char* _style, size_t length)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	BString style(_style, length);

	ServerFont font(context->CurrentState()->Font());

	FontStyle* fontStyle = gFontManager->GetStyle(font.Family(), style);

	font.SetStyle(fontStyle);
	context->CurrentState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
}
Ejemplo n.º 30
0
void
BonusBlock::draw(DrawingContext& context){
  // do the regular drawing first
  Block::draw(context);
  // then Draw the light if on.
  if(sprite->get_action() == "on") {
    Vector pos = get_pos() + (bbox.get_size().as_vector() - lightsprite->get_size()) / 2;
    context.push_target();
    context.set_target(DrawingContext::LIGHTMAP);
    context.draw_surface(lightsprite, pos, 10);
    context.pop_target();
  }
}