static void OpenPanelWithCheck( const char *panelToOpen, const char *panelToCheck )
{
	IViewPortPanel *checkPanel = gViewPortInterface->FindPanelByName( panelToCheck );
	if ( !checkPanel || !checkPanel->IsVisible() )
	{
		gViewPortInterface->ShowPanel( panelToOpen, true );
	}
}
Пример #2
0
int SDKViewport::GetDeathMessageStartHeight( void )
{
	int x = YRES(2);

	IViewPortPanel *spectator = gViewPortInterface->FindPanelByName( PANEL_SPECGUI );

	//TODO: Link to actual height of spectator bar
	if ( spectator && spectator->IsVisible() )
	{
		x += YRES(52);
	}

	return x;
}
Пример #3
0
//LAWYER: (BUILD MENU) Define the pressing of buttons
void CBuildMenu::OnCommand( const char *command )
{
	if (Q_stricmp( command, "vguicancel" ) != 0)
	{
		//TGB: some special commands need the current spawn idx
		if (Q_strnicmp( command, "summon", 6 ) == 0 || //both summon commands
			Q_strnicmp( command, "buildmenu_", 10 ) == 0) //remove last and clear queue commands
		{
			char buffer[256];
			Q_snprintf(buffer, sizeof(buffer), command, m_iCurrentSpawn);
			engine->ClientCmd( const_cast<char *>( buffer ) );
			return;
		}
		else if (Q_stricmp( command, "toggle_rally") == 0)
		{
			//engine->ClientCmd( const_cast<char *>( command ) );

			//TGB: instead of going through server, send a rallymode cmd to vgui_viewport
			KeyValues *msg = new KeyValues("ButtonCommand");
			msg->SetString("command", "MODE_RALLY");
			IViewPortPanel *pview = gViewPortInterface->FindPanelByName(PANEL_VIEWPORT);
			if (pview)
				PostMessage(pview->GetVPanel(), msg);

			//no return here means the buildmenu will close, as it should in this case
		}
		else
		{
			engine->ClientCmd( const_cast<char *>( command ) );
			return;
		}
	}

	DoClose();

	BaseClass::OnCommand(command);
}
Пример #4
0
//-----------------------------------------------------------------------------
// Purpose: Updates the gui, rearranges elements
//-----------------------------------------------------------------------------
void CSpectatorGUI::Update()
{
	int wide, tall;
	int bx, by, bwide, btall;

	GetHudSize(wide, tall);
	m_pTopBar->GetBounds( bx, by, bwide, btall );

	IGameResources *gr = GameResources();
	int specmode = GetSpectatorMode();
	int playernum = GetSpectatorTarget();

	IViewPortPanel *overview = GetViewPortInterface()->FindPanelByName( PANEL_OVERVIEW );

	if ( overview && overview->IsVisible() )
	{
		int mx, my, mwide, mtall;

		VPANEL p = overview->GetVPanel();
		vgui::ipanel()->GetPos( p, mx, my );
		vgui::ipanel()->GetSize( p, mwide, mtall );
				
		if ( my < btall )
		{
			// reduce to bar 
			m_pTopBar->SetSize( wide - (mx + mwide), btall );
			m_pTopBar->SetPos( (mx + mwide), 0 );
		}
		else
		{
			// full top bar
			m_pTopBar->SetSize( wide , btall );
			m_pTopBar->SetPos( 0, 0 );
		}
	}
	else
	{
		// full top bar
		m_pTopBar->SetSize( wide , btall ); // change width, keep height
		m_pTopBar->SetPos( 0, 0 );
	}

	m_pPlayerLabel->SetVisible( ShouldShowPlayerLabel(specmode) );

	// update player name filed, text & color

	if ( playernum > 0 && playernum <= gpGlobals->maxClients && gr )
	{
		Color c = gr->GetTeamColor( gr->GetTeam(playernum) ); // Player's team color

		m_pPlayerLabel->SetFgColor( c );
		
		wchar_t playerText[ 80 ], playerName[ 64 ], health[ 10 ];
		wcscpy( playerText, L"Unable to find #Spec_PlayerItem*" );
		memset( playerName, 0x0, sizeof( playerName ) );

		g_pVGuiLocalize->ConvertANSIToUnicode( UTIL_SafeName(gr->GetPlayerName( playernum )), playerName, sizeof( playerName ) );
		int iHealth = gr->GetHealth( playernum );
		if ( iHealth > 0  && gr->IsAlive(playernum) )
		{
			_snwprintf( health, sizeof( health ), L"%i", iHealth );
			g_pVGuiLocalize->ConstructString( playerText, sizeof( playerText ), g_pVGuiLocalize->Find( "#Spec_PlayerItem_Team" ), 2, playerName,  health );
		}
		else
		{
			g_pVGuiLocalize->ConstructString( playerText, sizeof( playerText ), g_pVGuiLocalize->Find( "#Spec_PlayerItem" ), 1, playerName );
		}

		m_pPlayerLabel->SetText( playerText );
	}
	else
	{
		m_pPlayerLabel->SetText( L"" );
	}

	// update extra info field
	wchar_t szEtxraInfo[1024];
	wchar_t szTitleLabel[1024];
	char tempstr[128];

	if ( g_bEngineIsHLTV )
	{
		// set spectator number and HLTV title
		Q_snprintf(tempstr,sizeof(tempstr),"Spectators : %d", HLTVCamera()->GetNumSpectators() );
		g_pVGuiLocalize->ConvertANSIToUnicode(tempstr,szEtxraInfo,sizeof(szEtxraInfo));
		
		Q_strncpy( tempstr, HLTVCamera()->GetTitleText(), sizeof(tempstr) );
		g_pVGuiLocalize->ConvertANSIToUnicode(tempstr,szTitleLabel,sizeof(szTitleLabel));
	}
#if defined( REPLAY_ENABLED )
	else if ( engine->IsReplay() )
	{
		// set spectator number and Replay title
		Q_snprintf(tempstr,sizeof(tempstr),"Spectators : %d", ReplayCamera()->GetNumSpectators() );
		g_pVGuiLocalize->ConvertANSIToUnicode(tempstr,szEtxraInfo,sizeof(szEtxraInfo));

		Q_strncpy( tempstr, ReplayCamera()->GetTitleText(), sizeof(tempstr) );
		g_pVGuiLocalize->ConvertANSIToUnicode(tempstr,szTitleLabel,sizeof(szTitleLabel));
	}
#endif
	else
	{
		// otherwise show map name
		Q_FileBase( engine->GetLevelName(), tempstr, sizeof(tempstr) );

		wchar_t wMapName[64];
		g_pVGuiLocalize->ConvertANSIToUnicode(tempstr,wMapName,sizeof(wMapName));
		g_pVGuiLocalize->ConstructString( szEtxraInfo,sizeof( szEtxraInfo ), g_pVGuiLocalize->Find("#Spec_Map" ),1, wMapName );

		g_pVGuiLocalize->ConvertANSIToUnicode( "" ,szTitleLabel,sizeof(szTitleLabel));
	}

	SetLabelText("extrainfo", szEtxraInfo );
	SetLabelText("titlelabel", szTitleLabel );
}
Пример #5
0
//-----------------------------------------------------------------------------
// Purpose: Updates the gui, rearranges elements
//-----------------------------------------------------------------------------
void CMOMSpectatorGUI::Update()
{
    int wide, tall;
    int bx, by, bwide, btall;

    GetHudSize(wide, tall);
    m_pTopBar->GetBounds(bx, by, bwide, btall);

    IGameResources *gr = GameResources();
    int specmode = GetSpectatorMode();
    int playernum = GetSpectatorTarget();

    IViewPortPanel *overview = gViewPortInterface->FindPanelByName(PANEL_OVERVIEW);

    if (overview && overview->IsVisible())
    {
        int mx, my, mwide, mtall;

        VPANEL p = overview->GetVPanel();
        vgui::ipanel()->GetPos(p, mx, my);
        vgui::ipanel()->GetSize(p, mwide, mtall);

        if (my < btall)
        {
            // reduce to bar
            m_pTopBar->SetSize(wide - (mx + mwide), btall);
            m_pTopBar->SetPos((mx + mwide), 0);
        }
        else
        {
            // full top bar
            m_pTopBar->SetSize(wide, btall);
            m_pTopBar->SetPos(0, 0);
        }
    }
    else
    {
        // full top bar
        m_pTopBar->SetSize(wide, btall); // change width, keep height
        m_pTopBar->SetPos(0, 0);
    }

    m_pPlayerLabel->SetVisible(ShouldShowPlayerLabel(specmode));

    // update player name filed, text & color

    if (playernum > 0 && playernum <= gpGlobals->maxClients && gr)
    {
        Color c = gr->GetTeamColor(gr->GetTeam(playernum)); // Player's team color

        m_pPlayerLabel->SetFgColor(c);

        wchar_t playerText[80], playerName[64];
        V_wcsncpy(playerText, L"Unable to find #Spec_PlayerItem*", sizeof(playerText));
        memset(playerName, 0x0, sizeof(playerName));

        g_pVGuiLocalize->ConvertANSIToUnicode(UTIL_SafeName(gr->GetPlayerName(playernum)), playerName,
                                              sizeof(playerName));
        g_pVGuiLocalize->ConstructString(playerText, sizeof(playerText), g_pVGuiLocalize->Find("#Spec_PlayerItem"), 1,
                                         playerName);

        m_pPlayerLabel->SetText(playerText);
    }
    else
    {
        m_pPlayerLabel->SetText("");
    }
    CMomentumPlayer *pPlayer = ToCMOMPlayer(CBasePlayer::GetLocalPlayer());
    if (pPlayer)
    {
        C_MomentumReplayGhostEntity *pReplayEnt = pPlayer->GetReplayEnt();
        if (pReplayEnt)
        {
            wchar_t wPlayerName[MAX_PLAYER_NAME_LENGTH], szPlayerInfo[128];
            g_pVGuiLocalize->ConvertANSIToUnicode(pReplayEnt->m_pszPlayerName, wPlayerName, sizeof(wPlayerName));
            swprintf(szPlayerInfo, L"%s %s", g_pVGuiLocalize->Find("#MOM_ReplayPlayer"), wPlayerName);

            SetLabelText("playerlabel", szPlayerInfo);

            char tempRunTime[BUFSIZETIME];
            wchar_t szTimeLabel[BUFSIZELOCL], wTime[BUFSIZETIME];
            mom_UTIL->FormatTime(pReplayEnt->m_RunData.m_flRunTime, tempRunTime);
            g_pVGuiLocalize->ConvertANSIToUnicode(tempRunTime, wTime, sizeof(wTime));
            g_pVGuiLocalize->ConstructString(szTimeLabel, sizeof(szTimeLabel), g_pVGuiLocalize->Find("#MOM_MF_RunTime"),
                                             1, wTime);

            SetLabelText("timelabel", szTimeLabel);

            SetLabelText("replaylabel", g_pVGuiLocalize->Find("#MOM_WatchingReplay"));
        }
        else
        {
            m_pReplayLabel->SetText("");
        }
    }

    // update extra info field
    wchar_t szEtxraInfo[1024];
    wchar_t szTitleLabel[1024];
    char tempstr[128];

    if (engine->IsHLTV())
    {
        // set spectator number and HLTV title
        Q_snprintf(tempstr, sizeof(tempstr), "Spectators : %d", HLTVCamera()->GetNumSpectators());
        g_pVGuiLocalize->ConvertANSIToUnicode(tempstr, szEtxraInfo, sizeof(szEtxraInfo));

        Q_strncpy(tempstr, HLTVCamera()->GetTitleText(), sizeof(tempstr));
        g_pVGuiLocalize->ConvertANSIToUnicode(tempstr, szTitleLabel, sizeof(szTitleLabel));
    }
    else
    {
        // otherwise show map name
        Q_FileBase(engine->GetLevelName(), tempstr, sizeof(tempstr));

        wchar_t wMapName[64];
        g_pVGuiLocalize->ConvertANSIToUnicode(tempstr, wMapName, sizeof(wMapName));
        g_pVGuiLocalize->ConstructString(szEtxraInfo, sizeof(szEtxraInfo), g_pVGuiLocalize->Find("#Spec_Map"), 1,
                                         wMapName);

        g_pVGuiLocalize->ConvertANSIToUnicode("", szTitleLabel, sizeof(szTitleLabel));
    }

    SetLabelText("extrainfo", szEtxraInfo);
    SetLabelText("titlelabel", szTitleLabel);
}