Exemplo n.º 1
0
/**
 * \brief Create the radio button group.
 * \param f The font to use for the text.
 */
bear::gui::radio_group*
ptb::frame_profiles::create_profiles_radio_buttons( bear::visual::font f )
{
  bear::gui::radio_group* const radio_group( new bear::gui::radio_group );
  radio_group->set_size
    ( std::numeric_limits<bear::gui::size_type>::max(),
      std::numeric_limits<bear::gui::size_type>::max() );

  m_profile_radio_buttons.resize(PTB_NUMBER_OF_PROFILES);

  for ( unsigned int i = 0; i < PTB_NUMBER_OF_PROFILES; ++i )
    {
      m_profile_radio_buttons[i] =
        new bear::gui::radio_button( get_radio_off(), get_radio_on(), f );
      m_profile_radio_buttons[i]->set_text( "Width fill placeholder" );

      allow_focus(*m_profile_radio_buttons[i]);
      radio_group->add_button(m_profile_radio_buttons[i], get_margin());
    }

  radio_group->fit();
  get_content().insert( radio_group );

  m_profile_radio_buttons.back()->check();

  return radio_group;
} // frame_profiles::create_profiles_radio_buttons()
Exemplo n.º 2
0
/**
 * \brief Create the static text components.
 */
void ptb::frame_play_story::create_controls()
{
  m_thumb = new bear::gui::picture( get_default_thumb() );
  m_name_text = new bear::gui::scene_element();
  m_status_picture = new bear::gui::picture( get_status_picture() );

  get_content().insert( m_thumb );
  get_content().insert( m_name_text );
  get_content().insert( m_status_picture );

  m_second_player_status.energy = new horizontal_gauge
    ( get_layer().get_level().get_globals(), 100, "bar (light blue)",
      "bar (red)", "heart", true );

  m_first_player_status.energy = new horizontal_gauge
    ( get_layer().get_level().get_globals(), 100, "bar (green)",
      "bar (red)", "heart", true );

  create_player_component(m_first_player_status);
  create_player_component(m_second_player_status);
  create_bonus_component();

  bear::gui::visual_component* ok = create_ok_button();
  bear::gui::visual_component* back = create_back_button();
  bear::gui::visual_component* previous = create_previous_button();
  bear::gui::visual_component* next = create_next_button();

  position_controls( ok->top() + get_margin() );

  bear::gui::size_type sum_w
    ( 3 * get_margin() + ok->width() + back->width() + previous->width()
      + next->width() );

  const bear::gui::size_type w
    ( (m_bonus->width() + m_thumb->width() + 2*get_margin() - sum_w) / 3);

  back->set_left( ok->right() + w );
  previous->set_left( back->right() + w );
  next->set_right( m_status_picture->right() );

  ok->set_focus();

  fit( get_margin() );
} // frame_play_story::create_controls()
Exemplo n.º 3
0
bool StageSelectScene::is_mouse_on_right_arrow() const
{
	if ( ! has_next_page() ) return false;

	win::Rect rect = win::Rect::Size( get_width() - get_margin() - right_arrow_src_rect_.width(), ( get_height() - right_arrow_src_rect_.height() ) / 2, right_arrow_src_rect_.width(), right_arrow_src_rect_.height() );

	if ( get_input()->get_mouse_x() <  rect.left()   ) return false;
	if ( get_input()->get_mouse_x() >= rect.right()  ) return false;
	if ( get_input()->get_mouse_y() <  rect.top()    ) return false;
	if ( get_input()->get_mouse_y() >= rect.bottom() ) return false;

	return true;
}
Exemplo n.º 4
0
/**
 * \brief Create the static text components.
 */
