void C_QUA_Strider::DrawHudElements( )
{
	CHudTexture *pIcon;
	//int iIconX, iIconY;


		// draw crosshairs for vehicle gun
		pIcon = gHUD.GetIcon( "gunhair" );

		if ( pIcon != NULL )
		{
			float x, y;
			Vector screen;

			x = ScreenWidth()/2;
			y = ScreenHeight()/2;

		
			ScreenTransform( m_vecGunCrosshair, screen );
			x += 0.5 * screen[0] * ScreenWidth() + 0.5;
			y -= 0.5 * screen[1] * ScreenHeight() + 0.5;

			x -= pIcon->Width() / 2; 
			y -= pIcon->Height() / 2; 
			bool unable;
			unable=false;
			Color	clr = ( unable ) ? gHUD.m_clrCaution : gHUD.m_clrNormal;
			pIcon->DrawSelf( x, y, clr );
		}

	// Aqui pondremos el crosshair
}
Exemple #2
0
int CHudStatusBar :: Draw( float fTime )
{
 
	this->ReparseStringIfNeeded();

	// Draw the status bar lines
	for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
	{
		int TextHeight, TextWidth;
		GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );

		int Y_START;
		if ( ScreenHeight() >= 480 )
			Y_START = ScreenHeight() - 55;
		else
			Y_START = ScreenHeight() - 45;

		int x = 5;
		int y = Y_START - ( TextHeight * i ); // draw along bottom of screen

		// let user set status ID bar centering
		if ( (i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid") )
		{
			x = max( 0, max(2, (ScreenWidth() - TextWidth)) / 2 );
			y = (ScreenHeight() / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid"));
		}

		if ( m_pflNameColors[i] )
			DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );

		DrawConsoleString( x, y, m_szStatusBar[i] );
	}

	return 1;
}
void ScrollingBackgroundLayer::ResetCloud(Node* cloud) {
	const float cloudHalfWidth = cloud->boundingBox().size.width / 2.0f;
	
	const int xPosition = GameManager::sharedInstance().IsReversed() ? -cloudHalfWidth : (ScreenWidth() + cloudHalfWidth);
	
	const int yMin = (int)ScreenHeight() * 0.33f;
	const int yMax = (int)ScreenHeight();
	const int yRange = yMax - yMin;
	const int yPosition = (random() % yRange) + yMin;
	
	cloud->setPosition({xPosition, yPosition});
	
	const int MaxCloudMoveDuration = GStateIsActive() ? 8 : 40;
	const int MinCloudMoveDuration = GStateIsActive() ? 2 : 20;
	const int moveDuration = (random() % (MaxCloudMoveDuration - MinCloudMoveDuration)) + MinCloudMoveDuration;
	
	const float offscreenXPosition = GameManager::sharedInstance().IsReversed() ? (ScreenWidth() + cloudHalfWidth) : -cloudHalfWidth;
	
	cloud->runAction(CCSequence::createWithTwoActions(CCMoveTo::create(moveDuration, Point(offscreenXPosition, cloud->getPositionY())),
													  CCCallFuncN::create([&](Node* node){
		ResetCloud(node);
	})));
	
	const int newZOrder = MaxCloudMoveDuration - moveDuration;
	cloud->setScale((((MaxCloudMoveDuration - moveDuration) / (float)MaxCloudMoveDuration) * 0.5f) + 0.5f);
	spriteBatchNode_->reorderChild(cloud, newZOrder);
}
Exemple #4
0
void new_synopsis_note()
{
	PrepareActiveContent(0);

	SynWordList* synWordList = new SynWordList[2];
	memset(synWordList, 0, sizeof(SynWordList) * 2);

	synWordList[0].word = strdup("");
	synWordList[0].x1 = 0;
	synWordList[0].y1 = 0;
	synWordList[0].x2 = 0;
	synWordList[0].y2 = 0;
	synWordList[0].pnum = cpage;
	synWordList[0].wnum = 1;

	synWordList[1].word = strdup("");
	synWordList[1].x1 = ScreenWidth();
	synWordList[1].y1 = ScreenHeight() - PanelHeight();
	synWordList[1].x2 = ScreenWidth();
	synWordList[1].y2 = ScreenHeight() - PanelHeight();
	synWordList[1].pnum = cpage;
	synWordList[1].wnum = 2;

	List.Clear();
	List.Add(synWordList, 2, 1);

	delete[] synWordList;

	ibitmap *bm1=NULL, *bm2=NULL;
	bm1 = BitmapFromScreen(0, 0, ScreenWidth(), ScreenHeight()-PanelHeight());
//	bm2 = BitmapFromScreen(0, 0, ScreenWidth(), ScreenHeight()-PanelHeight());
	Note = new SynopsisNote();
	Note->Create((TSynopsisTOC*)&m_TOC, &List, bm1, bm2, false);
//	SendEvent(GetEventHandler(), EVT_SHOW, 0, 0);
}
Exemple #5
0
void FlushMarker(PBSynopsisItem *item)
{
	// Flush marker or comment on page
	if (item != NULL && (item->GetType() == SYNOPSIS_MARKER || item->GetType() == SYNOPSIS_COMMENT))
	{
		int spi, sei, sci, epi, eei, eci;
		PBSynopsisMarker *marker = (PBSynopsisMarker *)item;
		if (marker != NULL)
		{
			unpack_position(marker->GetLongPosition(), &spi, &sei, &sci);
			unpack_position(marker->GetEndLongPosition(), &epi, &eei, &eci);
			int i;
			for (i = 0; i < 2; i++)
			{
				bookview->selectionModel().activate(0, 0);
				bookview->selectionModel().extendTo(ScreenWidth(), ScreenHeight());
				bookview->selectionModel().SetSelection(spi, sei, sci, epi, eei, eci);
				repaint_all(-2);
				PartialUpdateBW(0, 0, ScreenWidth(), ScreenHeight()-PanelHeight());
				bookview->selectionModel().clear();
				repaint_all(-2);
				PartialUpdateBW(0, 0, ScreenWidth(), ScreenHeight()-PanelHeight());
			}
		}
	}
}
void CASW_VGUI_Computer_Container::PerformLayout()
{
	BaseClass::PerformLayout();

	float fScale = ScreenHeight() / 768.0f;			
	int border = 10.0f * fScale;
	int title_border = 40.0f * fScale;
	if (m_bFrameMinimized)
	{
		int w = fScale * 0.3f * 1024.0f;
		vgui::HFont title_font = m_pTitleLabel->GetFont();
		int title_tall = vgui::surface()->GetFontTall(title_font);
		int h = title_tall * 1.2f;

		SetBounds((ScreenWidth() * 0.5f) - (w * 0.5f), (ScreenHeight() * 0.08f), 
									w , h);
	}
	else
	{
		int w = fScale * (0.65f * 1024) + border * 2;
		int h = fScale * (0.65f * 768) + border + title_border;
		SetBounds((ScreenWidth() * 0.5f) - (w * 0.5f), (ScreenHeight() * 0.5f) - (h * 0.5f), 
									w , h);
	}
}
void CASW_VGUI_Message_Log::PerformLayout()
{	
	BaseClass::PerformLayout();

	// sizes uses by baseclass
	int w = GetWide();
	int t = GetTall();
	m_fScale = ScreenWidth() / 1024.0f;
	float panel_y = ScreenHeight() * TEXT_BORDER_Y;
	int button_high = 40 * m_fScale;

	// how much space do we have for message buttons?
	int message_y_space = ( (t - button_high * 1.7f) - (ScreenHeight() * TEXT_BORDER_Y) ) - panel_y;
	int padding = 5 * m_fScale;
	int message_y_per_button = (message_y_space / float(ASW_MAX_LOGGED_MESSAGES));
	int pos_x = ScreenWidth() * TEXT_BORDER_X;

	// position message buttons
	for (int i=0;i<ASW_MAX_LOGGED_MESSAGES;i++)
	{
		if (!m_pMessageButton[i])
			continue;

		m_pMessageButton[i]->SetBounds(pos_x, panel_y, w - (pos_x * 2), message_y_per_button - padding);
		panel_y += message_y_per_button;
	}
}
Exemple #8
0
//-----------------------------------------------------------------------------
// Purpose: Get the x & y positions of a world position in screenspace
//			Returns true if it's onscreen
//-----------------------------------------------------------------------------
bool GetVectorInScreenSpace( Vector pos, int& iX, int& iY, Vector *vecOffset )
{
	Vector screen;

	// Apply the offset, if one was specified
	if ( vecOffset != NULL )
		pos += *vecOffset;

	// Transform to screen space
	int iFacing = ScreenTransform( pos, screen );
	iX =  0.5 * screen[0] * ScreenWidth();
	iY = -0.5 * screen[1] * ScreenHeight();
	iX += 0.5 * ScreenWidth();
	iY += 0.5 * ScreenHeight();

	// Make sure the player's facing it
	if ( iFacing )
	{
		// We're actually facing away from the Target. Stomp the screen position.
		iX = -640;
		iY = -640;
		return false;
	}

	return true;
}
void CASW_VGUI_Queen_Health_Panel::PerformLayout()
{
	int x = ScreenWidth() * 0.25f;
	int y = ScreenHeight() * 0.02f;
	int w = ScreenWidth() * 0.6f;
	int h = ScreenHeight() * 0.04f;

	SetBounds(x, y, w, h);
		
	//PositionAroundQueen();
	UpdateBars();
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *panel - 
//-----------------------------------------------------------------------------
void C_TFBaseHint::SetHintTarget( vgui::Panel *panel )
{
	m_hTarget = panel;

	if ( panel )
	{
		int hintW, hintH;
		
		GetSize( hintW, hintH );

		int x, y, w, h;
		panel->GetBounds( x, y, w, h );

		// Try and position ourselves up and to left of target item?
		x = x - ( hintW - w );
		y = y - ( hintH ) - 40;

		// Don't let it hang off screen
		if ( x < 3 )
		{
			x = 3;
		}
		else if ( x + hintW + 3 >= ScreenWidth() )
		{
			int over = ( x + hintW + 3 - ScreenWidth() );

			x -= over;
		}
		
		if ( y < 3 )
		{
			y = 3;
		}
		else if ( y + hintH >= ScreenHeight() )
		{
			int over = ( y + hintH + 3 - ScreenHeight() );

			y -= over;
		}

		SetDesiredPosition( x, y );
	}
	else
		PositionHintNoTarget( this );

	// Tell hint items that there is a new target
	for ( int i = 0 ; i < GetNumHintItems(); i++ )
	{
		ITFHintItem *item = GetHintItem( i );
		item->SetHintTarget( panel );
	}
}
Exemple #11
0
void CainMailPanel::PerformLayout()
{	
	SetBounds(0, 0, ScreenWidth(), ScreenHeight());
	
	int inset = ScreenWidth() * 0.1f;
	int line_height = ScreenHeight() * 0.035f;
	for (int i=0;i<ASW_CAIN_MAIL_LINES;i++)
	{
		m_MailLines[i]->SetContentAlignment(vgui::Label::a_northwest);
		m_MailLines[i]->SetBounds(inset, ScreenHeight() * 0.1f + line_height * i,
								ScreenWidth() - (inset * 2), line_height);
	}
}
void CASW_VGUI_Info_Message::GetMessagePanelSize(int &w, int &t)
{
	w = ScreenWidth() * 0.5f;
	t = ScreenHeight() * 0.5f;
	if (m_hMessage.Get())
	{
		float f = m_hMessage->m_iWindowSize * 0.1f;
		if (f == 0)
			f = 0.5f;
		f = clamp(f, 0.4f, 0.6f);
		w = ScreenWidth() * f;
		t = ScreenHeight() * f;
	}
}
Exemple #13
0
//-----------------------------------------------------------------------------
// Purpose: 
// Set the scissor
//  the coordinate system for gl is upsidedown (inverted-y) as compared to software, so the
//  specified clipping rect must be flipped
// Input  : x - 
//			y - 
//			width - 
//			height - 
//-----------------------------------------------------------------------------
void EnableScissorTest( int x, int y, int width, int height )
{
	x = clamp( x, 0, ScreenWidth() );
	y = clamp( y, 0, ScreenHeight() );
	width = clamp( width, 0, ScreenWidth() - x );
	height = clamp( height, 0, ScreenHeight() - y );

	scissor_x = x;
	scissor_width = width;
	scissor_y = y;
	scissor_height = height;

	giScissorTest = true;
}
//-----------------------------------------------------------------------------
// Purpose: Draw the weapon's crosshair
//-----------------------------------------------------------------------------
void CWeaponCombatLaserRifle::DrawCrosshair( void )
{
	BaseClass::DrawCrosshair();

	// Draw the targeting zone around the crosshair
	int r, g, b, a;
	gHUD.m_clrYellowish.GetColor( r, g, b, a );

	// Check to see if we are in vgui mode
	C_BaseTFPlayer *pPlayer	= static_cast<C_BaseTFPlayer*>( GetOwner() );
	if ( !pPlayer || pPlayer->IsInVGuiInputMode() )
		return;

	// Draw a crosshair & accuracy hoodad
	int iBarWidth = XRES(10);
	int iBarHeight = YRES(10);
	int iTotalWidth = (iBarWidth * 2) + (40 * m_flInaccuracy) + XRES(10);
	int iTotalHeight = (iBarHeight * 2) + (40 * m_flInaccuracy) + YRES(10);
	
	// Horizontal bars
	int iLeft = (ScreenWidth() - iTotalWidth) / 2;
	int iMidHeight = (ScreenHeight() / 2);

	Color dark( r, g, b, 32 );
	Color light( r, g, b, 160 );

	vgui::surface()->DrawSetColor( dark );

	vgui::surface()->DrawFilledRect( iLeft, iMidHeight-1, iLeft+ iBarWidth, iMidHeight + 2 );
	vgui::surface()->DrawFilledRect( iLeft + iTotalWidth - iBarWidth, iMidHeight-1, iLeft + iTotalWidth, iMidHeight + 2 );

	vgui::surface()->DrawSetColor( light );

	vgui::surface()->DrawFilledRect( iLeft, iMidHeight, iLeft + iBarWidth, iMidHeight + 1 );
	vgui::surface()->DrawFilledRect( iLeft + iTotalWidth - iBarWidth, iMidHeight, iLeft + iTotalWidth, iMidHeight + 1 );
	
	// Vertical bars
	int iTop = (ScreenHeight() - iTotalHeight) / 2;
	int iMidWidth = (ScreenWidth() / 2);

	vgui::surface()->DrawSetColor( dark );
	
	vgui::surface()->DrawFilledRect( iMidWidth-1, iTop, iMidWidth + 2, iTop + iBarHeight );
	vgui::surface()->DrawFilledRect( iMidWidth-1, iTop + iTotalHeight - iBarHeight, iMidWidth + 2, iTop + iTotalHeight );

	vgui::surface()->DrawSetColor( light );

	vgui::surface()->DrawFilledRect( iMidWidth, iTop, iMidWidth + 1, iTop + iBarHeight );
	vgui::surface()->DrawFilledRect( iMidWidth, iTop + iTotalHeight - iBarHeight, iMidWidth + 1, iTop + iTotalHeight );
}
Exemple #15
0
void CGraphics_OpenGL::ClipEnable(int x, int y, int w, int h)
{
    if(x < 0)
        w += x;
    if(y < 0)
        h += y;
    x = clamp(x, 0, ScreenWidth());
    y = clamp(y, 0, ScreenHeight());
    w = clamp(w, 0, ScreenWidth()-x);
    h = clamp(h, 0, ScreenHeight()-y);

	glScissor(x, ScreenHeight()-(y+h), w, h);
	glEnable(GL_SCISSOR_TEST);
}
Exemple #16
0
Vector UTIL_GetMouseAim( C_HL2WarsPlayer *pPlayer, int x, int y )
{
	Vector forward;
	// Remap x and y into -1 to 1 normalized space 
	float xf, yf; 
	xf = ( 2.0f * x / (float)(ScreenWidth()-1) ) - 1.0f; 
	yf = ( 2.0f * y / (float)(ScreenHeight()-1) ) - 1.0f; 

	// Flip y axis 
	yf = -yf; 

	const VMatrix &worldToScreen = engine->WorldToScreenMatrix(); 
	VMatrix screenToWorld; 
	MatrixInverseGeneral( worldToScreen, screenToWorld ); 

	// Create two points at the normalized mouse x, y pos and at the near and far z planes (0 and 1 depth) 
	Vector v1, v2; 
	v1.Init( xf, yf, 0.0f ); 
	v2.Init( xf, yf, 1.0f ); 

	Vector o2; 
	// Transform the two points by the screen to world matrix 
	screenToWorld.V3Mul( v1, pPlayer->Weapon_ShootPosition() ); // ray start origin 
	screenToWorld.V3Mul( v2, o2 ); // ray end origin 
	VectorSubtract( o2, pPlayer->Weapon_ShootPosition(), forward ); 
	forward.NormalizeInPlace(); 
	return forward;
}
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CLoadingDiscPanel::CLoadingDiscPanel( vgui::VPANEL parent ) : BaseClass( NULL, "CLoadingDiscPanel" )
{
	int w, h;
	w = ScreenWidth();
	h = ScreenHeight();

	SetParent( parent );
	SetProportional( true );
	SetScheme( "ClientScheme" );
	SetVisible( false );
	SetCursor( NULL );

	m_pLoadingLabel = vgui::SETUP_PANEL(new vgui::Label( this, "LoadingLabel", "" ));
	m_pLoadingLabel->SetPaintBackgroundEnabled( false );

	m_pProgressBar = vgui::SETUP_PANEL(new vgui::ProgressBar( this, "LoadingProgress" ));

	LoadControlSettings( "resource/LoadingDiscPanel.res" );

	// center the dialog
	int wide, tall;
	GetSize( wide, tall );
	SetPos( ( w - wide ) / 2, ( h - tall ) / 2 );

	m_ScreenSize[ 0 ] = w;
	m_ScreenSize[ 1 ] = h;
}
Exemple #18
0
 void placeWidgets(){
   setSize(0,0,ScreenWidth(),ScreenHeight());
   hs.setSize(10,10,w()-20,20);
   bto.setSize(10,40,100,30);
   bts.setSize(10,80,100,30);
   btd.setSize(10,120,100,30);
 }
Exemple #19
0
// get bounding rectangle of window
void Zoomer::GetWindowFrameRect(int& x, int& y, int& w, int& h)
{
    x = (ScreenWidth() - djvumode.width) / 2;
    y = (ScreenHeight() - djvumode.height) / 2;
    w = djvumode.width + 2 * m_IconWidth / 3;
    h = djvumode.height + 1.5 * menu_n_font->height + 2 * m_IconHeight / 3;
}
// camera view takes up our full space
void CASW_VGUI_Stylin_Cam::PerformLayout()
{
	BaseClass::PerformLayout();

	int x = ScreenWidth() * 0.01f;
	int y = ScreenHeight() * 0.40f;
	int w = GetStylinCamSize();
	int h = w;

	SetBounds( x, y, w, h );
	if ( ShouldShowStylinCam() )
	{
		m_pCameraImage->SetBounds( 0, 0, w, h );		
	}
	else
	{
		m_pCameraImage->SetBounds( 0, 0, 0, 0 );
	}

	if ( ShouldShowCommanderFace() )
	{
		m_pCommanderImage->SetBounds( 0, 0, YRES( 82 ), YRES( 110 ) );
		m_pCommanderFlash->SetBounds( 0, 0, YRES( 82 ), YRES( 110 ) );
	}
	else
	{
		m_pCommanderImage->SetBounds( 0, YRES( 55 ), YRES( 82 ), 0 );
		m_pCommanderFlash->SetBounds( 0, YRES( 55 ), YRES( 82 ), 0 );
	}	
}
CampaignFrame::CampaignFrame(Panel *parent, const char *panelName, bool showTaskbarIcon) :
	vgui::Frame(parent, panelName, showTaskbarIcon)
{
	vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SwarmSchemeNew.res", "SwarmSchemeNew");
	SetScheme(scheme);
	SetSize( ScreenWidth() + 1, ScreenHeight() + 1 );
	SetTitle("Campaign", true );
	SetPos(0,0);
	SetMoveable(false);
	SetSizeable(false);
	SetMenuButtonVisible(false);
	SetMaximizeButtonVisible(false);
	SetMinimizeToSysTrayButtonVisible(false);
	SetCloseButtonVisible(false);
	SetTitleBarVisible(false);
	SetAlpha(0.3f);
	SetPaintBackgroundEnabled(false);

	m_pCampaignPanel = new CampaignPanel( this, "CampaignPanel" );

	RequestFocus();
	SetVisible(true);
	SetEnabled(true);
	SetKeyBoardInputEnabled(false);

	if (GetClientModeASW() && GetClientModeASW()->m_bSpectator)
	{
		engine->ServerCmd("cl_spectating");
	}
}
void CASW_VGUI_Computer_Menu::PerformLayout()
{
	m_fScale = ScreenHeight() / 768.0f;

	int w = GetParent()->GetWide();
	int h = GetParent()->GetTall();
	SetWide(w);
	SetTall(h);
	SetPos(0, 0);

	if (m_hCurrentPage.Get())
	{
		m_hCurrentPage->SetPos(0,0);
		m_hCurrentPage->InvalidateLayout(true);
	}

	m_pAccessDeniedLabel->SetSize(w, h * 0.3);
	m_pAccessDeniedLabel->SetPos(0, h * 0.25f);
	m_pInsufficientRightsLabel->SetContentAlignment(vgui::Label::a_northwest);
	m_pInsufficientRightsLabel->InvalidateLayout(true);
	int ix, iy;
	m_pInsufficientRightsLabel->GetTextImage()->GetContentSize(ix, iy);
	m_pInsufficientRightsLabel->SetSize(ix, iy);	
	m_pInsufficientRightsLabel->SetPos(w * 0.5f - ix * 0.455f, h * 0.56f);		

	LayoutMenuOptions();
}
Exemple #23
0
void UIManager::SetMouseVisibility(bool inState)
{
    // To change whether the mouse is visible, just change this variable
    g_iVisibleMouse = inState;

    // Update cursor
    if(g_iVisibleMouse)
    {
        //ClientCmd("say Entering mouse mode.");
        //App::getInstance()->setCursorOveride(App::getInstance()->getScheme()->getCursor(Scheme::SchemeCursor::scu_arrow));
		// Remove above line and put this line back in for sprite cursors
        App::getInstance()->setCursorOveride(this->mBlankCursor);
    }
    else
    {
        //ClientCmd("say Exiting mouse mode.");
        // Move mouse to center of screen so mouse look isn't changed

        // Only do this when in full screen
        App::getInstance()->setCursorPos(ScreenWidth()/2, ScreenHeight()/2);

        // Hide cursor again
        App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::SchemeCursor::scu_none) );
    }

    //App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::SchemeCursor::scu_none) );

}
 // Constuctor: Initializes the Panel
