예제 #1
0
float CUIPdaKillMessage::InitText(CUIStatic& refStatic, float x, PlayerInfo& info){

	if ( 0 == xr_strlen(info.m_name))
		return 0;

	float y								= 0;
	float selfHeight					= GetHeight();
	CGameFont* pFont					= GetFont();

	float width							= pFont->SizeOf_(*info.m_name);
	UI()->ClientToScreenScaledWidth		(width);

	float height						= pFont->CurrentHeight_();
	y = (selfHeight - height)/2;
	float __eps							= pFont->SizeOf_('o');//hack -(
	UI()->ClientToScreenScaledWidth		(__eps);

	clamp								(width, 0.0f, 120.0f);
	refStatic.Init						(x, 0/*y*/, width + __eps, height);
//.	refStatic.SetElipsis				(CUIStatic::eepEnd, 0);
	refStatic.SetText					(*info.m_name);
	refStatic.SetTextColor				(info.m_color);

	return		width;
}
예제 #2
0
float CUIPdaKillMessage::InitText(CUIStatic& refStatic, float x, PlayerInfo& info)
{

	if ( 0 == xr_strlen(info.m_name))
		return 0.0f;

	CGameFont* pFont					= GetFont();
	float _eps							= pFont->SizeOf_(' ');
	UI()->ClientToScreenScaledWidth		(_eps); //add one letter

	float height						= pFont->CurrentHeight_();
	float y								= (GetHeight() - height)/2;

	refStatic.SetWndPos					(Fvector2().set(x, y));
	refStatic.SetHeight					(GetHeight());
	refStatic.SetEllipsis				(1, 0);
	refStatic.SetText					(info.m_name.c_str());
	refStatic.AdjustWidthToText			();
	refStatic.SetWidth					(refStatic.GetWidth()+_eps);
	refStatic.SetTextColor				(info.m_color);

	return		refStatic.GetWidth		();
}
예제 #3
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				();
}
예제 #4
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();
}