Ejemplo n.º 1
0
CUIDragItem* CUICellItem::CreateDragItem()
{
	CUIDragItem* tmp;
	tmp = xr_new<CUIDragItem>(this);
	Frect r;
	GetAbsoluteRect(r);
	if( m_UIStaticItem.GetFixedLTWhileHeading() )
	{
		float w, h;
		w				= r.width();
		h				= r.height();
		if (Heading())
		{   // исправление пропорций
			w = w / m_cell_size.x * m_cell_size.y;
			h = h / m_cell_size.y * m_cell_size.x;
		}

		Fvector2 cp = GetUICursor()->GetCursorPosition();
		// поворот на 90 градусов, и центрирование по курсору мыша						
		r.x1			= (cp.x - h / 2.0f);
		r.y1			= (cp.y - w / 2.0f);
		r.x2			= r.x1 + h;
		r.y2			= r.y1 + w;
	} 
	tmp->Init(GetShader(),r,GetUIStaticItem().GetOriginalRect());
	return tmp;
}
Ejemplo n.º 2
0
CUIDragItem* CUICellItem::CreateDragItem()
{
	CUIDragItem* tmp;
	tmp = xr_new<CUIDragItem>(this);
	Frect r;
	GetAbsoluteRect(r);

	if( m_UIStaticItem.GetFixedLTWhileHeading() )
	{
		float t1,t2;
		t1				= r.width();
		t2				= r.height()*UI().get_current_kx();

		Fvector2 cp = GetUICursor().GetCursorPosition();

		r.x1			= (cp.x-t2/2.0f);
		r.y1			= (cp.y-t1/2.0f);
		r.x2			= r.x1 + t2;
		r.y2			= r.y1 + t1;
	}
	tmp->Init(GetShader(), r, GetUIStaticItem().GetTextureRect());
	return tmp;
}
Ejemplo n.º 3
0
void CUIProgressShape::Draw()
{
	if(m_bText)
		DrawText		();

	UIRender->SetShader				(*GetShader());
	Fvector2						tsize;
	UIRender->GetActiveTextureResolution(tsize);

	
	UIRender->StartPrimitive		(m_sectorCount*3,IUIRender::ptTriList, UI().m_currentPointType);

	Frect pos_rect;
	GetAbsoluteRect					(pos_rect);
	UI().ClientToScreenScaled		(pos_rect.lt, pos_rect.x1, pos_rect.y1);
	UI().ClientToScreenScaled		(pos_rect.rb, pos_rect.x2, pos_rect.y2);

	Fvector2						center_pos;
	pos_rect.getcenter				(center_pos);

	Frect tex_rect					= GetUIStaticItem().GetTextureRect();
	
	tex_rect.lt.x					/= tsize.x;
	tex_rect.lt.y					/= tsize.y;
	tex_rect.rb.x					/= tsize.x;
	tex_rect.rb.y					/= tsize.y;

	Fvector2						center_tex;
	tex_rect.getcenter				(center_tex);

	float		radius_pos			= pos_rect.width()/2.0f;

	float		radius_tex			= tex_rect.width()/2.0f;

	float		curr_angle			=  m_angle_begin;
	float		sin_a				= _sin(curr_angle);
	float		cos_a				= _cos(curr_angle);
	Fvector2	start_pos_pt,	prev_pos_pt;
	Fvector2	start_tex_pt,	prev_tex_pt;
	
	start_pos_pt.set				(0.0f, -radius_pos);
	prev_pos_pt						= start_pos_pt;

	start_tex_pt.set				(0.0f, -radius_tex);
	prev_tex_pt						= start_tex_pt;

	_make_rot_tex(prev_pos_pt, start_pos_pt.y, sin_a, cos_a);
	_make_rot_tex(prev_tex_pt, start_tex_pt.y, sin_a, cos_a);

	float angle_range = PI_MUL_2;
	if ( m_bClockwise )
	{
		angle_range = -abs( m_angle_end - m_angle_begin );
	}
	else
	{
		angle_range = abs( m_angle_end - m_angle_begin );
	}
	
	for ( u32 i = 0; i < m_sectorCount; ++i )
	{
		float ffff					= calc_color		(i+1, m_sectorCount, m_stage, 1.0f, m_blend);
		u32 color					= color_argb_f		(ffff,1.0f,1.0f,1.0f); 

		UIRender->PushPoint(center_pos.x, center_pos.y, 0, color, center_tex.x, center_tex.y);

		Fvector2	tp;
		tp.set						(prev_pos_pt);
		tp.add						(center_pos);

		Fvector2	tx;
		tx.set						(prev_tex_pt);
		tx.add						(center_tex);

		Fvector2	tp1;
		Fvector2	tx1;
		tp1.set(tp);
		tx1.set(tx);

		curr_angle					+= angle_range/float(m_sectorCount);

		sin_a						= _sin(curr_angle);
		cos_a						= _cos(curr_angle);

		_make_rot_tex(prev_pos_pt, start_pos_pt.y, sin_a, cos_a);
		_make_rot_tex(prev_tex_pt, start_tex_pt.y, sin_a, cos_a);

		tp.set						(prev_pos_pt);
		tp.add						(center_pos);

		tx.set						(prev_tex_pt);
		tx.add						(center_tex);

		if (m_bClockwise)
		{
			UIRender->PushPoint(tp1.x,	tp1.y,	0,	color, tx1.x,	tx1.y);
			UIRender->PushPoint(tp.x,	tp.y,	0,	color, tx.x,	tx.y);
		}
		else
		{
			UIRender->PushPoint(tp.x,	tp.y,	0, color, tx.x,		tx.y);
			UIRender->PushPoint(tp1.x,	tp1.y,	0, color, tx1.x,	tx1.y);
		}
	}


	UIRender->FlushPrimitive();
}