Remove mod-specific code under macros.

This commit is contained in:
Andrey Akhmichin 2022-11-14 06:59:52 +05:00
parent 7fb1dab079
commit e761d1d405
No known key found for this signature in database
GPG Key ID: 1F180D249B0643C0
6 changed files with 5 additions and 827 deletions

View File

@ -100,147 +100,6 @@ CClassMenuPanel::CClassMenuPanel( int iTrans, int iRemoveMe, int x, int y, int w
m_pScrollPanel->setScrollBarVisible( false, false );
m_pScrollPanel->validate();
// Create the Class buttons
#ifdef _TFC
for( int i = 0; i <= PC_RANDOM; i++ )
{
char sz[256];
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y + ( ( CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y ) * i );
ActionSignal *pASignal = new CMenuHandler_StringCommandClassSelect( sTFClassSelection[i], true );
// Class button
sprintf( sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[i] ) );
m_pButtons[i] = new ClassButton( i, sz, CLASSMENU_TOPLEFT_BUTTON_X, iYPos, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y, true );
// RandomPC uses '0'
if( i >= 1 && i <= 9 )
{
sprintf( sz, "%d", i );
}
else
{
strcpy( sz, "0" );
}
m_pButtons[i]->setBoundKey( sz[0] );
m_pButtons[i]->setContentAlignment( vgui::Label::a_west );
m_pButtons[i]->addActionSignal( pASignal );
m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver(this, i) );
m_pButtons[i]->setParent( this );
// Create the Class Info Window
// m_pClassInfoPanel[i] = new CTransparentPanel( 255, CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y );
m_pClassInfoPanel[i] = new CTransparentPanel( 255, 0, 0, clientWide, CLASSMENU_WINDOW_SIZE_Y );
m_pClassInfoPanel[i]->setParent( m_pScrollPanel->getClient() );
// m_pClassInfoPanel[i]->setVisible( false );
// don't show class pic in lower resolutions
int textOffs = XRES( 8 );
if( bShowClassGraphic )
{
textOffs = CLASSMENU_WINDOW_NAME_X;
}
// Create the Class Name Label
sprintf( sz, "#Title_%s", sTFClassSelection[i] );
char *localName=CHudTextMessage::BufferedLocaliseTextString( sz );
Label *pNameLabel = new Label( "", textOffs, CLASSMENU_WINDOW_NAME_Y );
pNameLabel->setFont( pSchemes->getFont( hTitleScheme ) );
pNameLabel->setParent( m_pClassInfoPanel[i] );
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
pNameLabel->setFgColor( r, g, b, a );
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
pNameLabel->setBgColor( r, g, b, a );
pNameLabel->setContentAlignment( vgui::Label::a_west );
// pNameLabel->setBorder( new LineBorder() );
pNameLabel->setText( "%s", localName);
// Create the Class Image
if( bShowClassGraphic )
{
for( int team = 0; team < 2; team++ )
{
if( team == 1 )
{
sprintf( sz, "%sred", sTFClassSelection[i] );
}
else
{
sprintf( sz, "%sblue", sTFClassSelection[i] );
}
m_pClassImages[team][i] = new CImageLabel( sz, 0, 0, CLASSMENU_WINDOW_TEXT_X, CLASSMENU_WINDOW_TEXT_Y );
CImageLabel *pLabel = m_pClassImages[team][i];
pLabel->setParent( m_pClassInfoPanel[i] );
// pLabel->setBorder( new LineBorder() );
if( team != 1 )
{
pLabel->setVisible( false );
}
// Reposition it based upon it's size
int xOut, yOut;
pNameLabel->getTextSize( xOut, yOut );
pLabel->setPos( ( CLASSMENU_WINDOW_TEXT_X - pLabel->getWide() ) / 2, yOut / 2 );
}
}
// Create the Player count string
gHUD.m_TextMessage.LocaliseTextString( "#Title_CurrentlyOnYourTeam", m_sPlayersOnTeamString, STRLENMAX_PLAYERSONTEAM );
m_pPlayers[i] = new Label( "", textOffs, CLASSMENU_WINDOW_PLAYERS_Y );
m_pPlayers[i]->setParent( m_pClassInfoPanel[i] );
m_pPlayers[i]->setBgColor( 0, 0, 0, 255 );
m_pPlayers[i]->setContentAlignment( vgui::Label::a_west );
m_pPlayers[i]->setFont( pSchemes->getFont( hClassWindowText ) );
// Open up the Class Briefing File
sprintf(sz, "classes/short_%s.txt", sTFClassSelection[i]);
char *cText = "Class Description not available.";
char *pfile = (char *)gEngfuncs.COM_LoadFile( sz, 5, NULL );
if( pfile )
{
cText = pfile;
}
// Create the Text info window
TextPanel *pTextWindow = new TextPanel( cText, textOffs, CLASSMENU_WINDOW_TEXT_Y, ( CLASSMENU_WINDOW_SIZE_X - textOffs ) - 5, CLASSMENU_WINDOW_SIZE_Y - CLASSMENU_WINDOW_TEXT_Y );
pTextWindow->setParent( m_pClassInfoPanel[i] );
pTextWindow->setFont( pSchemes->getFont( hClassWindowText ) );
pSchemes->getFgColor( hClassWindowText, r, g, b, a );
pTextWindow->setFgColor( r, g, b, a );
pSchemes->getBgColor( hClassWindowText, r, g, b, a );
pTextWindow->setBgColor( r, g, b, a );
// Resize the Info panel to fit it all
int wide,tall;
pTextWindow->getTextImage()->getTextSizeWrapped( wide, tall );
pTextWindow->setSize( wide, tall );
int xx, yy;
pTextWindow->getPos( xx, yy );
int maxX = xx + wide;
int maxY = yy + tall;
//check to see if the image goes lower than the text
//just use the red teams [0] images
if( m_pClassImages[0][i] != null )
{
m_pClassImages[0][i]->getPos( xx, yy );
if( ( yy + m_pClassImages[0][i]->getTall() ) > maxY )
{
maxY = yy + m_pClassImages[0][i]->getTall();
}
}
m_pClassInfoPanel[i]->setSize( maxX , maxY );
if( pfile )
gEngfuncs.COM_FreeFile( pfile );
// m_pClassInfoPanel[i]->setBorder( new LineBorder() );
}
#endif
// Create the Cancel button
m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Menu_Cancel" ), CLASSMENU_TOPLEFT_BUTTON_X, 0, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y );
m_pCancelButton->setParent( this );
@ -258,96 +117,6 @@ void CClassMenuPanel::Update()
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y;
// Cycle through the rest of the buttons
#ifdef _TFC
for( int i = 0; i <= PC_RANDOM; i++ )
{
bool bCivilian = ( gViewPort->GetValidClasses( g_iTeamNumber ) == -1 );
if( bCivilian )
{
// If this team can only be civilians, only the civilian button's visible
if( i == 0 )
{
m_pButtons[0]->setVisible( true );
SetActiveInfo( 0 );
iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y;
}
else
{
m_pButtons[i]->setVisible( false );
}
}
else
{
if( m_pButtons[i]->IsNotValid() || i == 0 )
{
m_pButtons[i]->setVisible( false );
}
else
{
m_pButtons[i]->setVisible( true );
m_pButtons[i]->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos );
iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y;
// Start with the first option up
if( !m_iCurrentInfo )
SetActiveInfo( i );
}
}
// Now count the number of teammembers of this class
int iTotal = 0;
for( int j = 1; j < MAX_PLAYERS; j++ )
{
if( g_PlayerInfoList[j].name == 0 )
continue; // empty player slot, skip
if( g_PlayerExtraInfo[j].teamname[0] == 0 )
continue; // skip over players who are not in a team
if( g_PlayerInfoList[j].thisplayer )
continue; // skip this player
if( g_PlayerExtraInfo[j].teamnumber != g_iTeamNumber )
continue; // skip over players in other teams
// If this team is forced to be civilians, just count the number of teammates
if( g_PlayerExtraInfo[j].playerclass != i && !bCivilian )
continue;
iTotal++;
}
char sz[256];
sprintf( sz, m_sPlayersOnTeamString, iTotal );
m_pPlayers[i]->setText( "%s", sz );
// Set the text color to the teamcolor
m_pPlayers[i]->setFgColor( iTeamColors[g_iTeamNumber % iNumberOfTeamColors][0],
iTeamColors[g_iTeamNumber % iNumberOfTeamColors][1],
iTeamColors[g_iTeamNumber % iNumberOfTeamColors][2],
0 );
// set the graphic to be the team pick
for( int team = 0; team < MAX_TEAMS; team++ )
{
// unset all the other images
if( m_pClassImages[team][i] )
{
m_pClassImages[team][i]->setVisible( false );
}
// set the current team image
if( m_pClassImages[g_iTeamNumber - 1][i] != 0 )
{
m_pClassImages[g_iTeamNumber - 1][i]->setVisible( true );
}
else if( m_pClassImages[0][i] )
{
m_pClassImages[0][i]->setVisible( true );
}
}
}
#endif
// If the player already has a class, make the cancel button visible
if( g_iPlayerClass )
{
@ -415,16 +184,7 @@ void CClassMenuPanel::Initialize( void )
void CClassMenuPanel::SetActiveInfo( int iInput )
{
// Remove all the Info panels and bring up the specified one
#ifdef _TFC
for( int i = 0; i <= PC_RANDOM; i++ )
{
m_pButtons[i]->setArmed( false );
m_pClassInfoPanel[i]->setVisible( false );
}
if( iInput > PC_RANDOM || iInput < 0 )
#endif
iInput = 0;
iInput = 0;
m_pButtons[iInput]->setArmed( true );
m_pClassInfoPanel[iInput]->setVisible( true );

View File

@ -304,21 +304,12 @@ int ClassButton::IsNotValid()
return false;
}
// Is it an illegal class?
#ifdef _TFC
if( ( gViewPort->GetValidClasses( 0 ) & sTFValidClassInts[m_iPlayerClass] ) || ( gViewPort->GetValidClasses( g_iTeamNumber ) & sTFValidClassInts[m_iPlayerClass] ) )
return true;
#endif
// Only check current class if they've got autokill on
bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0;
if( bAutoKill )
{
// Is it the player's current class?
if (
#ifdef _TFC
(gViewPort->IsRandomPC() && m_iPlayerClass == PC_RANDOM) ||
#endif
(!gViewPort->IsRandomPC() && (m_iPlayerClass == g_iPlayerClass)) )
return true;
}
@ -539,13 +530,11 @@ void CMenuHandler_StringCommandClassSelect::actionPerformed( Panel *panel )
{
CMenuHandler_StringCommand::actionPerformed( panel );
// THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN
// THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN
// HAVE THE SERVER SAY "SORRY...YOU CAN'T BE THAT CLASS".
#if !defined _TFC
bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0;
if( bAutoKill && g_iPlayerClass != 0 )
gEngfuncs.pfnClientCmd( "kill" );
#endif
}

View File

@ -776,11 +776,6 @@ void ScorePanel::FillGrid()
// Don't show classes if this client hasnt picked a team yet
if ( g_iTeamNumber == 0 )
bShowClass = false;
#ifdef _TFC
// in TFC show all classes in spectator mode
if ( g_iUser1 )
bShowClass = true;
#endif
if (bShowClass)
{
@ -819,21 +814,6 @@ void ScorePanel::FillGrid()
}
*/
break;
#ifdef _TFC
case COLUMN_KILLS:
if (g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber)
sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].frags );
break;
case COLUMN_DEATHS:
if (g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber)
sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].deaths );
break;
case COLUMN_LATENCY:
if (g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber)
sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping );
break;
#else
case COLUMN_KILLS:
sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].frags );
break;
@ -843,7 +823,6 @@ void ScorePanel::FillGrid()
case COLUMN_LATENCY:
sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping );
break;
#endif
default:
break;
}

