Beispiel #1
0
void CUIPdaWnd::DrawUpdatedSections				()
{
	m_updatedSectionImage->Update				();
	m_oldSectionImage->Update					();
	
	Fvector2									tab_pos;
	UITabControl->GetAbsolutePos				(tab_pos);

	Fvector2 pos;

	pos = m_sign_places_main[eptQuests];
	pos.add(tab_pos);
	if(g_pda_info_state&pda_section::quests)
		draw_sign								(m_updatedSectionImage, pos);
	else
		draw_sign								(m_oldSectionImage, pos);

	pos = m_sign_places_main[eptMap];
	pos.add(tab_pos);
	if(g_pda_info_state&pda_section::map)
		draw_sign								(m_updatedSectionImage, pos);
	else
		draw_sign								(m_oldSectionImage, pos);

	pos = m_sign_places_main[eptDiary];
	pos.add(tab_pos);
	if(g_pda_info_state&pda_section::diary)
		draw_sign								(m_updatedSectionImage, pos);
	else
		draw_sign								(m_oldSectionImage, pos);

	pos = m_sign_places_main[eptContacts];
	pos.add(tab_pos);
	if(g_pda_info_state&pda_section::contacts)
		draw_sign								(m_updatedSectionImage, pos);
	else
		draw_sign								(m_oldSectionImage, pos);

	pos = m_sign_places_main[eptRanking];
	pos.add(tab_pos);
	if(g_pda_info_state&pda_section::ranking)
		draw_sign								(m_updatedSectionImage, pos);
	else
		draw_sign								(m_oldSectionImage, pos);

	pos = m_sign_places_main[eptActorStatistic];
	pos.add(tab_pos);
	if(g_pda_info_state&pda_section::statistics)
		draw_sign								(m_updatedSectionImage, pos);
	else
		draw_sign								(m_oldSectionImage, pos);

	pos = m_sign_places_main[eptEncyclopedia];
	pos.add(tab_pos);
	if(g_pda_info_state&pda_section::encyclopedia)
		draw_sign								(m_updatedSectionImage, pos);
	else
		draw_sign								(m_oldSectionImage, pos);
	
}
u32	 CLevelGraph::check_position_in_direction_slow	(u32 start_vertex_id, const Fvector2 &start_position, const Fvector2 &finish_position) const
{
	if (!valid_vertex_position(v3d(finish_position)))
		return				(u32(-1));

	u32						cur_vertex_id = start_vertex_id, prev_vertex_id = u32(-1);
	Fbox2					box;
	Fvector2				identity, start, dest, dir;

	identity.x = identity.y	= header().cell_size()*.5f;
	start					= start_position;
	dest					= finish_position;
	dir.sub					(dest,start);
	u32						dest_xz = vertex_position(v3d(dest)).xz();
	Fvector2				temp;
	unpack_xz				(vertex(start_vertex_id),temp.x,temp.y);

	float					cur_sqr = _sqr(temp.x - dest.x) + _sqr(temp.y - dest.y);
	for (;;) {
		const_iterator		I,E;
		begin				(cur_vertex_id,I,E);
		bool				found = false;
		for ( ; I != E; ++I) {
			u32				next_vertex_id = value(cur_vertex_id,I);
			if ((next_vertex_id == prev_vertex_id) || !valid_vertex_id(next_vertex_id))
				continue;
			CVertex			*v = vertex(next_vertex_id);
			unpack_xz		(v,temp.x,temp.y);
			box.min			= box.max = temp;
			box.grow		(identity);
			if (box.pick_exact(start,dir)) {

				if (dest_xz == v->position().xz()) {
					return	(is_accessible(next_vertex_id) ? next_vertex_id : u32(-1));
				}
				Fvector2		temp;
				temp.add		(box.min,box.max);
				temp.mul		(.5f);
				float			dist = _sqr(temp.x - dest.x) + _sqr(temp.y - dest.y);
				if (dist > cur_sqr)
					continue;
				
				if (!is_accessible(next_vertex_id))
					return		(u32(-1));

				cur_sqr			= dist;
				found			= true;
				prev_vertex_id	= cur_vertex_id;
				cur_vertex_id	= next_vertex_id;
				break;
			}
		}
		if (!found) {
			return			(u32(-1));
		}
	}
}
void draw_rect(Fvector2 LTp, Fvector2 RBp, Fvector2 LTt, Fvector2 RBt, u32 clr, Fvector2 const& ts)
{
	UI().AlignPixel			(LTp.x);
	UI().AlignPixel			(LTp.y);
	LTp.add					(pt_offset);
	UI().AlignPixel			(RBp.x);
	UI().AlignPixel			(RBp.y);
	RBp.add					(pt_offset);
	LTt.div					(ts);
	RBt.div					(ts);

	UIRender->PushPoint(LTp.x, LTp.y,	0, clr, LTt.x, LTt.y);
	UIRender->PushPoint(RBp.x, RBp.y,	0, clr, RBt.x, RBt.y);
	UIRender->PushPoint(LTp.x, RBp.y,	0, clr, LTt.x, RBt.y);

	UIRender->PushPoint(LTp.x, LTp.y,	0, clr, LTt.x, LTt.y);
	UIRender->PushPoint(RBp.x, LTp.y,	0, clr, RBt.x, LTt.y);
	UIRender->PushPoint(RBp.x, RBp.y,	0, clr, RBt.x, RBt.y);
}
Beispiel #4
0
Fvector2 CUICustomMap::ConvertRealToLocal  (const Fvector2& src)// meters->pixels (relatively own left-top pos)
{
	Fvector2 res;
	if( !Heading() ){
		return ConvertRealToLocalNoTransform(src);
	}else{
		Fvector2 heading_pivot = GetStaticItem()->GetHeadingPivot();
	
		res = ConvertRealToLocalNoTransform(src);
		res.sub(heading_pivot);
		rotation_(res.x, res.y, GetHeading(), res.x, res.y);
		res.add(heading_pivot);
		return res;
	};
}
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 #6
0
void CUIMpTradeWnd::FillUpSubLevelButtons()
{
	u32 root_cnt						= m_store_hierarchy->CurrentLevel().ChildCount();

	Fvector2							pos;
	pos.set								(40.0f,90.0f);

	for(u32 i=0; i<root_cnt; ++i)
	{
		const CStoreHierarchy::item& it	= m_store_hierarchy->CurrentLevel().ChildAt(i);
		CUITabButtonMP* btn				= it.m_button;
		btn->m_temp_index				= i;
		Register						(btn);
		btn->SetWndPos					(pos);
		pos.add							(btn->GetWndSize().y);
		pos.y							+= 40.0f;
		pos.x							= 40.0f;
		m_shop_wnd->AttachChild			(btn);
	}
}
bool CLevelGraph::neighbour_in_direction	(const Fvector &direction, u32 start_vertex_id) const
{
	u32						cur_vertex_id = start_vertex_id, prev_vertex_id = u32(-1);
	Fbox2					box;
	Fvector2				identity, start, dest, dir;

	identity.x = identity.y	= header().cell_size()*.5f;
	start					= v2d(vertex_position(start_vertex_id));
	dir						= v2d(direction);
	dir.normalize_safe		();
	dest					= dir;
	dest.mul				(header().cell_size()*4.f);
	dest.add				(start);
	Fvector2				temp;
	unpack_xz				(vertex(start_vertex_id),temp.x,temp.y);

	float					cur_sqr = _sqr(temp.x - dest.x) + _sqr(temp.y - dest.y);
	const_iterator			I,E;
	begin					(cur_vertex_id,I,E);
	for ( ; I != E; ++I) {
		u32					next_vertex_id = value(cur_vertex_id,I);
		if ((next_vertex_id == prev_vertex_id) || !is_accessible(next_vertex_id))
			continue;
		unpack_xz			(vertex(next_vertex_id),temp.x,temp.y);
		box.min				= box.max = temp;
		box.grow			(identity);
		if (box.pick_exact(start,dir)) {
			Fvector2		temp;
			temp.add		(box.min,box.max);
			temp.mul		(.5f);
			float			dist = _sqr(temp.x - dest.x) + _sqr(temp.y - dest.y);
			if (dist > cur_sqr)
				continue;
			return			(true);
		}
	}
	return					(false);
}
bool CLevelGraph::create_straight_path(u32 start_vertex_id, const Fvector2 &start_point, const Fvector2 &finish_point, xr_vector<Fvector> &tpaOutputPoints, xr_vector<u32> &tpaOutputNodes, bool bAddFirstPoint, bool bClearPath) const
{
	if (!valid_vertex_position(v3d(finish_point)))
		return				(false);

	u32						cur_vertex_id = start_vertex_id, prev_vertex_id = start_vertex_id;
	Fbox2					box;
	Fvector2				identity, start, dest, dir;

	identity.x = identity.y	= header().cell_size()*.5f;
	start					= start_point;
	dest					= finish_point;
	dir.sub					(dest,start);
	u32						dest_xz = vertex_position(v3d(dest)).xz();
	Fvector2				temp;
	Fvector					pos3d;
	unpack_xz				(vertex(start_vertex_id),temp.x,temp.y);

	if (bClearPath) {
		tpaOutputPoints.clear	();
		tpaOutputNodes.clear	();
	}
	if (bAddFirstPoint) {
		pos3d				= v3d(start_point);
		pos3d.y				= vertex_plane_y(start_vertex_id,start_point.x,start_point.y);
		tpaOutputPoints.push_back(pos3d);
		tpaOutputNodes.push_back(start_vertex_id);
	}

	float					cur_sqr = _sqr(temp.x - dest.x) + _sqr(temp.y - dest.y);
	for (;;) {
		const_iterator		I,E;
		begin				(cur_vertex_id,I,E);
		bool				found = false;
		for ( ; I != E; ++I) {
			u32				next_vertex_id = value(cur_vertex_id,I);
			if ((next_vertex_id == prev_vertex_id) || !valid_vertex_id(next_vertex_id))
				continue;
			CVertex			*v = vertex(next_vertex_id);
			unpack_xz		(v,temp.x,temp.y);
			box.min			= box.max = temp;
			box.grow		(identity);
			if (box.pick_exact(start,dir)) {
				Fvector2		temp;
				temp.add		(box.min,box.max);
				temp.mul		(.5f);
				float			dist = _sqr(temp.x - dest.x) + _sqr(temp.y - dest.y);
				if (dist > cur_sqr)
					continue;

				Fvector2		next1, next2;
#ifdef DEBUG
				next1			= next2 = Fvector2().set(0.f,0.f);
#endif
				Fvector			tIntersectPoint;

				switch (I) {
					case 0 : {
						next1		= box.max;
						next2.set	(box.max.x,box.min.y);
						break;
					}
					case 1 : {
						next1		= box.min;
						next2.set	(box.max.x,box.min.y);
						break;
					}
					case 2 : {
						next1		= box.min;
						next2.set	(box.min.x,box.max.y);
						break;
					}
					case 3 : {
						next1		= box.max;
						next2.set	(box.min.x,box.max.y);
						break;
					}
					default : NODEFAULT;
				}
				VERIFY			(_valid(next1));
				VERIFY			(_valid(next2));
				u32				dwIntersect = intersect(start_point.x,start_point.y,finish_point.x,finish_point.y,next1.x,next1.y,next2.x,next2.y,&tIntersectPoint.x,&tIntersectPoint.z);
				if (!dwIntersect)
					continue;
				tIntersectPoint.y = vertex_plane_y(vertex(cur_vertex_id),tIntersectPoint.x,tIntersectPoint.z);

				tpaOutputPoints.push_back(tIntersectPoint);
				tpaOutputNodes.push_back(cur_vertex_id);

				if (dest_xz == v->position().xz())
					return		(true);
				
				cur_sqr			= dist;
				found			= true;
				prev_vertex_id	= cur_vertex_id;
				cur_vertex_id	= next_vertex_id;
				break;
			}
		}
		if (!found)
			return				(false);
	}
}
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();
}