CVRPanel::CVRPanel(vgui::VPANEL parent)
: BaseClass(NULL, "VRPanel")
{

	int w, h;
	w = ScreenWidth();
	h = ScreenHeight();

	SetParent( parent );
 
	SetKeyBoardInputEnabled( true );
	SetMouseInputEnabled( true );
 
	SetProportional( false );
	SetVisible( true );
	
	SetSize(255, 255);
	SetPos(398, 240);
	
	vgui::ivgui()->AddTickSignal( GetVPanel(), 100 );
	
	// Label
	
	// Image
	m_pImage = new vgui::ImagePanel(this, "imgCalibrate");
	m_pImage->SetImage("hydra_calibrate");
	m_pImage->SetPos(0, 0);
	m_pImage->SetSize(255, 255);
	m_pImage->SetShouldScaleImage(true);
	m_pImage->SetScaleAmount(.75);
	

	DevMsg("VRPanel has been constructed\n");
}
//--------------------------------------------------------------------------
// Purpose:
// Given a field of view and mouse/screen positions as well as the current
// render origin and angles, returns a unit vector through the mouse position
// that can be used to trace into the world under the mouse click pixel.
// Input : 
// mousex -
// mousey -
// fov -
// vecRenderOrigin - 
// vecRenderAngles -
// Output :
// vecPickingRay
//--------------------------------------------------------------------------
void ScreenToWorld( int mousex, int mousey, float fov,
					const Vector& vecRenderOrigin,
					const QAngle& vecRenderAngles,
					Vector& vecPickingRay )
{
	float dx, dy;
	float c_x, c_y;
	float dist;
	Vector vpn, vup, vright;

	float scaled_fov = ScaleFOVByWidthRatio( fov, engine->GetScreenAspectRatio() * 0.75f );

	c_x = ScreenWidth() / 2;
	c_y = ScreenHeight() / 2;

	dx = (float)mousex - c_x;
	// Invert Y
	dy = c_y - (float)mousey;

	// Convert view plane distance
	float dist_denom = tan( M_PI * scaled_fov / 360.0f );
	dist = c_x / dist_denom;

	// Decompose view angles
	AngleVectors( vecRenderAngles, &vpn, &vright, &vup );

	// Offset forward by view plane distance, and then by pixel offsets
	vecPickingRay = vpn * dist + vright * ( dx ) + vup * ( dy );

	// Convert to unit vector
	VectorNormalize( vecPickingRay );
} 
Exemple #26
0
/**********************************************************************************************************************
*   Scene::Trace
*
*   Trace scene
**********************************************************************************************************************/
bool Scene::Trace()
{
    Ray* pRay = NULL;

    const unsigned int level = -1;

    Vector3D scanlineStart = m_pSceneCamera->PixelCenter();

    for (unsigned int i = 0; i < ScreenWidth(); ++i)
	{
        Vector3D pixelCenter = scanlineStart;

        for (unsigned int j = 0; j < ScreenHeight(); ++j)
        {
            pRay = new Ray(m_pSceneCamera->CameraOrigin(), pixelCenter - m_pSceneCamera->CameraOrigin());

            if (pRay)
            {
                pRay->Trace(this, level);
                pRay->Color();
            }
            
            delete pRay;
            
            pixelCenter = pixelCenter + m_pSceneCamera->PixelIncrement();
        }

        scanlineStart = scanlineStart + m_pSceneCamera->ScanlineIncrement();
    }

    return true;
};
	void open_zoomer()
	{
		if (!bm_touchzoom) bm_touchzoom = GetResource("touchzoom", (ibitmap*) &touchzoom);

		th = header_font->height + 4;
		dw = bm_touchzoom->width + 80;
		dh = th + bm_touchzoom->height + menu_n_font->height + 40;
		dx = (ScreenWidth() - dw) / 2;
		dy = (ScreenHeight() - dh) / 2;

		isaves = BitmapFromScreen(dx, dy, dw + 4, dh + 4);
		DimArea(dx + 4, dy + 4, dw, dh, BLACK);

		new_scale = scale;
		new_rscale = rscale;
		new_reflow = reflow_mode;

		prevhandler = iv_seteventhandler(newzoomer_handler);
		if (ivstate.needupdate)
		{
			draw_new_zoomer(0);
			SoftUpdate();
		}
		else
		{
			draw_new_zoomer(1);
		}

	}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CTFFreezePanelCallout *CTFFreezePanel::TestAndAddCallout( Vector &origin, Vector &vMins, Vector &vMaxs, CUtlVector<Vector> *vecCalloutsTL, 
			CUtlVector<Vector> *vecCalloutsBR, Vector &vecFreezeTL, Vector &vecFreezeBR, Vector &vecStatTL, Vector &vecStatBR, int *iX, int *iY )
{
	// This is the offset from the topleft of the callout to the arrow tip
	const int iXOffset = XRES(25);
	const int iYOffset = YRES(50);

	//if ( engine->IsBoxInViewCluster( vMins + origin, vMaxs + origin) && !engine->CullBox( vMins + origin, vMaxs + origin ) )
	{
		if ( GetVectorInScreenSpace( origin, *iX, *iY ) )
		{
			*iX -= iXOffset;
			*iY -= iYOffset;
			int iRight = *iX + CALLOUT_WIDE;
			int iBottom = *iY + CALLOUT_TALL;
			if ( *iX > 0 && *iY > 0 && (iRight < ScreenWidth()) && (iBottom < (ScreenHeight()-YRES(40))) )
			{
				// Make sure it wouldn't be over the top of the freezepanel or statpanel
				Vector vecCalloutTL( *iX, *iY, 0 );
				Vector vecCalloutBR( iRight, iBottom, 1 );
				if ( !QuickBoxIntersectTest( vecCalloutTL, vecCalloutBR, vecFreezeTL, vecFreezeBR ) &&
					 !QuickBoxIntersectTest( vecCalloutTL, vecCalloutBR, vecStatTL, vecStatBR ) )
				{
					// Make sure it doesn't intersect any other callouts
					bool bClear = true;
					for ( int iCall = 0; iCall < vecCalloutsTL->Count(); iCall++ )
					{
						if ( QuickBoxIntersectTest( vecCalloutTL, vecCalloutBR, vecCalloutsTL->Element(iCall), vecCalloutsBR->Element(iCall) ) )
						{
							bClear = false;
							break;
						}
					}

					if ( bClear )
					{
						// Verify that we have LOS to the gib
						trace_t	tr;
						UTIL_TraceLine( origin, MainViewOrigin(), MASK_OPAQUE, NULL, COLLISION_GROUP_NONE, &tr );
						bClear = ( tr.fraction >= 1.0f );
					}

					if ( bClear )
					{
						CTFFreezePanelCallout *pCallout = new CTFFreezePanelCallout( g_pClientMode->GetViewport(), "FreezePanelCallout" );
						m_pCalloutPanels.AddToTail( vgui::SETUP_PANEL(pCallout) );
						vecCalloutsTL->AddToTail( vecCalloutTL );
						vecCalloutsBR->AddToTail( vecCalloutBR );
						pCallout->SetVisible( true );
						pCallout->SetBounds( *iX, *iY, CALLOUT_WIDE, CALLOUT_TALL );
						return pCallout;
					}
				}
			}
		}
	}

	return NULL;
}
Exemple #29
0
////////////////////////
// PopupMenu -> Panel //
////////////////////////
void UIPopupMenu::AllocateComponent(const TRDescription& inDesc)
{
    float theXPos, theYPos;
    int theWidth, theHeight;
    UIGetPosition(inDesc, theXPos, theYPos, theWidth, theHeight);

    this->mUIPopupMenu = new PopupMenu(theXPos*ScreenWidth(), theYPos*ScreenHeight(), theWidth, theHeight);
}
void PlayerListContainerFrame::PerformLayout()
{
	BaseClass::PerformLayout();

	//SetPos( ScreenWidth() * 0.15f, ScreenHeight() * 0.1f);
	//SetSize( ScreenWidth() * 0.7f, ScreenHeight() * 0.8f );
	SetBounds( 0, 0, ScreenWidth(), ScreenHeight() );
}