コード例 #1
0
void ClientModeTFBase::Init()
{
	BaseClass::Init();
	C_BaseTFCombatWeapon::CreateCrosshairPanels();

	// FIXME: For playtests, turn off detail props. They're causing perf problems
	r_DrawDetailProps.SetValue("0");

	// Turn lighting into a mode where we use better computation for the ambient
	// cube on static props, and a cheap one for dynamic entities.
 	r_radiosity.SetValue("3");

	if ( !m_pMinimap )
	{
		m_pMinimap = ( CMinimapPanel * )GET_HUDELEMENT( CMinimapPanel );
	}

	// Load up the object control panel scheme
	g_hVGuiObjectScheme = vgui::scheme()->LoadSchemeFromFile( "resource/ObjectControlPanelScheme.res", "TFBase" );
	if (!g_hVGuiObjectScheme)
	{
		Warning( "Couldn't load control panel scheme!\n" );
	}

	// Load the objects.txt file.
	LoadObjectInfos( filesystem );
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudControlPointIcons::UpdateProgressBarFor( int iIndex )
{
	// If they tell us to update all progress bars, update only the one we're standing on
	if ( iIndex == -1 )
	{
		iIndex = m_iCurrentCP;
	}

	// Ignore requests to display progress bars for points we're not standing on
	if ( ( m_iCurrentCP != iIndex ) )
		return;

	// This can happen at level load
	CTFHudObjectiveStatus *pStatus = GET_HUDELEMENT( CTFHudObjectiveStatus );
	if ( pStatus && pStatus->GetControlPointProgressBar() )
	{
		CControlPointProgressBar *pProgressBar = pStatus->GetControlPointProgressBar();
		if ( !IsVisible() || iIndex < 0 || iIndex >= ObjectiveResource()->GetNumControlPoints() )
		{
			pProgressBar->SetupForPoint( NULL );
		}
		else
		{
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				if ( m_Icons[i]->GetCapIndex() == iIndex )
				{
					pProgressBar->SetupForPoint( m_Icons[i] );
					break;
				}
			}
		}
	}
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: Create the icons we need to display the state of this map's control points
//-----------------------------------------------------------------------------
void CHudControlPointIcons::InitIcons( void )
{
	ShutdownIcons();

	CTFHudObjectiveStatus *pStatus = GET_HUDELEMENT( CTFHudObjectiveStatus );
	if ( pStatus )
	{
		CControlPointProgressBar *pProgressBar = pStatus->GetControlPointProgressBar();

		if ( pProgressBar )
		{
			m_iCurrentCP = -1;
			pProgressBar->SetupForPoint( NULL );
		}
	}

	// Create an icon for each visible control point in this miniround
	int iPoints = ObjectiveResource()->GetNumControlPoints();
	for ( int i = 0; i < iPoints; i++ )
	{
		if ( ObjectiveResource()->IsInMiniRound(i) && ObjectiveResource()->IsCPVisible(i) )
		{
			CControlPointIcon *pIcon = new CControlPointIcon( this, VarArgs( "ControlPointIcon%d", i ), i );
			m_Icons.AddToTail( vgui::SETUP_PANEL(pIcon) );
		}
	}

	InvalidateLayout();
}
コード例 #4
0
//-----------------------------------------------------------------------------
// Purpose: Engine received crosshair offset ( autoaim )
// Input  : angle - 
//-----------------------------------------------------------------------------
void CHLClient::SetCrosshairAngle( const QAngle& angle )
{
	CHudCrosshair *crosshair = (CHudCrosshair *)GET_HUDELEMENT( CHudCrosshair );
	if ( crosshair )
	{
		crosshair->SetCrosshairAngle( angle );
	}
}
コード例 #5
0
void __MsgFunc_ASWNewHoldoutWave( bf_read &msg )
{
	int nWave = msg.ReadByte();
	float flDuration = msg.ReadFloat();

	CASW_Hud_Holdout *pHoldoutHud = GET_HUDELEMENT( CASW_Hud_Holdout );
	pHoldoutHud->AnnounceNewWave( nWave, flDuration );
}
コード例 #6
0
void __MsgFunc_ASWShowHoldoutWaveEnd( bf_read &msg )
{
	int nWave = msg.ReadByte();
	float flDuration = msg.ReadFloat();

	CASW_Hud_Holdout *pHoldoutHud = GET_HUDELEMENT( CASW_Hud_Holdout );
	pHoldoutHud->ShowWaveScores( nWave, flDuration );
}
コード例 #7
0
void ClientModeDODNormal::RadioMessage( const char *pszSoundName, const char *pszSubtitle, const char *pszSender /* = NULL */, int iSenderIndex /* = 0 */ )
{
	C_DODPlayer *pLocalPlayer = C_DODPlayer::GetLocalDODPlayer();
	if ( !pLocalPlayer )
	{
		return;
	}

	int color = ( pLocalPlayer->GetTeamNumber() == TEAM_ALLIES ) ? DOD_COLOR_ALLIES : DOD_COLOR_AXIS;

	// stop the last played radio message
	if ( Q_strlen( m_szLastRadioSound ) > 0 )
	{
		C_DODPlayer *pLocalPlayer = C_DODPlayer::GetLocalDODPlayer();
		if ( pLocalPlayer )
		{
			pLocalPlayer->StopSound( m_szLastRadioSound );
		}
	}

	Q_strncpy( m_szLastRadioSound, pszSoundName, sizeof(m_szLastRadioSound) );

	// Play the radio alert
	char szCmd[128];
	Q_snprintf( szCmd, sizeof(szCmd), "playgamesound %s", pszSoundName );

	engine->ClientCmd( szCmd );

	// Print a message to chat
	wchar_t wszPrint[128];
	char szPrint[128];

	g_pVGuiLocalize->ConstructString( wszPrint, sizeof(wszPrint), g_pVGuiLocalize->Find(pszSubtitle), 0 );
	g_pVGuiLocalize->ConvertUnicodeToANSI( wszPrint, szPrint, sizeof(szPrint) );

	CBaseHudChat *hudChat = (CBaseHudChat *)GET_HUDELEMENT( CHudChat );

	if ( !hudChat )
		return;
	
	wchar_t *pwLoc = g_pVGuiLocalize->Find( "#dod_radio_prefix" );
	char szPrefix[16];
	g_pVGuiLocalize->ConvertUnicodeToANSI( pwLoc, szPrefix, sizeof(szPrefix) );

	pwLoc = g_pVGuiLocalize->Find( pszSubtitle );
	char szSuffix[512];
	g_pVGuiLocalize->ConvertUnicodeToANSI( pwLoc, szSuffix, sizeof(szSuffix) );

	if ( pszSender )
	{
		hudChat->ChatPrintf( iSenderIndex, CHAT_FILTER_NONE, "%c%s %s %c: %s", COLOR_PLAYERNAME, szPrefix, g_PR->GetPlayerName( iSenderIndex ), COLOR_NORMAL, szSuffix );
	}
	else
	{
		hudChat->Printf( CHAT_FILTER_NONE, "%c%s %c: %s", color, szPrefix, COLOR_NORMAL, szSuffix );
	}
}
コード例 #8
0
ChatEchoPanel::~ChatEchoPanel()
{
	// give it back
	CHudChat *pHUDChat = dynamic_cast<CHudChat*>(GET_HUDELEMENT( CHudChat ));
	if (pHUDChat)
	{
		//pHUDChat->ReturnChat(this);
	}
}
コード例 #9
0
//-----------------------------------------------------------------------------
// Purpose: Playback sound file that contains phonemes
// Input  : *actor - 
//			*parameters - 
//-----------------------------------------------------------------------------
void C_SceneEntity::DispatchStartSpeak( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event, soundlevel_t iSoundlevel )
{
	// Emit sound
	if ( IsClientOnly() && actor )
	{
		CSingleUserRecipientFilter filter( C_BasePlayer::GetLocalPlayer() );

		float time_in_past = m_flCurrentTime - event->GetStartTime() ;
		float soundtime = gpGlobals->curtime - time_in_past;

		EmitSound_t es;
		es.m_nChannel = CHAN_VOICE;
		es.m_flVolume = 1;
		es.m_SoundLevel = iSoundlevel;
		es.m_flSoundTime = soundtime;

		// No CC since we do it manually
		// FIXME:  This will  change
		es.m_bEmitCloseCaption = false;
		es.m_pSoundName = event->GetParameters();

		EmitSound( filter, actor->entindex(), es );
		actor->AddSceneEvent( scene, event, NULL, IsClientOnly() );

		// Close captioning only on master token no matter what...
		if ( event->GetCloseCaptionType() == CChoreoEvent::CC_MASTER )
		{
			char tok[ CChoreoEvent::MAX_CCTOKEN_STRING ];
			bool validtoken = event->GetPlaybackCloseCaptionToken( tok, sizeof( tok ) );
			if ( validtoken )
			{
				CRC32_t tokenCRC;
				CRC32_Init( &tokenCRC );

				char lowercase[ 256 ];
				Q_strncpy( lowercase, tok, sizeof( lowercase ) );
				Q_strlower( lowercase );

				CRC32_ProcessBuffer( &tokenCRC, lowercase, Q_strlen( lowercase ) );
				CRC32_Final( &tokenCRC );

				float endtime = event->GetLastSlaveEndTime();
				float durationShort = event->GetDuration();
				float durationLong = endtime - event->GetStartTime();
				float duration = MAX( durationShort, durationLong );

				CHudCloseCaption *hudCloseCaption = GET_HUDELEMENT( CHudCloseCaption );
				if ( hudCloseCaption )
				{
					hudCloseCaption->ProcessCaption( lowercase, duration );
				}
			}

		}
	}
}
コード例 #10
0
//-----------------------------------------------------------------------------
// Purpose: called when a weapon has been picked up
//-----------------------------------------------------------------------------
void CBaseHudWeaponSelection::OnWeaponPickup( C_BaseCombatWeapon *pWeapon )
{
	// add to pickup history
	CHudHistoryResource *pHudHR = GET_HUDELEMENT( CHudHistoryResource );
	
	if ( pHudHR )
	{
		pHudHR->AddToHistory( pWeapon );
	}
}
コード例 #11
0
//-----------------------------------------------------------------------------
// Purpose: returns true if the CHudMenu handles the slot command
//-----------------------------------------------------------------------------
bool CBaseHudWeaponSelection::HandleHudMenuInput( int iSlot )
{
	CHudMenu *pHudMenu = GET_HUDELEMENT( CHudMenu );
	if ( !pHudMenu || !pHudMenu->IsMenuOpen() )
		return false;

	pHudMenu->SelectMenuItem( iSlot );

	return true;
}
コード例 #12
0
void ClientModeTFBase::Init()
{
	BaseClass::Init();
	C_BaseTFCombatWeapon::CreateCrosshairPanels();

	if ( !m_pMinimap )
		m_pMinimap = GET_HUDELEMENT( CMinimapPanel );
	if (!m_pCommanderStatus)
		m_pCommanderStatus = GET_HUDELEMENT(CCommanderStatusPanel);

	// Load up the object control panel scheme
	g_hVGuiObjectScheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), "resource/ObjectControlPanelScheme.res", "TFBase" );
	if (!g_hVGuiObjectScheme)
	{
		Warning( "Couldn't load control panel scheme!\n" );
	}

	// Load the objects.txt file.
	LoadObjectInfos( ::filesystem );
}
コード例 #13
0
void CHudChat::Init( void )
{
	BaseClass::Init();

	SetZPos( 2 );

	m_pHudGameplay = GET_HUDELEMENT( CHudGameplay );

	HOOK_HUD_MESSAGE( CHudChat, SayText );
	HOOK_HUD_MESSAGE( CHudChat, SayText2 );
	HOOK_HUD_MESSAGE( CHudChat, TextMsg );
}
コード例 #14
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientModeMOMNormal::Init()
{
    BaseClass::Init();

    m_pHudMenuStatic = static_cast<CHudMenuStatic*>(GET_HUDELEMENT(CHudMenuStatic));

    // Load up the combine control panel scheme
    g_hVGuiCombineScheme = vgui::scheme()->LoadSchemeFromFileEx(enginevgui->GetPanel(PANEL_CLIENTDLL), IsXbox() ? "resource/ClientScheme.res" : "resource/CombinePanelScheme.res", "CombineScheme");
    if (!g_hVGuiCombineScheme)
    {
        Warning("Couldn't load combine panel scheme!\n");
    }
}
コード例 #15
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientModeTFNormal::Init()
{
	m_pMenuEngyBuild = ( CHudMenuEngyBuild * )GET_HUDELEMENT( CHudMenuEngyBuild );
	Assert( m_pMenuEngyBuild );

	m_pMenuEngyDestroy = ( CHudMenuEngyDestroy * )GET_HUDELEMENT( CHudMenuEngyDestroy );
	Assert( m_pMenuEngyDestroy );

	m_pMenuSpyDisguise = ( CHudMenuSpyDisguise * )GET_HUDELEMENT( CHudMenuSpyDisguise );
	Assert( m_pMenuSpyDisguise );

	m_pMenuWeaponSet = (CHudMenuWeaponSet *)GET_HUDELEMENT(CHudMenuWeaponSet);
	Assert(m_pMenuWeaponSet);

	m_pFreezePanel = ( CTFFreezePanel * )GET_HUDELEMENT( CTFFreezePanel );
	Assert( m_pFreezePanel );

	CreateInterfaceFn gameUIFactory = g_GameUI.GetFactory();
	if ( gameUIFactory )
	{
		m_pGameUI = (IGameUI *) gameUIFactory(GAMEUI_INTERFACE_VERSION, NULL );
		if ( NULL != m_pGameUI )
		{
			// insert stats summary panel as the loading background dialog
			CTFStatsSummaryPanel *pPanel = GStatsSummaryPanel();
			pPanel->InvalidateLayout( false, true );
			pPanel->SetVisible( false );
			pPanel->MakePopup( false );
			m_pGameUI->SetLoadingBackgroundDialog( pPanel->GetVPanel() );
		}		
	}

#if defined( _X360 )
	m_pScoreboard = (CTFClientScoreBoardDialog *)( gViewPortInterface->FindPanelByName( PANEL_SCOREBOARD ) );
	Assert( m_pScoreboard );
#endif

	BaseClass::Init();
}
コード例 #16
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBaseHudWeaponSelection::VidInit(void)
{
	// If we've already loaded weapons, let's get new sprites
	gWR.LoadAllWeaponSprites();

	// set spacing of pickup history
	CHudHistoryResource *pHudHR = GET_HUDELEMENT( CHudHistoryResource );
	if( pHudHR )
	{
		pHudHR->SetHistoryGap( 21 );
	}

	Reset();
}
コード例 #17
0
void asw_return_chat_f()
{
	ChatEchoPanel *pEcho = dynamic_cast<ChatEchoPanel*>(GetClientMode()->GetViewport()->FindChildByName("ChatEchoPanel", true));
	if (!pEcho)
	{
		Msg("failed to find echo panel\n");
		return;
	}
	// give it back
	CHudChat *pHUDChat = dynamic_cast<CHudChat*>(GET_HUDELEMENT( CHudChat ));
	if (pHUDChat)
	{
		//pHUDChat->ReturnChat(pEcho);
	}
}
コード例 #18
0
	// if the player has his mouse over another marine, highlight it, cos he's the one we can give health to
	void CASW_Weapon_Medical_Satchel::MouseOverEntity(C_BaseEntity *pEnt, Vector vecWorldCursor)
	{
		C_ASW_Marine* pOtherMarine = C_ASW_Marine::AsMarine( pEnt );
		CASW_Player *pOwner = GetCommander();
		CASW_Marine *pMarine = GetMarine();
		if (!pOwner || !pMarine)
			return;

		float fOtherHealth = 1.0f;
		if (pOtherMarine && pOtherMarine->GetMarineResource())
			fOtherHealth = pOtherMarine->GetMarineResource()->GetHealthPercent();
		if (!pOtherMarine)
		{
			C_ASW_Game_Resource *pGameResource = ASWGameResource();
			if (pGameResource)
			{
				// find marine closest to world cursor
				const float fMustBeThisClose = 70;
				const C_ASW_Game_Resource::CMarineToCrosshairInfo::tuple_t &info = pGameResource->GetMarineCrosshairCache()->GetClosestMarine();
				if ( info.m_fDistToCursor <= fMustBeThisClose )
				{
					pOtherMarine = info.m_hMarine.Get();
				}
			}
		}

		// if the marine our cursor is over is near enough, highlight him
		if (pOtherMarine)
		{
			float dist = (pMarine->GetAbsOrigin() - pOtherMarine->GetAbsOrigin()).Length2D();
			if (dist < MAX_HEAL_DISTANCE)
			{
				bool bCanGiveHealth = ( fOtherHealth < 1.0f && m_iClip1 > 0 );
				ASWInput()->SetHighlightEntity( pOtherMarine, bCanGiveHealth );
				if ( bCanGiveHealth )		// if he needs healing, show the give health cursor
				{
					CASWHudCrosshair *pCrosshair = GET_HUDELEMENT( CASWHudCrosshair );
					if ( pCrosshair )
					{
						pCrosshair->SetShowGiveHealth(true);
					}
				}
			}
		}		
	}
