Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 73 additions & 28 deletions src/game/client/tf/tf_hud_tournament.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,44 @@ void CHudTournament::PreparePanel( void )
pszLabelText = "Tournament_Instructions_Waiting";
}

SetDialogVariable( "readylabel", g_pVGuiLocalize->Find( pszLabelText ) );
if ( pszLabelText == "Tournament_Instructions_Ready" )
{
// Lets get the currently bound ready up button and display it to the user
wchar_t wszLocalized[100];
wchar_t wszKey[25];
const char* key = engine->Key_LookupBinding("player_ready_toggle");
if (!key)
{
key = "< not bound >";
}

g_pVGuiLocalize->ConvertANSIToUnicode(key, wszKey, sizeof(wszKey));
g_pVGuiLocalize->ConstructString_safe(wszLocalized, g_pVGuiLocalize->Find( "Tournament_Instructions_Ready" ), 1, wszKey);
SetDialogVariable("readylabel", wszLocalized);
}
else
{
SetDialogVariable("readylabel", g_pVGuiLocalize->Find(pszLabelText));
}

SetDialogVariable( "tournamentstatelabel", g_pVGuiLocalize->Find( "Tournament_WaitingForTeam" ) );
SetPlayerPanelsVisible( true );
m_pModeImage->SetVisible( m_bCompetitiveMode );
}
else
{
SetDialogVariable( "readylabel", g_pVGuiLocalize->Find( "Tournament_Instructions" ) );
// Lets get the currently bound ready up button and display it to the user
wchar_t wszLocalized[100];
wchar_t wszKey[25];
const char* key = engine->Key_LookupBinding("player_ready_toggle");
if (!key)
{
key = "< not bound >";
}

g_pVGuiLocalize->ConvertANSIToUnicode(key, wszKey, sizeof(wszKey));
g_pVGuiLocalize->ConstructString_safe( wszLocalized, g_pVGuiLocalize->Find( "Tournament_Instructions" ), 1, wszKey );
SetDialogVariable("readylabel", wszLocalized);
SetDialogVariable( "tournamentstatelabel", g_pVGuiLocalize->Find( "Tournament_WaitingForTeams" ) );
SetPlayerPanelsVisible( false );
m_pModeImage->SetVisible( false );
Expand Down Expand Up @@ -357,7 +387,18 @@ void CHudTournament::PreparePanel( void )
}
else
{
SetDialogVariable( "readylabel", g_pVGuiLocalize->Find( "Tournament_Instructions_Ready" ) );
// Lets get the currently bound ready up button and display it to the user
wchar_t wszLocalized[100];
wchar_t wszKey[25];
const char* key = engine->Key_LookupBinding("player_ready_toggle");
if (!key)
{
key = "< not bound >";
}

g_pVGuiLocalize->ConvertANSIToUnicode(key, wszKey, sizeof(wszKey));
g_pVGuiLocalize->ConstructString_safe(wszLocalized, g_pVGuiLocalize->Find( "Tournament_Instructions_Ready" ), 1, wszKey);
SetDialogVariable("readylabel", wszLocalized);
}
}
else
Expand Down Expand Up @@ -1090,40 +1131,44 @@ void CHudTournamentSetup::OnCommand( const char *command )
}
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudTournamentSetup::ToggleState( ButtonCode_t code )
void CHudTournamentSetup::TogglePlayerReadiness()
{
if ( !IsVisible() )
return false;
if (!IsVisible())
return;

if ( !g_TF_PR )
return false;
if (!g_TF_PR)
return;

if ( code == KEY_F4 || code == STEAMCONTROLLER_F4 )
if (TFGameRules() && TFGameRules()->UsePlayerReadyStatusMode())
{
if ( TFGameRules() && TFGameRules()->UsePlayerReadyStatusMode() )
int nReady = (TFGameRules()->IsPlayerReady(GetLocalPlayerIndex())) ? 0 : 1;
char szCommand[64];
Q_snprintf(szCommand, sizeof(szCommand), "tournament_player_readystate %d", nReady);
engine->ClientCmd_Unrestricted(szCommand);
}
else
{
if (IsMouseInputEnabled())
{
int nReady = ( TFGameRules()->IsPlayerReady( GetLocalPlayerIndex() ) ) ? 0 : 1;
char szCommand[64];
Q_snprintf( szCommand, sizeof( szCommand ), "tournament_player_readystate %d", nReady );
engine->ClientCmd_Unrestricted( szCommand );
DisableInput();
}
else
{
if ( IsMouseInputEnabled() )
{
DisableInput();
return true;
}
else
{
EnableInput();
return true;
}
EnableInput();
}
}
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudTournamentSetup::ToggleState( ButtonCode_t code )
{
if ( !IsVisible() )
return false;

if ( !g_TF_PR )
return false;

if ( IsMouseInputEnabled() )
{
Expand Down Expand Up @@ -1590,7 +1635,7 @@ CON_COMMAND( player_ready_toggle, "Toggle player ready state" )
CHudTournamentSetup *pTournamentPanel = dynamic_cast< CHudTournamentSetup* >( GET_HUDELEMENT( CHudTournamentSetup ) );
if ( pTournamentPanel )
{
pTournamentPanel->ToggleState( KEY_F4 );
pTournamentPanel->TogglePlayerReadiness();
}
}
}
1 change: 1 addition & 0 deletions src/game/client/tf/tf_hud_tournament.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class CHudTournamentSetup : public CHudElement, public EditablePanel
void DisableInput( void );
bool ToggleState( ButtonCode_t code );
virtual void OnCommand( const char *command );
void TogglePlayerReadiness( void );

virtual void OnKeyCodeTyped(vgui::KeyCode code)
{
Expand Down