void ptb::frame_profiles::create_controls()
{
  bear::visual::font font = get_font();

  m_profiles = create_profiles_radio_buttons( font );
  bear::gui::visual_component* ok_button = create_ok_button( font );
  bear::gui::visual_component* cancel_button = create_back_button( font );
  bear::gui::visual_component* remove_button = create_remove_button( font );

  ok_button->set_top( m_profiles->bottom() - get_margin() );

  cancel_button->set_top( ok_button->top() );
  cancel_button->set_left( ok_button->right() + get_margin() );

  remove_button->set_top( ok_button->top() );
  remove_button->set_left( cancel_button->right() + get_margin() );

  ok_button->set_focus();
  update_controls();

  fit( get_margin() );
} // frame_profiles::create_controls()
Exemplo n.º 5
0
/**
 * \brief Create the "Next" button.
 */
bear::gui::visual_component* ptb::frame_play_story::create_next_button()
{
  bear::gui::button* result =
    new bear::gui::button
    ( get_font(), gettext("Next"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_play_story::on_next, this ) ) );

  result->set_margin( get_margin() / 2 );
  set_borders_up( *result );
  insert_control( *result );

  return result;
} // frame_play_story::create_next_button()
Exemplo n.º 6
0
/**
 * \brief Set position of controls.
 * \param b The bottom position of the controls.
 */
void
ptb::frame_play_story::position_controls( bear::gui::coordinate_type b )
{
  bear::universe::coordinate_type width =
    (get_layer().get_size().x - 100 - get_margin() - m_thumb->width()) / 2;

  m_first_player_status.component->set_size( width, m_thumb->height() );
  player_status_position_controls(m_first_player_status);

  m_second_player_status.component->set_size( width, m_thumb->height() );
  player_status_position_controls(m_second_player_status);

  m_bonus_text->set_size
    ( get_layer().get_size().x -100 + get_margin(), 25 );
  m_bonus_text->set_bottom( b + get_margin());
  m_bonus_text->set_left( get_margin() );

  m_bonus->set_size
    ( 2*width + get_margin(), m_thumb->height() );
  m_bonus->set_bottom( m_bonus_text->top() );

  m_status_picture->set_bottom_left
    ( m_bonus->right() + get_margin(), m_bonus->bottom() );
  m_thumb->set_bottom( m_bonus->top() + get_margin() );

  m_first_player_status.component->set_bottom_left
    ( m_thumb->right() + get_margin(), m_thumb->bottom() );
  if ( m_second_player_status.component )
     m_second_player_status.component->set_bottom_left
       ( m_first_player_status.component->right() + get_margin(),
         m_thumb->bottom() );

  // The height of the font used for the name of the mini-game
  m_name_text->set_height(50);
  m_name_text->set_bottom( m_thumb->top() + get_margin() );
} // frame_play_story::position_controls()
Exemplo n.º 7
0
/**
 * \brief Create the "remove" button.
 * \param f The font to use for the texts.
 */
bear::gui::visual_component*
ptb::frame_profiles::create_remove_button( bear::visual::font f )
{
  bear::gui::button* result =
    new bear::gui::button
    ( f, gettext("Remove"),
      bear::gui::callback_function_maker
      ( boost::bind(&frame_profiles::on_remove, this) ) );

  result->set_margin( get_margin() / 2 );
  set_borders_up(*result);
  insert_control(*result);

  return result;
} // frame_profiles::create_remove_button()
Exemplo n.º 8
0
/**
 * \brief Update level name.
 */
