//---------------------------------------------------
void SafeAreaRenderer::DrawSafeAreas( void )
{
#if ENABLE_HUD_EXTRA_DEBUG
	if( m_interactiveResize && !m_pResizer )
	{
		m_pResizer = new SafeAreaResizer(m_pScreenLayout);
	}
	else if(m_pResizer && !m_interactiveResize)
	{
		SAFE_DELETE( m_pResizer );
	}
#endif

	ScreenLayoutManager* pLayout = m_pScreenLayout;
	const Vec2 fullscreen_border = pLayout->GetSafeAreaBorderScreenProportion( eHSAID_fullscreen );
	const Vec2 title_safe_border = pLayout->GetSafeAreaBorderScreenProportion( eHSAID_title );
	const Vec2 sony_trc_safe_border = pLayout->GetSafeAreaBorderScreenProportion( eHSAID_PS3_trc );
	const Vec2 action_safe_border = pLayout->GetSafeAreaBorderScreenProportion( eHSAID_action );

	// Get state so we can reset later
	ScreenLayoutStates prev_state = pLayout->GetState();

	// Set to null state so we can render full screen.
	pLayout->SetState(eSLO_DoNotAdaptToSafeArea|eSLO_ScaleMethod_None);

	DrawSafeArea( string().Format( "fullscreen area : should not see me! %d%%x,%d%%y", (int)(100.0f*fullscreen_border.x), (int)(100.0f*fullscreen_border.y) ).c_str(), fullscreen_border    );
	DrawSafeArea( string().Format( "NTSC/PAL title safe %d%%x,%d%%y",  (int)(100.0f*title_safe_border.x),    (int)(100.0f*title_safe_border.y) ).c_str(),              title_safe_border    );
	DrawSafeArea( string().Format( "sony trc safe %d%%x,%d%%y",        (int)(100.0f*sony_trc_safe_border.x), (int)(100.0f*sony_trc_safe_border.y) ).c_str(),           sony_trc_safe_border );
	DrawSafeArea( string().Format( "NTSC/PAL action safe %d%%x,%d%%y", (int)(100.0f*action_safe_border.x),   (int)(100.0f*action_safe_border.y) ).c_str(),             action_safe_border   );
	if( pLayout->GetCurSafeAreaId() == eHSAID_custom )
	{
		const Vec2 custom_safe_border = pLayout->GetSafeAreaBorderScreenProportion( eHSAID_custom );
		DrawSafeArea( string().Format( "Custom safe %d%%x,%d%%y (%d,%d)pixels", (int)(100.0f*custom_safe_border.x), (int)(100.0f*custom_safe_border.y), (int)(gEnv->pRenderer->GetWidth()*(1.0f-(2.0f*custom_safe_border.x))), (int)(gEnv->pRenderer->GetHeight()*(1.0f-(2.0f*custom_safe_border.y)) ) ).c_str(), custom_safe_border );// , (int)(100.0f*m_customSafeArea))
	}

	// Size debug
	const float screen_width  = (float)pLayout->GetVirtualWidth();
	const float screen_height = (float)pLayout->GetVirtualHeight();
	const Vec2 cur_safe = pLayout->GetSafeAreaBorderScreenProportion( pLayout->GetCurSafeAreaId() );
	const vector2f orig( cur_safe.x * screen_width, cur_safe.y * screen_height );
	const vector2f max( screen_width - (cur_safe.x * screen_width), screen_height - (cur_safe.y * screen_height) );

	ColorF pos_text(1.0f, 1.0f, 1.0f, 1.0f);
	m_p2dRenderUtils->SetFont( gEnv->pCryFont->GetFont("default") );
	m_p2dRenderUtils->DrawText( orig.x, orig.y, 15.0f, 15.0f, "(0,0)", pos_text);
	m_p2dRenderUtils->DrawText(  max.x,  max.y, 15.0f, 15.0f, "(800,600)", pos_text, UIDRAWHORIZONTAL_RIGHT, UIDRAWVERTICAL_BOTTOM);

	pLayout->SetState(prev_state);
}
Пример #2
0
static void
distribute_vertically(void)
{
  int		 num_objects = 0;
  F_ellipse	*e;
  F_arc		*a;
  F_line	*l;
  F_spline	*s;
  F_compound	*c;
  F_text	*t;
  float		 inter_obj_space;
  int		 min_y, max_y;
  int		 obj1, obj2;
  int		 obj_type;
  F_line	*obj_ptr;
  int		 min_top, min_height;
  int		 req_pos;
  int		 sum_obj_height;


  if (cur_valign == ALIGN_DISTRIB_C)
    num_objects = init_distrib_centres (&min_y, &max_y, 1);
  else {
    num_objects = init_distrib_edges (&min_y, &max_y, &sum_obj_height, 1);
    req_pos = min_y;
  }
  if (num_objects <= 1)
    return;

  /* Determine the amount of space between objects (centres or edges) */
  if (cur_valign == ALIGN_DISTRIB_C)
    inter_obj_space = (float) (max_y - min_y) / (float)(num_objects - 1);
  else if (cur_valign == ALIGN_DISTRIB_E)
    inter_obj_space = (float) (max_y - min_y - sum_obj_height) / (float)(num_objects - 1);
  else
    inter_obj_space = 0.0;

  /*
   * Go through all of the objects, finding the top-most, then the second
   * top-most, ...
   */
  for (obj1=0; obj1<num_objects; obj1++) {
    min_top = INT_MAX;
    for (obj2=0; obj2<num_objects; obj2++) {
      for (e = cur_c->ellipses; e != NULL; e = e->next)
	if (pos_ellipse(e, &min_top, &min_height, 1))
	  { obj_ptr = (F_line *) e; obj_type = O_ELLIPSE; }
      for (a = cur_c->arcs; a != NULL; a = a->next)
	if (pos_arc(a, &min_top, &min_height, 1))
	  { obj_ptr = (F_line *) a; obj_type = O_ARC; }
      for (l = cur_c->lines; l != NULL; l = l->next)
	if (pos_line(l, &min_top, &min_height, 1))
	  { obj_ptr = (F_line *) l; obj_type = O_POLYLINE; }
      for (s = cur_c->splines; s != NULL; s = s->next)
	if (pos_spline(s, &min_top, &min_height, 1))
	  { obj_ptr = (F_line *) s; obj_type = O_SPLINE; }
      for (c = cur_c->compounds; c != NULL; c = c->next)
	if (pos_compound(c, &min_top, &min_height, 1))
	  { obj_ptr = (F_line *) c; obj_type = O_COMPOUND; }
      for (t = cur_c->texts; t != NULL; t = t->next)
	if (pos_text(t, &min_top, &min_height, 1))
	  { obj_ptr = (F_line *) t; obj_type = O_TEXT; }
    }

    /* Determine the new vertical position of the object */
    if (cur_valign == ALIGN_DISTRIB_C)
      req_pos = min_y + (int)((float)obj1 * inter_obj_space);

    /* Adjust position of left-most undistributed object */
    adjust_object_pos (obj_ptr, obj_type, 0, req_pos - min_top);

    /* Determine the virtical position of the next object */
    if ((cur_valign == ALIGN_DISTRIB_E) || (cur_valign == ALIGN_ABUT) )
      req_pos += min_height + (int)inter_obj_space;
  }

} /* distribute_vertically */