Exemplo n.º 1
0
void  CHUDManager::RenderUI()
{
	if(!b_online)					return;

	BOOL bAlready					= FALSE;
	if (true || psHUD_Flags.is(HUD_DRAW | HUD_DRAW_RT))
	{
		HitMarker.Render			();
		bAlready					= ! (pUI && !pUI->Render());
		Font().Render();
	}

	if (psHUD_Flags.is(HUD_CROSSHAIR|HUD_CROSSHAIR_RT|HUD_CROSSHAIR_RT2) && !bAlready)	
		m_pHUDTarget->Render();

	draw_wnds_rects		();

	if( Device.Paused() && bShowPauseString){
		CGameFont* pFont	= Font().pFontGraffiti50Russian;
		pFont->SetColor		(0x80FF0000	);
		LPCSTR _str			= CStringTable().translate("st_game_paused").c_str();
		
		Fvector2			_pos;
		_pos.set			(UI_BASE_WIDTH/2.0f, UI_BASE_HEIGHT/2.0f);
		UI()->ClientToScreenScaled(_pos);
		pFont->SetAligment	(CGameFont::alCenter);
		pFont->Out			(_pos.x, _pos.y, _str);
		pFont->OnRender		();
	}

}
Exemplo n.º 2
0
void CActor::RenderText				(LPCSTR Text, Fvector dpos, float* pdup, u32 color)
{
	if (!g_Alive()) return;
	
	CBoneInstance& BI = smart_cast<CKinematics*>(Visual())->LL_GetBoneInstance(u16(m_head));
	Fmatrix M;
	smart_cast<CKinematics*>(Visual())->CalculateBones	();
	M.mul						(XFORM(),BI.mTransform);
	//------------------------------------------------
	Fvector v0, v1;
	v0.set(M.c); v1.set(M.c);
	Fvector T        = Device.vCameraTop;
	v1.add(T);

	Fvector v0r, v1r;
	Device.mFullTransform.transform(v0r,v0);
	Device.mFullTransform.transform(v1r,v1);
	float size = v1r.distance_to(v0r);
	CGameFont* pFont = HUD().Font().pFontArial14;
	if (!pFont) return;
//	float OldFontSize = pFont->GetHeight	();	
	float delta_up = 0.0f;
	if (size < mid_size) delta_up = upsize;
	else delta_up = upsize*(mid_size/size);
	dpos.y += delta_up;
	if (size > mid_size) size = mid_size;
//	float NewFontSize = size/mid_size * fontsize;
	//------------------------------------------------
	M.c.y += dpos.y;

	Fvector4 v_res;	
	Device.mFullTransform.transform(v_res,M.c);

	if (v_res.z < 0 || v_res.w < 0)	return;
	if (v_res.x < -1.f || v_res.x > 1.f || v_res.y<-1.f || v_res.y>1.f) return;

	float x = (1.f + v_res.x)/2.f * (Device.dwWidth);
	float y = (1.f - v_res.y)/2.f * (Device.dwHeight);

	pFont->SetAligment	(CGameFont::alCenter);
	pFont->SetColor		(color);
//	pFont->SetHeight	(NewFontSize);
	pFont->Out			(x,y,Text);
	//-------------------------------------------------
//	pFont->SetHeight(OldFontSize);
	*pdup = delta_up;
};
Exemplo n.º 3
0
void CUICellItemTradeMenuDraw::OnDraw(CUICellItem* cell)
{
	Fvector2							pos;
	cell->GetAbsolutePos				(pos);
	UI().ClientToScreenScaled			(pos, pos.x, pos.y);

	int acc									= cell->GetAccelerator();
	if(acc!=0)
	{
		if(acc==11)							
			acc = 1;
		string64							buff;

		xr_sprintf							(buff," %d", acc - DIK_ESCAPE);
		CGameFont* pFont					= UI().Font().pFontLetterica16Russian;
		pFont->SetAligment					(CGameFont::alCenter);
		pFont->SetColor						(color_rgba(135,123,116,255));
		pFont->Out							(pos.x, pos.y, buff);
		pFont->OnRender						();
	}

	bool b_can_buy_rank		= m_trade_wnd->CheckBuyPossibility(m_info_item->m_name_sect, CUIMpTradeWnd::bf_check_rank_restr, true);

	if(!b_can_buy_rank)
	{
		cell->SetTextureColor			(m_trade_wnd->m_item_color_restr_rank);
		return;
	}
	bool b_can_buy_money	= m_trade_wnd->CheckBuyPossibility(m_info_item->m_name_sect, CUIMpTradeWnd::bf_check_money, true);
	if(!b_can_buy_money)
	{
		cell->SetTextureColor			(m_trade_wnd->m_item_color_restr_money);
		return;
	}
	cell->SetTextureColor				(m_trade_wnd->m_item_color_normal);

}
Exemplo n.º 4
0
void  CUICustomEdit::Draw()
{
	Fvector2 pos, out;
	GetAbsolutePos		(pos);
	CGameFont* font		= TextItemControl()->m_pFont;
	
	if ( ec().need_update() || m_force_update )
	{
		float ui_width   = GetWidth();

		LPCSTR cursor_str   = ec().str_before_cursor();
		u32 cursor_str_size = xr_strlen( cursor_str );

		LPCSTR istr			= cursor_str;
		float str_length	= font->SizeOf_( istr );
		UI().ClientToScreenScaledWidth( str_length );

		u32 ix = 0;
		while ( (str_length > ui_width) && (ix < cursor_str_size) )
		{
			istr			= cursor_str + ix;
			str_length		= font->SizeOf_( istr );
			UI().ClientToScreenScaledWidth( str_length );
			++ix;
		}
		istr				= cursor_str + ix;
		LPCSTR astr			= ec().str_edit() + ix;
		u32 str_size		= xr_strlen( ec().str_edit() );

		u32 jx = 1;
		strncpy_s			(m_out_str, sizeof(m_out_str), astr, jx);

		str_length			= font->SizeOf_(m_out_str);
		UI().ClientToScreenScaledWidth(str_length);

		while((str_length < ui_width) && (jx < str_size-ix))
		{
			strncpy_s		(m_out_str, sizeof(m_out_str), astr, jx);
			str_length		= font->SizeOf_(m_out_str);
			UI().ClientToScreenScaledWidth(str_length);
			++jx;
		}
		strncpy_s			(m_out_str, sizeof(m_out_str), astr, jx);

		TextItemControl()->SetText(m_out_str);

		if(TextItemControl()->IsPasswordMode())
		{
			string256 passText;
			shared_str str(istr);
			int sz = (int)str.size();
			for (int i = 0; i < sz; i++)
				passText[i] = '*';
			passText[sz] = 0;
			m_dx_cur			= font->SizeOf_(passText); // cursor_str
		}
		else
			m_dx_cur			= font->SizeOf_(istr); // cursor_str

		m_force_update		= false;
	}

	inherited::Draw();

	if (m_bInputFocus) //draw cursor here
	{
		out.x = pos.x + 0.0f + TextItemControl()->m_TextOffset.x + TextItemControl()->GetIndentByAlign();
		out.y = pos.y + 2.0f + TextItemControl()->m_TextOffset.y + TextItemControl()->GetVIndentByAlign();
		UI().ClientToScreenScaled( out );

		out.x += m_dx_cur; // cursor_str

		font->Out				(out.x, out.y, "_");
	}
	font->OnRender				();
}
Exemplo n.º 5
0
void  CUICustomEdit::Draw()
{
	VERIFY( m_pLines );

	Fvector2 pos, out;
	GetAbsolutePos( pos );
	CGameFont* font = m_pLines->m_pFont;
	
	if ( ec().need_update() || m_force_update )
	{
		float ui_width   = GetWidth();

		LPCSTR cursor_str   = ec().str_before_cursor();
		u32 cursor_str_size = xr_strlen( cursor_str );

		LPCSTR istr = cursor_str;
		float str_length = font->SizeOf_( istr );
		UI()->ClientToScreenScaledWidth( str_length );

		u32 ix = 0;
		while ( (str_length > ui_width) && (ix < cursor_str_size) )
		{
			istr = cursor_str + ix;
			str_length = font->SizeOf_( istr );
			UI()->ClientToScreenScaledWidth( str_length );
			++ix;
		}
		istr = cursor_str + ix;
		LPCSTR astr = ec().str_edit() + ix;
		u32 str_size = xr_strlen( ec().str_edit() );

		u32 jx = 1;
		strncpy_s( m_out_str, sizeof(m_out_str), astr, jx );

		str_length = font->SizeOf_( m_out_str );
		UI()->ClientToScreenScaledWidth( str_length );
		while ( (str_length < ui_width) && (jx < str_size-ix) )
		{
			strncpy_s( m_out_str, sizeof(m_out_str), astr, jx );
			str_length = font->SizeOf_( m_out_str );
			UI()->ClientToScreenScaledWidth( str_length );
			++jx;
		}
		strncpy_s( m_out_str, sizeof(m_out_str), astr, jx );

		inherited::SetText( m_out_str );
		m_dx_cur = font->SizeOf_( istr ); // cursor_str

		m_force_update = false;
	}

	inherited::Draw();

	if ( m_bInputFocus ) //draw cursor here
	{
		out.x = pos.x + 0.0f + GetTextX() + m_pLines->GetIndentByAlign();
		out.y = pos.y + 2.0f + GetTextY() + m_pLines->GetVIndentByAlign();
		UI()->ClientToScreenScaled( out );

		out.x += m_dx_cur; // cursor_str

		font->Out( out.x, out.y, "_" );
	}
	font->OnRender();
}