Beispiel #1
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 #2
0
void CUICellItem::Update()
{
	if (m_pParentList)
		EnableHeading(m_pParentList->GetVerticalPlacement());

	if(Heading())
	{
		SetHeading			( 90.0f * (PI/180.0f) );
		SetHeadingPivot		(Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true);
	}else
		ResetHeadingPivot	();

	inherited::Update();
	
	if ( CursorOverWindow() )
	{
		Frect clientArea;
		m_pParentList->GetClientArea(clientArea);
		Fvector2 cp			= GetUICursor()->GetCursorPosition();
		if(clientArea.in(cp))
			GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_FOCUSED_UPDATE, NULL);
	}
	
	m_b_already_drawn=false;
 
}
Beispiel #3
0
void CUIWindow::Update()
{
	if (GetUICursor()->IsVisible())
	{
		bool cursor_on_window;

		Fvector2			temp = GetUICursor()->GetCursorPosition();
		Frect				r;
		GetAbsoluteRect		(r);
		cursor_on_window	= !!r.in(temp);
		// RECEIVE and LOST focus
		if(m_bCursorOverWindow != cursor_on_window)
		{
			if(cursor_on_window)
				OnFocusReceive();			
			else
				OnFocusLost();			
		}
	}
	
	for(WINDOW_LIST_it it = m_ChildWndList.begin(); m_ChildWndList.end()!=it; ++it){
		if(!(*it)->IsShown()) continue;
			(*it)->Update();
	}
}
Beispiel #4
0
bool CUIMMShniaga::OnMouse(float x, float y, EUIMessages mouse_action){
	
	Fvector2 pos = UI()->GetUICursor()->GetCursorPosition();
    Frect r;
	m_magnifier->GetAbsoluteRect(r);
	if (WINDOW_LBUTTON_DOWN == mouse_action && r.in(pos.x, pos.y))
	{
		OnBtnClick();
	}

	return CUIWindow::OnMouse(x,y,mouse_action);
}
Beispiel #5
0
void CUIArtefactDetectorElite::Draw()
{
	Fmatrix						LM;
	GetUILocatorMatrix			(LM);

	IUIRender::ePointType bk	= UI()->m_currentPointType;

	UI()->m_currentPointType	= IUIRender::pttLIT;

	UIRender->CacheSetXformWorld(LM);
	UIRender->CacheSetCullMode	(IUIRender::cmNONE);

	CUIWindow::Draw				();

	Frect r						= m_wrk_area->GetWndRect();
	Fvector2					rp; 
	m_wrk_area->GetAbsolutePos	(rp);

	Fmatrix						M, Mc;
	float h,p;
	Device.vCameraDirection.getHP(h,p);
	Mc.setHPB					(h,0,0);
	Mc.c.set					(Device.vCameraPosition);
	M.invert					(Mc);

	xr_vector<Fvector>::const_iterator it	 = m_af_to_draw.begin();
	xr_vector<Fvector>::const_iterator it_e  = m_af_to_draw.end();
	for(;it!=it_e;++it)
	{
		Fvector					p = (*it);
		Fvector					pt3d;
		M.transform_tiny		(pt3d,p);
//		float kx				= m_wrk_area->GetWndSize().x / m_parent->m_fAfDetectRadius;
		float kz				= m_wrk_area->GetWndSize().y / m_parent->m_fAfDetectRadius;
		pt3d.x					*= kz;
		pt3d.z					*= kz;

		pt3d.x					+= m_wrk_area->GetWndSize().x/2.0f;	
		pt3d.z					-= m_wrk_area->GetWndSize().y;

		Fvector2				pos;
		pos.set					(pt3d.x, -pt3d.z);
		pos.sub					(rp);
		if( r.in(pos) )
		{
			m_af_sign->SetWndPos	(pos);
			m_af_sign->Draw			();
		}
	}

	UI()->m_currentPointType		= bk;
}
Beispiel #6
0
bool CUIWindow::HasChildMouseHandler(){
	WINDOW_LIST::reverse_iterator it = m_ChildWndList.rbegin();

	for( ; it!=m_ChildWndList.rend(); ++it)
	{
		if ((*it)->m_bClickable)
		{
			Frect wndRect = (*it)->GetWndRect();
			if (wndRect.in(cursor_pos) )
				return true;
		}
	}

	return false;
}
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 #8
0
// try to positioning clipRect center to vNewPoint
void CUICustomMap::SetActivePoint(const Fvector &vNewPoint)
{
	Fvector2 pos;
	pos.set(vNewPoint.x,vNewPoint.z);
	Frect bound = BoundRect();
	if( FALSE==bound.in(pos) )return;

	Fvector2	pos_on_map		= ConvertRealToLocalNoTransform(pos);
	Frect		map_abs_rect;
	GetAbsoluteRect(map_abs_rect);
	Fvector2	pos_abs;

	pos_abs.set(map_abs_rect.lt);
	pos_abs.add(pos_on_map);

	Frect		clip_abs_rect	= GetClipperRect();
	Fvector2	clip_center;
	clip_abs_rect.getcenter(clip_center);
	clip_center.sub(pos_abs);
	MoveWndDelta				(clip_center);
	SetHeadingPivot				(pos_on_map, Fvector2().set(0,0), false); 
}
Beispiel #9
0
void CUICellItem::Update()
{
	EnableHeading(m_pParentList->GetVerticalPlacement());
	if(Heading())
	{
		SetHeading			( 90.0f * (PI/180.0f) );
		SetHeadingPivot		(Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true);
	}else
		ResetHeadingPivot	();

	inherited::Update();
	
	if ( CursorOverWindow() )
	{
		Frect clientArea;
		m_pParentList->GetClientArea(clientArea);
		Fvector2 cp			= GetUICursor().GetCursorPosition();
		if(clientArea.in(cp))
			GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_FOCUSED_UPDATE, NULL);
	}
	
	PIItem item = (PIItem)m_pData;
	if ( item )
	{
		m_has_upgrade = item->has_any_upgrades();

//		Fvector2 size      = GetWndSize();
//		Fvector2 up_size = m_upgrade->GetWndSize();
//		pos.x = size.x - up_size.x - 4.0f;
		Fvector2 pos;
		pos.set( m_upgrade_pos );
		if ( ChildsCount() )
		{
			pos.x += m_text->GetWndSize().x + 2.0f;
		}
		m_upgrade->SetWndPos( pos );
	}
	m_upgrade->Show( m_has_upgrade );
}
Beispiel #10
0
CUIWindow* CUIWindow::GetChildMouseHandler(){
	CUIWindow* pWndResult;
	WINDOW_LIST::reverse_iterator it = m_ChildWndList.rbegin();

	for(; it!=m_ChildWndList.rend(); ++it)
	{
		Frect wndRect = (*it)->GetWndRect();
		// very strange code.... i can't understand difference between
		// first and second condition. I Got It from OnMouse() method;
		if (wndRect.in(cursor_pos) )
		{
			if((*it)->IsEnabled())
			{
				return pWndResult = (*it)->GetChildMouseHandler();				
			}
		}
		else if ((*it)->IsEnabled() && (*it)->CursorOverWindow())
		{
			return pWndResult = (*it)->GetChildMouseHandler();
		}
	}

    return this;
}
Beispiel #11
0
bool CUIWindow::OnMouse(float x, float y, EUIMessages mouse_action)
{	
	Frect	wndRect = GetWndRect();

	cursor_pos.x = x;
	cursor_pos.y = y;


	if( WINDOW_LBUTTON_DOWN == mouse_action )
	{
		static u32 _last_db_click_frame		= 0;
		u32 dwCurTime						= Device.dwTimeContinual;

		if( (_last_db_click_frame!=Device.dwFrame) && (dwCurTime-m_dwLastClickTime < DOUBLE_CLICK_TIME) )
		{
            mouse_action			= WINDOW_LBUTTON_DB_CLICK;
			_last_db_click_frame	= Device.dwFrame;
		}

		m_dwLastClickTime = dwCurTime;
	}

	if(GetParent()== NULL)
	{
		if(!wndRect.in(cursor_pos))
            return false;
		//получить координаты относительно окна
		cursor_pos.x -= wndRect.left;
		cursor_pos.y -= wndRect.top;
	}


	//если есть дочернее окно,захватившее мышь, то
	//сообщение направляем ему сразу
	if(m_pMouseCapturer)
	{
		m_pMouseCapturer->OnMouse(cursor_pos.x - m_pMouseCapturer->GetWndRect().left, 
								  cursor_pos.y - m_pMouseCapturer->GetWndRect().top, 
								  mouse_action);
		return true;
	}

	// handle any action
	switch (mouse_action){
		case WINDOW_MOUSE_MOVE:
			OnMouseMove();							break;
		case WINDOW_MOUSE_WHEEL_DOWN:
			OnMouseScroll(WINDOW_MOUSE_WHEEL_DOWN); break;
		case WINDOW_MOUSE_WHEEL_UP:
			OnMouseScroll(WINDOW_MOUSE_WHEEL_UP);	break;
		case WINDOW_LBUTTON_DOWN:
			if(OnMouseDown(MOUSE_1))				return true;	break;
		case WINDOW_RBUTTON_DOWN:
			if(OnMouseDown(MOUSE_2))				return true;	break;
		case WINDOW_CBUTTON_DOWN:
			if(OnMouseDown(MOUSE_3))				return true;	break;
		case WINDOW_LBUTTON_DB_CLICK:
			if (OnDbClick())						return true;	break;
		default:
            break;
	}

	//Проверка на попадание мыши в окно,
	//происходит в обратном порядке, чем рисование окон
	//(последние в списке имеют высший приоритет)
	WINDOW_LIST::reverse_iterator it = m_ChildWndList.rbegin();

	for(; it!=m_ChildWndList.rend(); ++it)
	{
		CUIWindow* w	= (*it);
		Frect wndRect	= w->GetWndRect();
		if (wndRect.in(cursor_pos) )
		{
			if(w->IsEnabled())
			{
				if( w->OnMouse(cursor_pos.x -w->GetWndRect().left, 
							   cursor_pos.y -w->GetWndRect().top, mouse_action))return true;
			}
		}
		else if (w->IsEnabled() && w->CursorOverWindow())
		{
			if( w->OnMouse(cursor_pos.x -w->GetWndRect().left, 
						   cursor_pos.y -w->GetWndRect().top, mouse_action))return true;
		}
	}


	return false;
}