void ptb::frame_play_story::update_level_name()
{
  // Adjust the height of m_name_text in position_controls() to the height
  // of this font
  const bear::visual::writing w
    ( get_layer().get_level().get_globals().get_font
      ("font/level_name-42x50.fnt", 50),
      gettext(m_levels[m_index].get_id().c_str()) );

  m_name_text->set_size
    ( std::min(w.get_width(), get_content().width()), 50 );
  m_name_text->set_scene_element( bear::visual::scene_writing(0, 0, w) );
  m_name_text->set_position
    ( (get_content().width() - m_name_text->width()) / 2,
      m_thumb->top() + get_margin());
} // frame_play_story::update_level_name()
Exemplo n.º 9
0
win::Rect StageSelectScene::get_stage_dst_rect( const Stage* /* stage */, int n ) const
{
	const int stage_x_count = 2;
	const int stage_y_count = 2;

	int w = get_width() - get_margin() - left_arrow_src_rect_.width() - get_margin() * 2 - right_arrow_src_rect_.width() - get_margin();
	int h = get_height() - get_margin() * 2;

	int stage_interval_w = w / stage_x_count;
	int stage_interval_h = h / stage_y_count;

	int dst_w = 512;
	
	dst_w = std::min( dst_w, stage_interval_w - get_margin() - 20 );
	dst_w = std::min( dst_w, stage_interval_h - get_margin() - 20 );

	int x = n % stage_x_count;
	int y = n / stage_x_count;

	int dx = get_margin() + left_arrow_src_rect_.width() + get_margin() + stage_interval_w * x + stage_interval_w / 2;
	int dy = get_margin() + stage_interval_h * y + stage_interval_h / 2;

	return win::Rect::Size( dx - dst_w / 2, dy - dst_w / 2, dst_w, dst_w );
}
Exemplo n.º 10
0
/*
 * Adjusts the desired velocity for the circular fence.
 */
void AC_Avoid::adjust_velocity_circle(const float kP, const float accel_cmss, Vector2f &desired_vel)
{
    // exit if circular fence is not enabled
    if ((_fence.get_enabled_fences() & AC_FENCE_TYPE_CIRCLE) == 0) {
        return;
    }

    // exit if the circular fence has already been breached
    if ((_fence.get_breaches() & AC_FENCE_TYPE_CIRCLE) != 0) {
        return;
    }

    // get position as a 2D offset in cm from ahrs home
    const Vector2f position_xy = get_position();

    float speed = desired_vel.length();
    // get the fence radius in cm
    const float fence_radius = _fence.get_radius() * 100.0f;
    // get the margin to the fence in cm
    const float margin = get_margin();

    if (!is_zero(speed) && position_xy.length() <= fence_radius) {
        // Currently inside circular fence
        Vector2f stopping_point = position_xy + desired_vel*(get_stopping_distance(kP, accel_cmss, speed)/speed);
        float stopping_point_length = stopping_point.length();
        if (stopping_point_length > fence_radius - margin) {
            // Unsafe desired velocity - will not be able to stop before fence breach
            // Project stopping point radially onto fence boundary
            // Adjusted velocity will point towards this projected point at a safe speed
            Vector2f target = stopping_point * ((fence_radius - margin) / stopping_point_length);
            Vector2f target_direction = target - position_xy;
            float distance_to_target = target_direction.length();
            float max_speed = get_max_speed(kP, accel_cmss, distance_to_target);
            desired_vel = target_direction * (MIN(speed,max_speed) / distance_to_target);
        }
    }
}
Exemplo n.º 11
0
/**
 * \brief Create the static text components.
 */
void ptb::frame_pause::create_controls()
{
#ifdef PTB_CAN_RESTART_LEVEL
  push
    ( gettext("Restart level"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_pause::on_restart_level, this ) ) );
#endif

  push
    ( gettext("Back to title screen"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_pause::on_title_screen, this ) ) );
  push
    ( gettext("Configuration"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_pause::on_configuration, this ) ) );
  push
    ( gettext("Resume game"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_pause::on_resume, this ) ) );

  fit( get_margin() );
} // frame_pause::create_controls()
Exemplo n.º 12
0
/**
 * \brief Create the static text components.
 */
void ptb::frame_configure::create_controls()
{
  push
    ( gettext("Back"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_configure::on_back, this ) ) );

  if ( game_variables::get_password_menu_visibility() == true )
    push
      ( gettext("Password"),
        bear::gui::callback_function_maker
        ( boost::bind( &frame_configure::on_password, this ) ) );

  push
    ( gettext("Audio"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_configure::on_audio, this ) ) );
  push
    ( gettext("Screen"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_configure::on_screen, this ) ) );
  push
    ( gettext("Game options"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_configure::on_game_options, this ) ) );
  push
    ( gettext("Player two's controls"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_configure::on_second_player_controls, this ) ) );
  push
    ( gettext("Player one's controls"),
      bear::gui::callback_function_maker
      ( boost::bind( &frame_configure::on_first_player_controls, this ) ) );

  fit( get_margin() );
} // frame_configure::create_controls()
Exemplo n.º 13
0
/*
 * Adjusts the desired velocity for the polygon fence.
 */
