Beispiel #1
0
void  CUIButton::Update()
{
	CUIStatic::Update();

	if(CursorOverWindow() && m_hint_text.size() && !g_btnHint->Owner() && Device.dwTimeGlobal>m_dwFocusReceiveTime+500)
	{
		g_btnHint->SetHintText	(this,*m_hint_text);

		Fvector2 c_pos			= GetUICursor()->GetCursorPosition();
		Frect vis_rect;
		vis_rect.set			(0,0,UI_BASE_WIDTH, UI_BASE_HEIGHT);

		//select appropriate position
		Frect r;
		r.set					(0.0f, 0.0f, g_btnHint->GetWidth(), g_btnHint->GetHeight());
		r.add					(c_pos.x, c_pos.y);

		r.sub					(0.0f,r.height());
		if (false==is_in2(vis_rect,r))
			r.sub				(r.width(),0.0f);
		if (false==is_in2(vis_rect,r))
			r.add				(0.0f,r.height());

		if (false==is_in2(vis_rect,r))
			r.add				(r.width(), 45.0f);

		g_btnHint->SetWndPos(r.lt);
	}
}
Beispiel #2
0
bool CUIWindow::AlignHintWndPos( Frect const& vis_rect, float border, float dx16pos ) //this = hint wnd
{
	float const cursor_height = 43.0f;
	Fvector2 cursor_pos	= GetUICursor()->GetCursorPosition();
	if ( UI()->is_16_9_mode() )
	{
		cursor_pos.x -= dx16pos;
	}

	if ( !vis_rect.in(cursor_pos) )
	{
		return false;
	}

	Frect	rect;
	rect.set( -border, -border, GetWidth() - 2.0f*border, GetHeight() - 2.0f*border );
	rect.add( cursor_pos.x, cursor_pos.y );

	rect.sub( 0.0f, rect.height() - border );
	if ( !is_in( vis_rect, rect ) ) {	rect.sub( rect.width() - border, 0.0f                   );	}
	if ( !is_in( vis_rect, rect ) ) {	rect.add( 0.0f                 , rect.height() - border );	}
	if ( !is_in( vis_rect, rect ) ) {	rect.add( rect.width() - border, cursor_height          );	}

	float yn = rect.top - vis_rect.height() + rect.height( ) - border + cursor_height;
	if ( !is_in( vis_rect, rect ) ) {	rect.sub( 0.0f                 , yn                     );	}
	if ( !is_in( vis_rect, rect ) ) {	rect.sub( rect.width() - border, 0.0f                   );	}

	SetWndPos( rect.lt );
	return true;
}
Beispiel #3
0
bool CUITradeWnd::OnItemFocusedUpdate(CUICellItem* itm)
{
	if ( itm )
	{
		#ifdef INV_FLOAT_ITEM_INFO
		Fvector2 c_pos			= GetUICursor()->GetCursorPosition();
		Frect vis_rect;
		vis_rect.set			(0,0,UI_BASE_WIDTH, UI_BASE_HEIGHT);

		Frect r;
		r.set					(0.0f, 0.0f, m_uidata->UIItemInfo.GetWidth(), m_uidata->UIItemInfo.GetHeight());
		r.add					(c_pos.x, c_pos.y);

		r.sub					(0.0f,r.height());
		if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2)))
			r.sub				(r.width(),0.0f);
		if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2)))
			r.add				(0.0f,r.height());
		if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2)))
			r.add				(r.width(), 45.0f);

		m_uidata->UIItemInfo.SetWndPos(r.lt);
		SetCurrentItem	(itm);
		#endif
	}
	return true;
}
Beispiel #4
0
void CUICustomMap::OptimalFit(const Frect& r)
{
	if ((m_BoundRect.height()/r.height())<(m_BoundRect.width()/r.width()))
		FitToHeight	(r.height());
	else
		FitToWidth	(r.width());

}
Beispiel #5
0
void CUIGlobalMap::ClipByVisRect()
{
	Frect r					= GetWndRect();
	Frect clip				= GetClipperRect();
	if (r.x2<clip.width())	r.x1 += clip.width()-r.x2;
	if (r.y2<clip.height())	r.y1 += clip.height()-r.y2;
	if (r.x1>0.0f)			r.x1 = 0.0f;
	if (r.y1>0.0f)			r.y1 = 0.0f;
	SetWndPos				(r.x1,r.y1);
}
Beispiel #6
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;
}
Beispiel #7
0
float CUIPdaKillMessage::InitIcon(CUIStatic& refStatic, float x, IconInfo& info){
	if ( 0 == info.m_rect.width())
		return 0;

	if (info.m_shader == NULL)
		return 0;

	float		y = 0;
	float		selfHeight = GetHeight();
	float		scale = 0;
	Frect		rect = info.m_rect;

	float width = rect.width();
	float height = rect.height();
	
	scale = selfHeight/height;
	if (scale > 1)
		scale = 1;
	width  = width*scale;
	height = height*scale;
	y = (selfHeight - height) /2;
	refStatic.Init(x, y, width, height);
	refStatic.SetOriginalRect(info.m_rect);
	refStatic.SetShader(info.m_shader);
	refStatic.SetStretchTexture(true);

	return width;
}
Beispiel #8
0
void CUIButton::DrawTexture()
{
	Frect rect; 
	GetAbsoluteRect		(rect);

	if(m_bAvailableTexture && m_bTextureEnable)
	{
		if(m_eButtonState == BUTTON_UP || m_eButtonState == BUTTON_NORMAL)
			m_UIStaticItem.SetPos(rect.left + m_TextureOffset.x, rect.top + m_TextureOffset.y);
		else
			m_UIStaticItem.SetPos(rect.left + m_PushOffset.x + m_TextureOffset.x, rect.top + m_PushOffset.y + m_TextureOffset.y);

		if(m_bStretchTexture)
			m_UIStaticItem.SetRect(0, 0, rect.width(), rect.height());
		else
		{
			Frect r={0,0,
				m_UIStaticItem.GetOriginalRectScaled().width(),
				m_UIStaticItem.GetOriginalRectScaled().height()};
			m_UIStaticItem.SetRect(r);
		}

		if( Heading() )
			m_UIStaticItem.Render( GetHeading() );
		else
			m_UIStaticItem.Render();		
	}
}
Beispiel #9
0
bool CUIFrameWindow::get_points(Frect const& r, int i, Fvector2& LTp, Fvector2& RBp, Fvector2& LTt, Fvector2& RBt)
{
	LTt				= m_tex_rect[i].lt;
	RBt				= m_tex_rect[i].rb;

	LTp				= r.lt; 
	RBp				= r.lt; 
	RBp.x			+= m_tex_rect[i].width();
	RBp.y			+= m_tex_rect[i].height();

	float rem_x		= r.width()-m_tex_rect[i].width();
	float rem_y		= r.height()-m_tex_rect[i].height();
	if(rem_x<0.0f)
	{
		RBt.x		+= rem_x;
		RBp.x		+= rem_x;
	}
	if(rem_y<0.0f)
	{
		RBt.y		+= rem_y;
		RBp.y		+= rem_y;
	}

	return true;
}
Beispiel #10
0
Frect CUICustomItem::GetOriginalRectScaled()
{
	Frect rect = iOriginalRect;

	rect.x2		= rect.x1 + rect.width();
	rect.y2		= rect.y1 + rect.height();

	return rect;
}
Beispiel #11
0
void CUIRadioButton::Init(float x, float y, float width, float height){
	if (!m_pLines)
		m_pLines = xr_new<CUILines>();
	m_pLines->SetTextAlignment(CGameFont::alLeft);
    CUI3tButton::InitTexture("ui_radio");
	Frect r = m_background.GetE()->GetStaticItem()->GetRect(); 
	CUI3tButton::SetTextX(r.width());
    CUI3tButton::Init(x,y, width, r.height() - 5);
	m_pLines->Init(x,y,width,m_background.GetE()->GetStaticItem()->GetRect().height());
}
Beispiel #12
0
void CUIFrameLineWnd::DrawElements()
{
	UIRender->SetShader			(*m_shader);

	Fvector2					ts;
	UIRender->GetActiveTextureResolution(ts);

	Frect						rect;
	GetAbsoluteRect				(rect);
	UI().ClientToScreenScaled	(rect.lt);
	UI().ClientToScreenScaled	(rect.rb);
	
	float back_len				= 0.0f;
	u32 prim_count				= 6*2; //first&second 
	if(bHorizontal)
	{
		back_len				= rect.width()-m_tex_rect[flFirst].width()-m_tex_rect[flSecond].width();
		if(back_len<0.0f)
			rect.x2				-= back_len;

		if(back_len>0.0f)
			prim_count				+= 6* iCeil(back_len / m_tex_rect[flBack].width());
	}else
	{
		back_len				= rect.height()-m_tex_rect[flFirst].height()-m_tex_rect[flSecond].height();
		if(back_len<0)
			rect.y2				-= back_len;

		if(back_len>0.0f)
			prim_count				+= 6* iCeil(back_len / m_tex_rect[flBack].height());
	}

	UIRender->StartPrimitive	(prim_count, IUIRender::ptTriList, UI().m_currentPointType);

	for(int i=0; i<flMax; ++i)
	{
		Fvector2 LTt, RBt;
		Fvector2 LTp, RBp;
		int counter				= 0;

		while(inc_pos(rect, counter, i, LTp, RBp, LTt, RBt))
		{
			draw_rect				(LTp, RBp, LTt, RBt, m_texture_color, ts);
			++counter;
		};
	}
	UIRender->FlushPrimitive		();
}
bool CEvaluatorTargetMapShown::evaluate()
{
	if(m_storage->property(1)) return true;
	if(m_storage->property(2)) return true;
	Fvector2 pt					= m_object->m_tgtCenter; 
	pt.mul						(m_object->GlobalMap()->GetCurrentZoom());
	Fvector2 _p;
	m_object->GlobalMap()->GetAbsolutePos(_p);
	pt.add						(_p);
	Frect	rect	=	m_object->ActiveMapRect();
			rect.grow	(rect.width(),rect.height());
	if (rect.in(pt))	{
		m_storage->set_property	(2,true);
		return true;
	}
	return false;
}
Beispiel #14
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;
}
Beispiel #15
0
void CUIFrameWindow::DrawElements()
{
	UIRender->SetShader			(*m_shader);

	Fvector2					ts;
	UIRender->GetActiveTextureResolution(ts);

	Frect						rect;
	GetAbsoluteRect				(rect);
	UI().ClientToScreenScaled	(rect.lt);
	UI().ClientToScreenScaled	(rect.rb);
	
	Fvector2 back_len			= {0.0f, 0.0f};
	u32 rect_count				= 4; //lt+rt+lb+rb
	back_len.x					= rect.width()-m_tex_rect[fmLT].width()-m_tex_rect[fmRT].width();
	back_len.y					= rect.height()-m_tex_rect[fmLT].height()-m_tex_rect[fmRB].height();
	R_ASSERT					(back_len.x+EPS_L>=0.0f && back_len.y+EPS_L>=0.0f);
	
	u32 cnt =0;
	if(back_len.x>0.0f)//top+bottom
		cnt						= 2* iCeil(back_len.x/m_tex_rect[fmT].width());
	rect_count					+= cnt;

	if(back_len.y>0.0f)//left+right
		cnt						= 2* iCeil(back_len.y/m_tex_rect[fmL].height());
	rect_count					+= cnt;
	
	if(back_len.x>0.0f && back_len.y>0.0f) //back
		cnt						= iCeil(back_len.x/m_tex_rect[fmBK].width()) * iCeil(back_len.y/m_tex_rect[fmBK].height()) ;

	rect_count					+= cnt;

	rect_count					*= 6;
	
	UIRender->StartPrimitive	(rect_count, IUIRender::ptTriList, UI().m_currentPointType);

	Fvector2 LTt, RBt;
	Fvector2 LTp, RBp;

	Frect tmp					= rect;
	get_points					(tmp, fmLT, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.lt.x;
	tmp.lt.y					= rect.rb.y - m_tex_rect[fmLB].height();
	get_points					(tmp, fmLB, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.rb.x - m_tex_rect[fmRT].width();
	tmp.lt.y					= rect.lt.y;;
	get_points					(tmp, fmRT, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.rb.x - m_tex_rect[fmRB].width();
	tmp.lt.y					= rect.rb.y - m_tex_rect[fmRB].height();
	get_points					(tmp, fmRB, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	if(back_len.x>0.0f)
	{
		tmp.lt					= rect.lt;
		tmp.lt.x				+= m_tex_rect[fmLT].width();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRT].width();
		tmp.rb.y				= rect.lt.y+m_tex_rect[fmT].height();
		draw_tile_line			(tmp, fmT, true, ts);

		tmp.lt.x				= rect.lt.x+m_tex_rect[fmLT].width();
		tmp.lt.y				= rect.rb.y-m_tex_rect[fmB].height();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRT].width();
		tmp.rb.y				= rect.rb.y;
		draw_tile_line			(tmp, fmB, true, ts);
	}

	if(back_len.y>0.0f)
	{
		tmp.lt					= rect.lt;
		tmp.lt.y				+= m_tex_rect[fmLT].height();
		tmp.rb.x				= rect.lt.x+m_tex_rect[fmL].width();
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmLB].height();
		draw_tile_line			(tmp, fmL, false, ts);

		tmp.lt.x				= rect.rb.x-m_tex_rect[fmR].width();
		tmp.lt.y				= rect.lt.y+m_tex_rect[fmRT].height();;
		tmp.rb.x				= rect.rb.x;
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmRB].height();
		draw_tile_line			(tmp, fmR, false, ts);
	}

	if(back_len.x>0.0f && back_len.y>0.0f)
	{
		tmp.lt.x				= rect.lt.x+m_tex_rect[fmLT].width();
		tmp.lt.y				= rect.lt.y+m_tex_rect[fmLT].height();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRB].width();
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmRB].height();
		draw_tile_rect			(tmp, fmBK, ts);
	}

	UIRender->FlushPrimitive	();
}