View File

@ -136,32 +136,6 @@ const char *sTFClassSelection[] =
"civilian",
};
#ifdef _TFC
int iBuildingCosts[] =
{
BUILD_COST_DISPENSER,
BUILD_COST_SENTRYGUN,
BUILD_COST_TELEPORTER
};
// This maps class numbers to the Invalid Class bit.
// This is needed for backwards compatability in maps that were finished before
// all the classes were in TF. Hence the wacky sequence.
int sTFValidClassInts[] =
{
0,
TF_ILL_SCOUT,
TF_ILL_SNIPER,
TF_ILL_SOLDIER,
TF_ILL_DEMOMAN,
TF_ILL_MEDIC,
TF_ILL_HVYWEP,
TF_ILL_PYRO,
TF_ILL_SPY,
TF_ILL_ENGINEER,
TF_ILL_RANDOMPC,
};
#endif
// Get the name of TGA file, based on GameDir
char *GetVGUITGAName( const char *pszName )
@ -784,20 +758,6 @@ int TeamFortressViewport::CreateCommandMenu( const char *menuFile, int direction
else
{
// See if it's a Class
#ifdef _TFC
for( int i = 1; i <= PC_ENGINEER; i++ )
{
if( !strcmp( token, sTFClasses[i] ) )
{
// Save it off
iPlayerClass = i;
// Get the button text
pfile = gEngfuncs.COM_ParseFile( pfile, token );
break;
}
}
#endif
}
// Get the button bound key
@ -946,21 +906,6 @@ CCommandMenu *TeamFortressViewport::CreateDisguiseSubmenu( CommandButton *pButto
CCommandMenu *pMenu = CreateSubMenu( pButton, pParentMenu, iYOffset, iXOffset );
m_pCommandMenus[m_iNumMenus] = pMenu;
m_iNumMenus++;
// create the class choice buttons
#ifdef _TFC
for( int i = PC_SCOUT; i <= PC_ENGINEER; i++ )
{
CommandButton *pDisguiseButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[i] ), 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
char sz[256];
sprintf( sz, "%s %d", commandText, i );
pDisguiseButton->addActionSignal( new CMenuHandler_StringCommand( sz ) );
pMenu->AddButton( pDisguiseButton );
}
#endif
return pMenu;
}
@ -1018,268 +963,7 @@ CommandButton *TeamFortressViewport::CreateCustomButton( char *pButtonText, char
pMenu = CreateSubMenu( pButton, m_pCurrentCommandMenu, iYOffset );
m_pCommandMenus[m_iNumMenus] = pMenu;
m_iNumMenus++;
#ifdef _TFC
for( int i = PC_SCOUT; i <= PC_RANDOM; i++ )
{
char sz[256];
// ChangeClass buttons
CHudTextMessage::LocaliseTextString( sLocalisedClasses[i], sz, 256 );
ClassButton *pClassButton = new ClassButton( i, sz, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y, false );
sprintf( sz, "%s", sTFClassSelection[i] );
pClassButton->addActionSignal( new CMenuHandler_StringCommandClassSelect( sz ) );
pMenu->AddButton( pClassButton );
}
#endif
}
#ifdef _TFC
// Map Briefing
else if( !strcmp( pButtonName, "!MAPBRIEFING" ) )
{
pButton = new CommandButton( pButtonText, 0, BUTTON_SIZE_Y * m_pCurrentCommandMenu->GetNumButtons(), CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_TextWindow( MENU_MAPBRIEFING ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
// Class Descriptions
else if( !strcmp( pButtonName, "!CLASSDESC" ) )
{
pButton = new ClassButton( 0, pButtonText, 0, BUTTON_SIZE_Y * m_pCurrentCommandMenu->GetNumButtons(), CMENU_SIZE_X, BUTTON_SIZE_Y, false );
pButton->addActionSignal( new CMenuHandler_TextWindow( MENU_CLASSHELP ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
else if( !strcmp( pButtonName, "!SERVERINFO" ) )
{
pButton = new ClassButton( 0, pButtonText, 0, BUTTON_SIZE_Y * m_pCurrentCommandMenu->GetNumButtons(), CMENU_SIZE_X, BUTTON_SIZE_Y, false );
pButton->addActionSignal( new CMenuHandler_TextWindow( MENU_INTRO ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
// Spy abilities
else if( !strcmp( pButtonName, "!SPY" ) )
{
pButton = new DisguiseButton( 0, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
}
// Feign
else if( !strcmp( pButtonName, "!FEIGN" ) )
{
pButton = new FeignButton( FALSE, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "feign" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
// Feign Silently
else if( !strcmp( pButtonName, "!FEIGNSILENT" ) )
{
pButton = new FeignButton( FALSE, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "sfeign" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
// Stop Feigning
else if( !strcmp( pButtonName, "!FEIGNSTOP" ) )
{
pButton = new FeignButton( TRUE, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "feign" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
// Disguise
else if( !strcmp( pButtonName, "!DISGUISEENEMY" ) )
{
// Create the disguise enemy button, which active only if there are 2 teams
pButton = new DisguiseButton(DISGUISE_TEAM2, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
CreateDisguiseSubmenu( pButton, m_pCurrentCommandMenu, "disguise_enemy", iYOffset);
}
else if( !strcmp( pButtonName, "!DISGUISEFRIENDLY" ) )
{
// Create the disguise friendly button, which active only if there are 1 or 2 teams
pButton = new DisguiseButton( DISGUISE_TEAM1 | DISGUISE_TEAM2, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
CreateDisguiseSubmenu( pButton, m_pCurrentCommandMenu, "disguise_friendly", iYOffset );
}
else if( !strcmp( pButtonName, "!DISGUISE" ) )
{
// Create the Disguise button
pButton = new DisguiseButton( DISGUISE_TEAM3 | DISGUISE_TEAM4, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
CCommandMenu *pDisguiseMenu = CreateSubMenu( pButton, m_pCurrentCommandMenu, iYOffset );
m_pCommandMenus[m_iNumMenus] = pDisguiseMenu;
m_iNumMenus++;
// Disguise Enemy submenu buttons
for( int i = 1; i <= 4; i++ )
{
// only show the 4th disguise button if we have 4 teams
m_pDisguiseButtons[i] = new DisguiseButton( ( ( i < 4 ) ? DISGUISE_TEAM3 : 0) | DISGUISE_TEAM4, "Disguise", 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
pDisguiseMenu->AddButton( m_pDisguiseButtons[i] );
m_pDisguiseButtons[i]->setParentMenu( pDisguiseMenu );
char sz[256];
sprintf( sz, "disguise %d", i );
CreateDisguiseSubmenu( m_pDisguiseButtons[i], pDisguiseMenu, sz, iYOffset, CMENU_SIZE_X - 1 );
}
}
// Start setting a Detpack
else if( !strcmp( pButtonName, "!DETPACKSTART" ) )
{
// Detpack Submenu
pButton = new DetpackButton( 2, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
// Create the submenu
pMenu = CreateSubMenu( pButton, m_pCurrentCommandMenu, iYOffset );
m_pCommandMenus[m_iNumMenus] = pMenu;
m_iNumMenus++;
// Set detpack buttons
CommandButton *pDetButton;
pDetButton = new CommandButton( m_sDetpackStrings[0], 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
pDetButton->addActionSignal( new CMenuHandler_StringCommand( "detstart 5" ) );
pMenu->AddButton( pDetButton );
pDetButton = new CommandButton( m_sDetpackStrings[1], 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
pDetButton->addActionSignal( new CMenuHandler_StringCommand( "detstart 20" ) );
pMenu->AddButton( pDetButton );
pDetButton = new CommandButton( m_sDetpackStrings[2], 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
pDetButton->addActionSignal( new CMenuHandler_StringCommand( "detstart 50" ) );
pMenu->AddButton( pDetButton );
}
// Stop setting a Detpack
else if( !strcmp( pButtonName, "!DETPACKSTOP" ) )
{
pButton = new DetpackButton( 1, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "detstop" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
// Engineer building
else if( !strcmp( pButtonName, "!BUILD" ) )
{
// only appears if the player is an engineer, and either they have built something or have enough metal to build
pButton = new BuildButton( BUILDSTATE_BASE, 0, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
}
else if( !strcmp( pButtonName, "!BUILDSENTRY" ) )
{
pButton = new BuildButton( BUILDSTATE_CANBUILD, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "build 2" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
else if( !strcmp( pButtonName, "!BUILDDISPENSER" ) )
{
pButton = new BuildButton( BUILDSTATE_CANBUILD, BuildButton::DISPENSER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "build 1" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
else if( !strcmp( pButtonName, "!ROTATESENTRY180" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "rotatesentry180" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
else if( !strcmp( pButtonName, "!ROTATESENTRY" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "rotatesentry" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) );
}
else if( !strcmp( pButtonName, "!DISMANTLEDISPENSER" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::DISPENSER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "dismantle 1" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
else if( !strcmp( pButtonName, "!DISMANTLESENTRY" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "dismantle 2" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
else if( !strcmp( pButtonName, "!DETONATEDISPENSER" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::DISPENSER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "detdispenser" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
else if( !strcmp( pButtonName, "!DETONATESENTRY" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "detsentry" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) );
}
else if ( !strcmp( pButtonName, "!BUILDENTRYTELEPORTER" ) )
{
pButton = new BuildButton( BUILDSTATE_CANBUILD, BuildButton::ENTRY_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y);
pButton->addActionSignal(new CMenuHandler_StringCommand("build 4"));
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) );
}
else if ( !strcmp( pButtonName, "!DISMANTLEENTRYTELEPORTER" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::ENTRY_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y);
pButton->addActionSignal(new CMenuHandler_StringCommand("dismantle 4"));
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) );
}
else if ( !strcmp( pButtonName, "!DETONATEENTRYTELEPORTER" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::ENTRY_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y);
pButton->addActionSignal(new CMenuHandler_StringCommand("detentryteleporter"));
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) );
}
else if ( !strcmp( pButtonName, "!BUILDEXITTELEPORTER" ) )
{
pButton = new BuildButton( BUILDSTATE_CANBUILD, BuildButton::EXIT_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y);
pButton->addActionSignal(new CMenuHandler_StringCommand("build 5"));
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) );
}
else if ( !strcmp( pButtonName, "!DISMANTLEEXITTELEPORTER" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::EXIT_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y);
pButton->addActionSignal(new CMenuHandler_StringCommand("dismantle 5"));
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) );
}
else if ( !strcmp( pButtonName, "!DETONATEEXITTELEPORTER" ) )
{
pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::EXIT_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y);
pButton->addActionSignal(new CMenuHandler_StringCommand("detexitteleporter"));
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
// Stop building
else if( !strcmp( pButtonName, "!BUILDSTOP" ) )
{
pButton = new BuildButton( BUILDSTATE_BUILDING, 0, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y );
pButton->addActionSignal( new CMenuHandler_StringCommand( "build" ) );
// Create an input signal that'll popup the current menu
pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) );
}
#endif
return pButton;
}
@ -1433,22 +1117,8 @@ void TeamFortressViewport::InputPlayerSpecial( void )
if( !m_iInitialized )
return;
#ifdef _TFC
if( g_iPlayerClass == PC_ENGINEER || g_iPlayerClass == PC_SPY )
{
ShowCommandMenu( gViewPort->m_StandardMenu );
if( m_pCurrentCommandMenu )
{
m_pCurrentCommandMenu->KeyInput( '7' );
}
}
else
#endif
{
// if it's any other class, just send the command down to the server
ClientCmd( "_special" );
}
// if it's any other class, just send the command down to the server
ClientCmd( "_special" );
}
// Set the submenu of the Command Menu
@ -1767,51 +1437,6 @@ CMenuPanel *TeamFortressViewport::CreateTextWindow( int iTextToShow )
strncpy( cTitle, m_sMapName, MAX_TITLE_LENGTH );
cTitle[MAX_TITLE_LENGTH - 1] = 0;
}
#ifdef _TFC
else if( iTextToShow == SHOW_CLASSDESC )
{
switch( g_iPlayerClass )
{
case PC_SCOUT: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_scout" );
CHudTextMessage::LocaliseTextString( "#Title_scout", cTitle, MAX_TITLE_LENGTH ); break;
case PC_SNIPER: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_sniper" );
CHudTextMessage::LocaliseTextString( "#Title_sniper", cTitle, MAX_TITLE_LENGTH ); break;
case PC_SOLDIER: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_soldier" );
CHudTextMessage::LocaliseTextString( "#Title_soldier", cTitle, MAX_TITLE_LENGTH ); break;
case PC_DEMOMAN: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_demoman" );
CHudTextMessage::LocaliseTextString( "#Title_demoman", cTitle, MAX_TITLE_LENGTH ); break;
case PC_MEDIC: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_medic" );
CHudTextMessage::LocaliseTextString( "#Title_medic", cTitle, MAX_TITLE_LENGTH ); break;
case PC_HVYWEAP: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_hwguy" );
CHudTextMessage::LocaliseTextString( "#Title_hwguy", cTitle, MAX_TITLE_LENGTH ); break;
case PC_PYRO: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_pyro" );
CHudTextMessage::LocaliseTextString( "#Title_pyro", cTitle, MAX_TITLE_LENGTH ); break;
case PC_SPY: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_spy" );
CHudTextMessage::LocaliseTextString( "#Title_spy", cTitle, MAX_TITLE_LENGTH ); break;
case PC_ENGINEER: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_engineer" );
CHudTextMessage::LocaliseTextString( "#Title_engineer", cTitle, MAX_TITLE_LENGTH ); break;
case PC_CIVILIAN: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_civilian" );
CHudTextMessage::LocaliseTextString( "#Title_civilian", cTitle, MAX_TITLE_LENGTH ); break;
default:
return NULL;
}
if( g_iPlayerClass == PC_CIVILIAN )
{
strcpy(sz, "classes/long_civilian.txt");
}
else
{
sprintf( sz, "classes/long_%s.txt", sTFClassSelection[g_iPlayerClass] );
}
char *pfile = (char*)gEngfuncs.COM_LoadFile( sz, 5, NULL );
if( pfile )
{
cText = pfile;
}
}
#endif
else if( iTextToShow == SHOW_SPECHELP )
{
CHudTextMessage::LocaliseTextString( "#Spec_Help_Title", cTitle, MAX_TITLE_LENGTH );
@ -2534,100 +2159,14 @@ int TeamFortressViewport::MsgFunc_AllowSpec( const char *pszName, int iSize, voi
return 1;
}
#if defined( _TFC )
const Vector& GetTeamColor( int team_no );
extern globalvars_t *gpGlobals;
#endif
// used to reset the player's screen immediately
int TeamFortressViewport::MsgFunc_ResetFade( const char *pszName, int iSize, void *pbuf )
{
#if defined( _TFC )
if ( !gpGlobals )
return 0;
screenfade_t sf;
gEngfuncs.pfnGetScreenFade( &sf );
sf.fader = 0;
sf.fadeg = 0;
sf.fadeb = 0;
sf.fadealpha = 0;
sf.fadeEnd = 0.1;
sf.fadeReset = 0.0;
sf.fadeSpeed = 0.0;
sf.fadeFlags = FFADE_IN;
sf.fadeReset += gpGlobals->time;
sf.fadeEnd += sf.fadeReset;
gEngfuncs.pfnSetScreenFade( &sf );
#endif
return 1;
}
// used to fade a player's screen out/in when they're spectating someone who is teleported
int TeamFortressViewport::MsgFunc_SpecFade( const char *pszName, int iSize, void *pbuf )
{
#if defined( _TFC )
BEGIN_READ( pbuf, iSize );
int iIndex = READ_BYTE();
// we're in first-person spectator mode (...not first-person in the PIP)
if ( g_iUser1 == OBS_IN_EYE )
{
// this is the person we're watching
if ( g_iUser2 == iIndex )
{
int iFade = READ_BYTE();
int iTeam = READ_BYTE();
float flTime = ( (float)READ_SHORT() / 100.0 );
int iAlpha = READ_BYTE();
Vector team = GetTeamColor( iTeam );
screenfade_t sf;
gEngfuncs.pfnGetScreenFade( &sf );
sf.fader = team[0];
sf.fadeg = team[1];
sf.fadeb = team[2];
sf.fadealpha = iAlpha;
sf.fadeEnd = flTime;
sf.fadeReset = 0.0;
sf.fadeSpeed = 0.0;
if ( iFade == BUILD_TELEPORTER_FADE_OUT )
{
sf.fadeFlags = FFADE_OUT;
sf.fadeReset = flTime;
if ( sf.fadeEnd )
sf.fadeSpeed = -(float)sf.fadealpha / sf.fadeEnd;
sf.fadeTotalEnd = sf.fadeEnd += gpGlobals->time;
sf.fadeReset += sf.fadeEnd;
}
else
{
sf.fadeFlags = FFADE_IN;
if ( sf.fadeEnd )
sf.fadeSpeed = (float)sf.fadealpha / sf.fadeEnd;
sf.fadeReset += gpGlobals->time;
sf.fadeEnd += sf.fadeReset;
}
gEngfuncs.pfnSetScreenFade( &sf );
}
}
#endif
return 1;
}

View File

@ -32,9 +32,6 @@
#include "vgui_SchemeManager.h"
#define TF_DEFS_ONLY
#ifdef _TFC
#include "../tfc/tf_defs.h"
#else
#define PC_LASTCLASS 10
#define PC_UNDEFINED 0
#define MENU_DEFAULT 1
@ -46,7 +43,6 @@
#define MENU_CLASSHELP2 7
#define MENU_REPEATHELP 8
#define MENU_SPECHELP 9
#endif
using namespace vgui;
class Cursor;
@ -1031,12 +1027,6 @@ public:
virtual int IsNotValid()
{
// Only visible for spies
#ifdef _TFC
if( g_iPlayerClass != PC_SPY )
return true;
#endif
if( m_iFeignState == gViewPort->GetIsFeigning() )
return false;
@ -1079,12 +1069,6 @@ public:
virtual int IsNotValid()
{
#ifdef _TFC
// Only visible for spies
if( g_iPlayerClass != PC_SPY )
return true;
#endif
// if it's not tied to a specific team, then always show (for spies)
if( !m_iValidTeamsBits )
return false;
@ -1110,12 +1094,6 @@ public:
virtual int IsNotValid()
{
#ifdef _TFC
// Only visible for demomen
if( g_iPlayerClass != PC_DEMOMAN )
return true;
#endif
if( m_iDetpackState == gViewPort->GetIsSettingDetpack() )
return false;
@ -1152,64 +1130,6 @@ public:
virtual int IsNotValid()
{
#ifdef _TFC
// Only visible for engineers
if( g_iPlayerClass != PC_ENGINEER )
return true;
// If this isn't set, it's only active when they're not building
if( m_iBuildState & BUILDSTATE_BUILDING )
{
// Make sure the player's building
if( !( gViewPort->GetBuildState() & BS_BUILDING ) )
return true;
}
else
{
// Make sure the player's not building
if( gViewPort->GetBuildState() & BS_BUILDING )
return true;
}
if( m_iBuildState & BUILDSTATE_BASE )
{
// Only appear if we've got enough metal to build something, or something already built
if ( gViewPort->GetBuildState() & (BS_HAS_SENTRYGUN | BS_HAS_DISPENSER | BS_CANB_SENTRYGUN | BS_CANB_DISPENSER | BS_HAS_ENTRY_TELEPORTER | BS_HAS_EXIT_TELEPORTER | BS_CANB_ENTRY_TELEPORTER | BS_CANB_EXIT_TELEPORTER) )
return false;
return true;
}
// Must have a building
if( m_iBuildState & BUILDSTATE_HASBUILDING )
{
if( m_iBuildData == BuildButton::DISPENSER && !( gViewPort->GetBuildState() & BS_HAS_DISPENSER ) )
return true;
if( m_iBuildData == BuildButton::SENTRYGUN && !( gViewPort->GetBuildState() & BS_HAS_SENTRYGUN ) )
return true;
if ( m_iBuildData == BuildButton::ENTRY_TELEPORTER && !(gViewPort->GetBuildState() & BS_HAS_ENTRY_TELEPORTER) )
return true;
if ( m_iBuildData == BuildButton::EXIT_TELEPORTER && !(gViewPort->GetBuildState() & BS_HAS_EXIT_TELEPORTER) )
return true;
}
// Can build something
if( m_iBuildState & BUILDSTATE_CANBUILD )
{
// Make sure they've got the ammo and don't have one already
if( m_iBuildData == BuildButton::DISPENSER && ( gViewPort->GetBuildState() & BS_CANB_DISPENSER ) )
return false;
if( m_iBuildData == BuildButton::SENTRYGUN && ( gViewPort->GetBuildState() & BS_CANB_SENTRYGUN ) )
return false;
if ( m_iBuildData == BuildButton::ENTRY_TELEPORTER && (gViewPort->GetBuildState() & BS_CANB_ENTRY_TELEPORTER) )
return false;
if ( m_iBuildData == BuildButton::EXIT_TELEPORTER && (gViewPort->GetBuildState() & BS_CANB_EXIT_TELEPORTER) )
return false;
return true;
}
#endif
return false;
}
};

View File

@ -5,16 +5,7 @@
// $NoKeywords: $
//=============================================================================
// There are hud.h's coming out of the woodwork so this ensures that we get the right one.
#if defined(THREEWAVE) || defined(DMC_BUILD)
#include "../dmc/cl_dll/hud.h"
#elif defined(CSTRIKE)
#include "../cstrike/cl_dll/hud.h"
#elif defined(DOD)
#include "../dod/cl_dll/hud.h"
#else
#include "hud.h"
#endif
#include "hud.h"
#include "cl_util.h"
#include <assert.h>