void AC_Avoid::adjust_velocity_polygon(float kP, float accel_cmss, Vector2f &desired_vel, const Vector2f* boundary, uint16_t num_points, bool earth_frame)
{
    // exit if there are no points
    if (boundary == nullptr || num_points == 0) {
        return;
    }

    // do not adjust velocity if vehicle is outside the polygon fence
    Vector3f position;
    if (earth_frame) {
        position = _inav.get_position();
    }
    Vector2f position_xy(position.x, position.y);
    if (_fence.boundary_breached(position_xy, num_points, boundary)) {
        return;
    }

    // Safe_vel will be adjusted to remain within fence.
    // We need a separate vector in case adjustment fails,
    // e.g. if we are exactly on the boundary.
    Vector2f safe_vel(desired_vel);

    // if boundary points are in body-frame, rotate velocity vector from earth frame to body-frame
    if (!earth_frame) {
        safe_vel.x = desired_vel.y * _ahrs.sin_yaw() + desired_vel.x * _ahrs.cos_yaw(); // right
        safe_vel.y = desired_vel.y * _ahrs.cos_yaw() - desired_vel.x * _ahrs.sin_yaw(); // forward
    }

    uint16_t i, j;
    for (i = 1, j = num_points-1; i < num_points; j = i++) {
        // end points of current edge
        Vector2f start = boundary[j];
        Vector2f end = boundary[i];
        // vector from current position to closest point on current edge
        Vector2f limit_direction = Vector2f::closest_point(position_xy, start, end) - position_xy;
        // distance to closest point
        const float limit_distance = limit_direction.length();
        if (!is_zero(limit_distance)) {
            // We are strictly inside the given edge.
            // Adjust velocity to not violate this edge.
            limit_direction /= limit_distance;
            limit_velocity(kP, accel_cmss, safe_vel, limit_direction, MAX(limit_distance - get_margin(),0.0f));
        } else {
            // We are exactly on the edge - treat this as a fence breach.
            // i.e. do not adjust velocity.
            return;
        }
    }

    // set modified desired velocity vector
    if (earth_frame) {
        desired_vel = safe_vel;
    } else {
        // if points were in body-frame, rotate resulting vector back to earth-frame
        desired_vel.x = safe_vel.x * _ahrs.cos_yaw() - safe_vel.y * _ahrs.sin_yaw();
        desired_vel.y = safe_vel.x * _ahrs.sin_yaw() + safe_vel.y * _ahrs.cos_yaw();
    }
}
Exemplo n.º 14
0
void AC_Avoid::adjust_velocity_poly(const float kP, const float accel_cmss, Vector2f &desired_vel)
{
    // exit if the polygon fence is not enabled
    if ((_fence.get_enabled_fences() & AC_FENCE_TYPE_POLYGON) == 0) {
        return;
    }

    // exit if the polygon fence has already been breached
    if ((_fence.get_breaches() & AC_FENCE_TYPE_POLYGON) != 0) {
        return;
    }

    // get polygon boundary
    // Note: first point in list is the return-point (which copter does not use)
    uint16_t num_points;
    Vector2f* boundary = _fence.get_polygon_points(num_points);

    // exit if there are no points
    if (boundary == NULL || num_points == 0) {
        return;
    }

    // do not adjust velocity if vehicle is outside the polygon fence
    const Vector3f& position = _inav.get_position();
    Vector2f position_xy(position.x, position.y);
    if (_fence.boundary_breached(position_xy, num_points, boundary)) {
        return;
    }

    // Safe_vel will be adjusted to remain within fence.
    // We need a separate vector in case adjustment fails,
    // e.g. if we are exactly on the boundary.
    Vector2f safe_vel(desired_vel);

    uint16_t i, j;
    for (i = 1, j = num_points-1; i < num_points; j = i++) {
        // end points of current edge
        Vector2f start = boundary[j];
        Vector2f end = boundary[i];
        // vector from current position to closest point on current edge
        Vector2f limit_direction = Vector2f::closest_point(position_xy, start, end) - position_xy;
        // distance to closest point
        const float limit_distance = limit_direction.length();
        if (!is_zero(limit_distance)) {
            // We are strictly inside the given edge.
            // Adjust velocity to not violate this edge.
            limit_direction /= limit_distance;
            limit_velocity(kP, accel_cmss, safe_vel, limit_direction, MAX(limit_distance - get_margin(),0.0f));
        } else {
            // We are exactly on the edge - treat this as a fence breach.
            // i.e. do not adjust velocity.
            return;
        }
    }

    desired_vel = safe_vel;
}
Exemplo n.º 15
0
Size2 StyleBox::get_minimum_size() const {

	return Size2(get_margin(MARGIN_LEFT) + get_margin(MARGIN_RIGHT), get_margin(MARGIN_TOP) + get_margin(MARGIN_BOTTOM));
}
Exemplo n.º 16
0
Point2 StyleBox::get_offset() const {

	return Point2(get_margin(MARGIN_LEFT), get_margin(MARGIN_TOP));
}
Exemplo n.º 17
0
/**
 * 描画
 */