コード例 #19
0
bool IsTakingAFreezecamScreenshot( void )
{
	// Don't draw in freezecam, or when the game's not running
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	bool bInFreezeCam = ( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM );

	if ( bInFreezeCam == true && engine->IsTakingScreenshot() )
		return true;

	CTFFreezePanel *pPanel = GET_HUDELEMENT( CTFFreezePanel );
	if ( pPanel )
	{
		if ( pPanel->IsHoldingAfterScreenShot() )
			return true;
	}

	return false;
}
コード例 #20
0
void PlayerListPanel::UpdateServerName()
{
    const char* szServerName="";
    if (gpGlobals->maxClients > 1)
    {
        CASWHudMinimap *pMinimap = GET_HUDELEMENT( CASWHudMinimap );
        if (pMinimap)
            szServerName = pMinimap->m_szServerName;
    }
    if (Q_strcmp(szServerName, m_szServerName))
    {
        Q_snprintf(m_szServerName, sizeof(m_szServerName), "%s", szServerName);
        if (m_pServerLabel)
        {
            // post message to avoid translation
            PostMessage( m_pServerLabel, new KeyValues( "SetText", "text", m_szServerName ) );
        }
    }
}
コード例 #21
0
//-----------------------------------------------------------------------------
// Purpose: Menu Selection Code
//-----------------------------------------------------------------------------
void CBaseHudWeaponSelection::SelectSlot( int iSlot )
{
	// A menu may be overriding weapon selection commands
	CHudMenu *pHudMenu = GET_HUDELEMENT( CHudMenu );
	if ( pHudMenu && IsHudMenuTakingInput() )	
	{ 
		pHudMenu->SelectMenuItem( iSlot );  // slots are one off the key numbers
		return;
	}

	// If we're not allowed to draw, ignore weapon selections
	if ( !BaseClass::ShouldDraw() )
	{
		return;
	}

	UpdateSelectionTime();
	SelectWeaponSlot( iSlot );
}
コード例 #22
0
//-----------------------------------------------------------------------------
// Purpose: Draw the weapon's crosshair
//-----------------------------------------------------------------------------
void C_ObjectBaseMannedGun::DrawCrosshair()
{
	C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
	if ( !player )
		return;

	CHudCrosshair *crosshair = (CHudCrosshair *)GET_HUDELEMENT( CHudCrosshair );
	if ( !crosshair )
		return;
	
	if ( iconCrosshair )
	{
		crosshair->SetCrosshair( iconCrosshair, gHUD.m_clrNormal );
	}
	else
	{
		static wrect_t nullrc;
		crosshair->SetCrosshair( 0, Color( 255, 255, 255, 255 ) );
	}
}
コード例 #23
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
C_WeaponMortar::C_WeaponMortar()
{
	m_bCarried = true;
	m_bMortarReloading = false;
	m_iFiringState = MORTAR_IDLE;
	m_flNextClick = 0;
	m_flAccuracySpeed = 0;
	m_bRotating = false;
	m_pGroundLine = NULL;
	m_pDarkLine = NULL;
	m_flMortarYaw = 0;
	m_flPrevMortarYaw = -1;

	m_pRotateIcon = materials->FindMaterial( "Hud/mortar/mortar_rotate", NULL );
	m_pRotateIcon->IncrementReferenceCount();

	m_pPowerBar = GET_HUDELEMENT( CHudMortar );

	m_flLastGroundlineUpdateTime = 0.0f;

	m_hFontText = g_hFontTrebuchet24;
}
コード例 #24
0
ChatEchoPanel::ChatEchoPanel(vgui::Panel *parent, const char *name) : vgui::Panel(parent, name)
{	
	m_pChatInputLine = new vgui::RichText(this, "EchoChatInputLine");
	//m_pChatHistory = new CASWChatHistoryEcho(this, "EchoChatHistory");
	m_pChatHistory = NULL;
	if (m_pChatHistory)
	{
		m_pChatHistory->SetMaximumCharCount( 127 * 100 );
	}
	m_InputBuffer[0] = '\0';

	m_hFont = vgui::INVALID_FONT;

	SetMouseInputEnabled(true);

	// hijack the chat!
	CHudChat *pHUDChat = dynamic_cast<CHudChat*>(GET_HUDELEMENT( CHudChat ));
	if (pHUDChat)
	{
		//pHUDChat->HijackChat(this);
	}
}
コード例 #25
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_VoteController::FireGameEvent( IGameEvent *event )
{
	CHudVote *pHudVote = GET_HUDELEMENT( CHudVote );
	if ( pHudVote && pHudVote->IsVisible() )
	{
		const char *eventName = event->GetName();
		if ( !eventName )
			return;

		C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
		if ( !pLocalPlayer )
			return;

		int team = event->GetInt( "team", TEAM_UNASSIGNED );
		if ( team > TEAM_UNASSIGNED && team != pLocalPlayer->GetTeamNumber() )
			return;

		if ( FStrEq( eventName, "vote_cast" ) )
		{
			if ( m_bIsYesNoVote )
			{
				int vote_option = event->GetInt( "vote_option", TEAM_UNASSIGNED );
				if( vote_option == VOTE_OPTION2 )
				{
					pLocalPlayer->EmitSound( "Vote.Cast.No" );
				}
				else if( vote_option == VOTE_OPTION1 )
				{
					pLocalPlayer->EmitSound( "Vote.Cast.Yes" );
				}
			}
			else
			{
				pLocalPlayer->EmitSound( "Vote.Cast.Yes" );
			}
		}
	}
}
コード例 #26
0
void CASWInput::UpdateHighlightEntity()
{
	// if we're currently brightening any entity, stop
	SetHighlightEntity( NULL, false );
	// clear any additional cursor icons
	CASWHudCrosshair *pCrosshair = GET_HUDELEMENT( CASWHudCrosshair );
	if ( pCrosshair )
	{
		pCrosshair->SetShowGiveAmmo(false, -1);
		pCrosshair->SetShowGiveHealth( false );
	}

	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	C_ASW_Marine* pMarine = pPlayer->GetMarine();
	if ( !pMarine )
		return;

	// see if the marine and his weapons want to highlight the current entity, or something near the cursor
	pMarine->MouseOverEntity( GetMouseOverEntity(), GetCrosshairAimingPos() );
}
コード例 #27
0
//-----------------------------------------------------------------------------
// Purpose: Set a crosshair when in a vehicle and we don't have a proper 
//          crosshair sprite (ie. a commando laser rifle).
//-----------------------------------------------------------------------------
void CBaseTFVehicle::SetupCrosshair( void )
{
	if ( !m_pIconDefaultCrosshair )
	{
		// Init the default crosshair the first time.
		CHudTexture newTexture;
		Q_strncpy( newTexture.szTextureFile, "sprites/crosshairs", sizeof( newTexture.szTextureFile ) );

		newTexture.rc.left		= 0;
		newTexture.rc.top		= 48;
		newTexture.rc.right		= newTexture.rc.left + 24;
		newTexture.rc.bottom	= newTexture.rc.top + 24;
		m_pIconDefaultCrosshair = gHUD.AddUnsearchableHudIconToList( newTexture );
	}

	CHudCrosshair *crosshair = GET_HUDELEMENT( CHudCrosshair );
	if ( crosshair )
	{
		if ( !crosshair->HasCrosshair() && m_pIconDefaultCrosshair )
		{
			crosshair->SetCrosshair( m_pIconDefaultCrosshair, gHUD.m_clrNormal );
		}
	}
}
コード例 #28
0
//-----------------------------------------------------------------------------
// Purpose: Called when the DLL is first loaded.
// Input  : engineFactory - 
// Output : int
//-----------------------------------------------------------------------------
int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physicsFactory, CGlobalVarsBase *pGlobals )
{
	InitCRTMemDebug();
	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );

	// Hook up global variables
	gpGlobals = pGlobals;

	// We aren't happy unless we get all of our interfaces.
	if(
		!(engine = (IVEngineClient *)appSystemFactory( VENGINE_CLIENT_INTERFACE_VERSION, NULL )) ||
		!(modelrender = (IVModelRender *)appSystemFactory( VENGINE_HUDMODEL_INTERFACE_VERSION, NULL )) ||
		!(effects = (IVEfx *)appSystemFactory( VENGINE_EFFECTS_INTERFACE_VERSION, NULL )) ||
		!(cvar = (ICvar *)appSystemFactory( VENGINE_CVAR_INTERFACE_VERSION, NULL )) ||
		!(enginetrace = (IEngineTrace *)appSystemFactory( INTERFACEVERSION_ENGINETRACE_CLIENT, NULL )) ||
		!(render = (IVRenderView *)appSystemFactory( VENGINE_RENDERVIEW_INTERFACE_VERSION, NULL )) ||
		!(debugoverlay = (IVDebugOverlay *)appSystemFactory( VDEBUG_OVERLAY_INTERFACE_VERSION, NULL )) ||
		!(materials = (IMaterialSystem *)appSystemFactory( MATERIAL_SYSTEM_INTERFACE_VERSION, NULL )) ||
		!(engineCache = (IVEngineCache*)appSystemFactory(VENGINE_CACHE_INTERFACE_VERSION, NULL )) ||
		!(modelinfo = (IVModelInfo *)appSystemFactory(VMODELINFO_CLIENT_INTERFACE_VERSION, NULL )) ||
		!(netgraph = (INetGraph *)appSystemFactory(VNETGRAPH_INTERFACE_VERSION, NULL )) ||
		!(enginevgui = (IEngineVGui *)appSystemFactory(VENGINE_VGUI_VERSION, NULL )) ||
		!(networkstringtable = (INetworkStringTableClient *)appSystemFactory(INTERFACENAME_NETWORKSTRINGTABLECLIENT,NULL)) ||
		!(partition = (ISpatialPartition *)appSystemFactory(INTERFACEVERSION_SPATIALPARTITION, NULL)) ||
		!(shadowmgr = (IShadowMgr *)appSystemFactory(ENGINE_SHADOWMGR_INTERFACE_VERSION, NULL)) ||
		!(staticpropmgr = (IStaticPropMgrClient *)appSystemFactory(INTERFACEVERSION_STATICPROPMGR_CLIENT, NULL)) ||
		!(enginesound = (IEngineSound *)appSystemFactory(IENGINESOUND_CLIENT_INTERFACE_VERSION, NULL)) ||
		!(filesystem = (IFileSystem *)appSystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL)) ||
		!(random = (IUniformRandomStream *)appSystemFactory(VENGINE_CLIENT_RANDOM_INTERFACE_VERSION, NULL)) ||
		!(gameuifuncs = (IGameUIFuncs * )appSystemFactory( VENGINE_GAMEUIFUNCS_VERSION, NULL )) ||
		!(gameeventmanager = (IGameEventManager *)appSystemFactory(INTERFACEVERSION_GAMEEVENTSMANAGER,NULL))
		)
	{
		return false;
	}

	g_pMaterialSystemHardwareConfig = materials->GetHardwareConfig( MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, NULL );
	if( !g_pMaterialSystemHardwareConfig )
	{
		return false;
	}

	SetScreenSize();

	// Hook up the gaussian random number generator
	s_GaussianRandomStream.AttachToStream( random );

	// Initialize the console variables.
	ConCommandBaseMgr::OneTimeInit(&g_ConVarAccessor);

	if(!Initializer::InitializeAllObjects())
		return false;

	if(!g_ParticleMgr.Init(8192, materials))
		return false;

	// load used game events  
	gameeventmanager->LoadEventsFromFile("resource/gameevents.res");

	if(!VGui_Startup( appSystemFactory ))
		return false;

	g_pMatSystemSurface = (IMatSystemSurface*)vgui::surface()->QueryInterface( MAT_SYSTEM_SURFACE_INTERFACE_VERSION ); 
	if (!g_pMatSystemSurface)
		return false;

	// Add the client systems.	
	
	// Client Leaf System has to be initialized first, since DetailObjectSystem uses it
	IGameSystem::Add( GameStringSystem() );
	IGameSystem::Add( ClientLeafSystem() );
	IGameSystem::Add( DetailObjectSystem() );
	IGameSystem::Add( ViewportClientSystem() );
	IGameSystem::Add( ClientEffectPrecacheSystem() );
	IGameSystem::Add( g_pClientShadowMgr );
	IGameSystem::Add( ClientThinkList() );
	IGameSystem::Add( ClientSoundscapeSystem() );