void StageSelectScene::render()
{
	Color bg_color = page_ < get_max_story_page() ? Color::from_256( 0xFF, 0xAA, 0x11 ) : Color::from_256( 0x99, 0xEE, 0xFF );

	get_direct_3d()->set_default_render_target();
	get_direct_3d()->set_default_viewport();

	get_direct_3d()->clear_default_view( bg_color );

	get_direct_3d()->getSprite()->begin();

	render_technique( "|sprite", [this]
	{
		// render_bg()
		{
			get_direct_3d()->getSprite()->draw( win::Rect::Size( 0, 0, get_width(), get_height() ), bg_texture_ );
		}
	} );

	Direct3D::Matrix t, s, transform;

	// Stage
	RectList::const_iterator j = circle_src_rect_list_.begin();
	RectList::const_iterator k = face_src_rect_list_.begin();

	for ( StageList::const_iterator i = stage_list_.begin(); i != stage_list_.end(); ++i, ++j, ++k )
	{
		Stage* stage = *i;

		// Direct3D::Vector center( stage_src_rect_.width() * 0.5f, stage_src_rect_.height() * 0.5f, 0.f );

		win::Rect dst_rect = stage->rect;

		// float dx = dst_rect.left() + dst_rect.width() * 0.5f - ( get_width() / 2 );
		// float dy = dst_rect.top() + dst_rect.height() * 0.5f - ( get_height() / 2 );

		int offset = 0;
		Direct3D::Color frame_color = Direct3D::Color::White;

		if ( stage == get_pointed_stage() )
		{
			if ( get_input()->press( Input::A ) )
			{
				offset = 3;
			}
			frame_color = Direct3D::Color::from_hex( 0xFFAA11FF );
		}

		win::Rect white_src_rect = win::Rect::Size( 0, 512, 128, 128 );
		// Direct3D::Vector white_center( white_src_rect.width() * 0.5f, white_src_rect.height() * 0.5f, 0.f );

		// float scale = static_cast< float >( dst_rect.width() ) / static_cast< float >( stage_src_rect_.width() );
		// float frame_scale = ( dst_rect.width() + 10.f ) / white_src_rect.width();
		const win::Rect frame_scale_rect( -5, -5, +5, +5 );

		// shadow
		get_direct_3d()->getSprite()->draw( dst_rect + frame_scale_rect + win::Point( -5, 5 ), sprite_texture_, white_src_rect, Direct3D::Color::from_hex( 0x00000099 ) );

		// white
		get_direct_3d()->getSprite()->draw( dst_rect + frame_scale_rect + win::Point( -offset, offset ), sprite_texture_, white_src_rect, frame_color );

		// stage
		get_direct_3d()->getSprite()->draw( dst_rect + win::Point( -offset, offset ), stage->texture, stage_src_rect_, Direct3D::Color::White );

		// circle
		if ( stage->cleared )
		{
			win::Point circle_dst_point = win::Point( dst_rect.right() - j->width(), dst_rect.bottom() - j->height() ) + win::Point( -offset, offset );
			get_direct_3d()->getSprite()->draw( circle_dst_point, sprite_texture_, *j, Direct3D::Color::from_hex( 0xFFFFFF99 ) );
		}

		// face
		if ( stage->completed )
		{
			// face
			if ( true )
			{
				win::Point circle_dst_point = win::Point( dst_rect.right() - j->width() + ( j->width() - k->width() ) / 2, dst_rect.bottom() - j->height() + ( j->height() - k->height() ) / 2 ) + win::Point( -offset, offset );
				get_direct_3d()->getSprite()->draw( circle_dst_point, sprite_texture_, *k, Direct3D::Color::from_hex( 0xFFFFFF99 ) );
			}

			// medal
			win::Rect medal_src_rect = win::Rect::Size( 832, 384, 64, 64 );
			win::Point medal_dst_point = win::Point( dst_rect.left(), dst_rect.bottom() - medal_src_rect.height() ) + win::Point( -offset, offset );
			get_direct_3d()->getSprite()->draw( medal_dst_point, sprite_texture_, medal_src_rect, Direct3D::Color::from_hex( 0xFFFFFF99 ) );
		}
	}

	// Arrow
	if ( has_prev_page() )
	{
		win::Rect src_rect = left_arrow_src_rect_;

		if ( is_mouse_on_left_arrow() )
		{
			src_rect.left() += 256;
			src_rect.right() += 256;
		}

		win::Point arrow_dst_point = win::Point( get_margin(), ( get_height() - src_rect.height() ) / 2 );
		get_direct_3d()->getSprite()->draw( arrow_dst_point, sprite_texture_, src_rect.get_rect() );
	}
	if ( has_next_page() )
	{
		win::Rect src_rect = right_arrow_src_rect_;

		if ( is_mouse_on_right_arrow() )
		{
			src_rect.left() += 256;
			src_rect.right() += 256;
		}

		win::Point arrow_dst_point( get_width() - get_margin() - src_rect.width(), ( get_height() - src_rect.height() ) / 2 );
		get_direct_3d()->getSprite()->draw( arrow_dst_point, sprite_texture_, src_rect.get_rect() );
	}

	// Cursor
	{
		win::Rect src_rect = cursor_src_rect_;

		if ( get_input()->press( Input::A ) )
		{
			src_rect.left() += 128;
			src_rect.right() += 128;
		}

		win::Point cursor_dst_point( get_input()->get_mouse_x(), get_input()->get_mouse_y() );
		get_direct_3d()->getSprite()->draw( cursor_dst_point, sprite_texture_, src_rect.get_rect() );
	}

	get_direct_3d()->getSprite()->end();

	render_fader();
}
Exemplo n.º 18
0
int SkRTree::distributeChildren(Branch* children) {
    // We have two sides to sort by on each of two axes:
    const static SortSide sorts[2][2] = {
        {&SkIRect::fLeft, &SkIRect::fRight},
        {&SkIRect::fTop, &SkIRect::fBottom}
    };

    // We want to choose an axis to split on, then a distribution along that axis; we'll need
    // three pieces of info: the split axis, the side to sort by on that axis, and the index
    // to split the sorted array on.
    int32_t sortSide = -1;
    int32_t k        = -1;
    int32_t axis     = -1;
    int32_t bestS    = SK_MaxS32;

    // Evaluate each axis, we want the min summed margin-value (s) over all distributions
    for (int i = 0; i < 2; ++i) {
        int32_t minOverlap   = SK_MaxS32;
        int32_t minArea      = SK_MaxS32;
        int32_t axisBestK    = 0;
        int32_t axisBestSide = 0;
        int32_t s = 0;

        // Evaluate each sort
        for (int j = 0; j < 2; ++j) {
            SkTQSort(children, children + fMaxChildren, RectLessThan(sorts[i][j]));

            // Evaluate each split index
            for (int32_t k = 1; k <= fMaxChildren - 2 * fMinChildren + 2; ++k) {
                SkIRect r1 = children[0].fBounds;
                SkIRect r2 = children[fMinChildren + k - 1].fBounds;
                for (int32_t l = 1; l < fMinChildren - 1 + k; ++l) {
                    join_no_empty_check(children[l].fBounds, &r1);
                }
                for (int32_t l = fMinChildren + k; l < fMaxChildren + 1; ++l) {
                    join_no_empty_check(children[l].fBounds, &r2);
                }

                int32_t area = get_area(r1) + get_area(r2);
                int32_t overlap = get_overlap(r1, r2);
                s += get_margin(r1) + get_margin(r2);

                if (overlap < minOverlap || (overlap == minOverlap && area < minArea)) {
                    minOverlap = overlap;
                    minArea = area;
                    axisBestSide = j;
                    axisBestK = k;
                }
            }
        }

        if (s < bestS) {
            bestS = s;
            axis = i;
            sortSide = axisBestSide;
            k = axisBestK;
        }
    }

    // replicate the sort of the winning distribution, (we can skip this if the last
    // sort ended up being best)
    if (!(axis == 1 && sortSide == 1)) {
        SkTQSort(children, children + fMaxChildren, RectLessThan(sorts[axis][sortSide]));
    }

    return fMinChildren - 1 + k;
}
Exemplo n.º 19
0
/**
 * \brief Set position of controls for player's informations.
 * \param p The object containing all player's information controls.
 */
void ptb::frame_play_story::player_status_position_controls
( player_status& p )
{
  bear::engine::level_globals& glob =
    get_layer().get_level().get_globals();

  p.energy->set_size
    (p.component->get_size().x - 2 * get_margin(),
     (p.component->get_size().y - 4*get_margin()) / 3);
  p.energy->set_bottom_left( get_margin(), get_margin());

  bear::visual::sprite s0(glob.auto_sprite("gfx/ui/status/status.png", "plee"));
  p.lives_picture->set_size(s0.get_size());
  p.lives_picture->set_bottom_left
    ( get_margin(), p.energy->top() + get_margin());

  p.lives_text->set_size
    (p.component->get_size().x / 2 - p.lives_picture->width() - get_margin(),
     (p.component->get_size().y - 4*get_margin()) / 3);
  p.lives_text->set_top_left
    (p.lives_picture->right() + get_margin(), p.lives_picture->top());

  p.score_text->set_size
    (p.component->get_size().x / 2,
     (p.component->get_size().y - 4*get_margin()) / 3);
  p.score_text->set_bottom_left
    ( get_margin(), p.lives_picture->top()+get_margin());

  bear::visual::sprite s1(glob.get_image("gfx/ui/air-power.png"));
  p.air_power->set_size(s1.get_size());

  p.air_power->set_top_left
    (p.score_text->right() + get_margin(), p.score_text->top());

  p.fire_power->set_size(s1.get_size());
  p.fire_power->set_top_left
    (p.air_power->right() + get_margin(), p.score_text->top());

  p.water_power->set_size(s1.get_size());
  p.water_power->set_top_left
    (p.fire_power->right() + get_margin(), p.score_text->top());

  bear::visual::sprite s2
    (glob.auto_sprite("gfx/stone/stone.png", "default stone"));
  p.stone_picture->set_size(s2.get_size());
  p.stone_picture->set_bottom_left
    (p.lives_text->right() + get_margin(), p.lives_text->bottom());

  p.stone_text->set_size
    (p.component->get_size().x / 2,
     (p.component->get_size().y - 4*get_margin()) / 3);
  p.stone_text->set_top_left
    ( p.stone_picture->right() + get_margin(), p.stone_picture->top());
} // frame_play_story::player_status_position_controls