#if defined( CLIENT_DLL ) && defined( COPY_CHECK_STRESSTEST )
	IGameSystem::Add( GetPredictionCopyTester() );
#endif

	modemanager->Init( );

	gHUD.Init();

	g_pClientMode->Init();

	if( !IGameSystem::InitAllSystems() )
		return false;

	g_pClientMode->Enable();

	view->Init();
	vieweffects->Init();

	C_BaseTempEntity::PrecacheTempEnts();

	input->Init_All();

	VGui_CreateGlobalPanels();

	InitSmokeFogOverlay();

	C_TerrainMod_Init();

	// Register user messages..
	CUserMessageRegister::RegisterAll();

	ClientVoiceMgr_Init();

	// Embed voice status icons inside chat element
	{
		CHudChat *chatElement = GET_HUDELEMENT( CHudChat );
		vgui::VPANEL parent = enginevgui->GetPanel( PANEL_CLIENTDLL );
		if ( chatElement )
		{
			parent = chatElement->GetVoiceArea()->GetVPanel();
		}
		
		GetClientVoiceMgr()->Init( &g_VoiceStatusHelper, parent );
	}

	if ( !PhysicsDLLInit( physicsFactory ) )
		return false;

	g_pGameSaveRestoreBlockSet->AddBlockHandler( GetEntitiySaveRestoreBlockHandler() );
	g_pGameSaveRestoreBlockSet->AddBlockHandler( GetPhysSaveRestoreBlockHandler() );

	return true;
}
コード例 #29
0
void CNB_Mission_Summary::OnThink()
{
	BaseClass::OnThink();

	if ( !ASWGameResource() )
		return;

	int nSkillLevel = ASWGameRules()->GetSkillLevel();
	const wchar_t *pDifficulty = NULL;
	switch( nSkillLevel )
	{
		case 1: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_easy" ); break;
		default:
		case 2: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_normal" ); break;
		case 3: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_hard" ); break;
		case 4: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_insane" ); break;
		case 5: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_imba" ); break;
	}
	if ( !pDifficulty )
	{
		pDifficulty = L"";
	}

	if ( CAlienSwarm::IsOnslaught() )
	{
		wchar_t wszText[ 128 ];
		_snwprintf( wszText, sizeof( wszText ), L"%s %s", pDifficulty, g_pVGuiLocalize->FindSafe( "#nb_onslaught_title" ) );
		m_pDifficultyLabel->SetText( wszText );
	}
	else
	{
		m_pDifficultyLabel->SetText( pDifficulty );
	}

	CASWHudMinimap *pMap = GET_HUDELEMENT( CASWHudMinimap );
	if ( pMap )
	{
		m_pMissionLabel->SetText(pMap->m_szMissionTitle);
	}

	// compose objectives list
	wchar_t wszObjectivesBuffer[ 1024 ];
	wchar_t wszBuffer[ 1024 ];

	wszObjectivesBuffer[ 0 ] = 0;

	int nObjectives = 0;
	for ( int i = 0 ; i < ASW_MAX_OBJECTIVES; i++ )
	{
		C_ASW_Objective* pObjective = ASWGameResource()->GetObjective(i);
		if ( pObjective && !pObjective->IsObjectiveHidden() && !pObjective->IsObjectiveDummy() )
		{
			if ( nObjectives == 0 )
			{
				_snwprintf( wszObjectivesBuffer, sizeof( wszObjectivesBuffer ), L"- %s", pObjective->GetObjectiveTitle() );
			}
			else
			{
				_snwprintf( wszBuffer, sizeof( wszBuffer ), L"%s\n- %s", wszObjectivesBuffer, pObjective->GetObjectiveTitle() );
				_snwprintf( wszObjectivesBuffer , sizeof( wszObjectivesBuffer ), L"%s", wszBuffer );
			}
			nObjectives++;
		}
	}
	m_pObjectivesLabel->SetText( wszObjectivesBuffer );

	int nLabelWidth = YRES( 168 );
	m_pObjectivesLabel->SetSize( nLabelWidth, 400 );
	m_pObjectivesLabel->GetTextImage()->SetDrawWidth( nLabelWidth );
	m_pObjectivesLabel->InvalidateLayout( true );
	int texwide, texttall;	
	m_pObjectivesLabel->GetTextImage()->ResizeImageToContentMaxWidth( nLabelWidth );
	m_pObjectivesLabel->SetWrap( true );
	m_pObjectivesLabel->GetTextImage()->GetContentSize( texwide, texttall );	
	//m_pObjectivesLabel->SetSize( texwide, texttall );
	m_pObjectivesLabel->InvalidateLayout( true );
	m_pObjectivesLabel->GetTextImage()->GetContentSize( texwide, texttall );
	m_pObjectivesLabel->InvalidateLayout( true );
}
コード例 #30
0
void ChatEchoPanel::OnThink()
{
	CBaseHudChat *pHUDChat = (CBaseHudChat *)GET_HUDELEMENT( CHudChat );
	if (!pHUDChat)
		return;

	// ASWTODO - Unprotect all the hud chat stuff so this code below works - or figure out a better way of showing the chat during the various frames

	// copying the chat input line
	CBaseHudChatInputLine *pChatInput = pHUDChat->GetChatInput();
	if ( pChatInput)
	{
		vgui::TextEntry *pTextEntry = dynamic_cast<vgui::TextEntry*>(pChatInput->GetInputPanel());
		vgui::Label *pPrompt = pChatInput->GetPrompt();
		if (pTextEntry)
		{
			wchar_t buffer[256];
			pTextEntry->GetText(buffer, sizeof(buffer));
			bool bInputVisible = (pChatInput->IsVisible() && pTextEntry->IsVisible()
						&& pChatInput->GetAlpha() > 200  && pTextEntry->GetAlpha() > 200);
			//if (Q_strcmp(buffer, m_InputBuffer))
			{				
				pTextEntry->GetText(m_InputBuffer, sizeof(m_InputBuffer));
				if (bInputVisible)
				{
					// grab our prompt (or use a default)
					wchar_t prompt[64];
					if (pPrompt)
						pPrompt->GetText(prompt, sizeof(prompt));
					else
					{
						char promptbuffer[8];
						Q_snprintf(promptbuffer, sizeof(promptbuffer), "Say: ");
						g_pVGuiLocalize->ConvertANSIToUnicode(promptbuffer, prompt, sizeof( prompt ));
					}

					// copy x chars around the cursor into our echo
					const int max_copy_chars = 54;
					int line_length = wcslen(m_InputBuffer);
					int cursor_pos = 0;
					if (pTextEntry)
						cursor_pos = pTextEntry->GetTextCursorPos();
					int copy_start = MAX((cursor_pos + 20) - max_copy_chars, 0);
					int copy_end = copy_start + max_copy_chars;
					if (copy_end > line_length)
					{
						int diff = copy_end - line_length;
						copy_start = MAX(copy_start - diff, 0);
						copy_end = MIN(copy_start + max_copy_chars, line_length);
					}

					// copy the prompt over
					int prompt_len = wcslen(prompt);
					int iCopyCursor = 0;
					for (int i=0;i<prompt_len;i++)
					{
						buffer[iCopyCursor] = prompt[i];
						iCopyCursor++;
					}

					buffer[iCopyCursor] = L' ';
					iCopyCursor++;
					bool bAddedCursor = false;

					// check for drawing the cursor at the start
					if (cursor_pos == 0)
					{
						bAddedCursor |= AddCursorToBuffer(buffer, iCopyCursor, (cursor_pos == copy_end));  // if cursor is also at the end, we can flash it						
					}

					// now copy the section of our input line, insert the cursor in the right place
					for (int i=copy_start;i<copy_end;i++)
					{
						if (iCopyCursor >= 253)	// make sure we don't go over out limit for safety (never should though)
							iCopyCursor = 253;
						buffer[iCopyCursor] = m_InputBuffer[i];
						iCopyCursor++;
						if (i == (cursor_pos-1))
						{
							bAddedCursor |= AddCursorToBuffer(buffer, iCopyCursor, (cursor_pos == copy_end));  // if cursor is at the end, we can flash it
						}
					}

					// make sure we've added the cursor
					if (!bAddedCursor)
						AddCursorToBuffer(buffer, iCopyCursor, true);
					
					//if (copy_start == copy_end)
					//{
						//if (fabs(gpGlobals->curtime - integer_time) < 0.25f ||
								//(fabs(gpGlobals->curtime - integer_time) > 0.5f
								//&& fabs(gpGlobals->curtime - integer_time) < 0.75f)) 
						//{
							//buffer[iCopyCursor] = L'|';
							//iCopyCursor++;
						//}
					//}
					buffer[iCopyCursor] = L'\0';
					
					//if 
						//Q_snprintf(buffer, sizeof(buffer), "%s %s", prompt, m_InputBuffer);
					//else
						//Q_snprintf(buffer, sizeof(buffer), "%s %s|", prompt, m_InputBuffer);
					
					m_pChatInputLine->SetText(buffer);
					m_pChatInputLine->SetVisible(true);
				}
				else
				{
					m_pChatInputLine->SetText(m_InputBuffer);					
				}
			}			
			if (m_pChatInputLine->IsVisible() != bInputVisible)
				m_pChatInputLine->SetVisible(bInputVisible);
		}
		else
		{
			if (m_pChatInputLine->IsVisible())
				m_pChatInputLine->SetVisible(false);
		}
	}	
	/*
	// copying the chat history
	if ( pHUDChat->GetChatHistory() )
	{
		CHudChatHistory *pHistory = pHUDChat->GetChatHistory();
						
		//pHistory->GetText(0, m_InputBuffer, sizeof(m_InputBuffer) * sizeof(wchar_t));
		pHistory->GetEndOfText(ASW_CHAT_ECHO_HISTORY_WCHARS-1, m_InputBuffer, ASW_CHAT_ECHO_HISTORY_WCHARS);
		if (m_pChatHistory)
		{
			if (pHistory->IsVisible())
			{
				m_pChatHistory->SetText(m_InputBuffer);
				m_pChatHistory->SetVisible(true);

				m_pChatHistory->SetPaintBorderEnabled( false );
				m_pChatHistory->GotoTextEnd();
				m_pChatHistory->SetMouseInputEnabled( false );
			}
			else
			{
				m_pChatHistory->SetVisible(false);			
			}
		}
	}
	*/
}