Skip to content

Commit 3e15d19

Browse files
committed
menu fixes
1 parent 8caf7d8 commit 3e15d19

5 files changed

Lines changed: 81 additions & 61 deletions

File tree

src/game/client/tf/clientmode_tf.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "client_virtualreality.h"
7979

8080
#include "econ_gcmessages.h"
81+
#include "gamestate/gamestate.h"
8182

8283
#if defined( _X360 )
8384
#include "tf_clientscoreboard.h"
@@ -395,6 +396,7 @@ ClientModeTFNormal::ClientModeTFNormal()
395396
m_bInitializedHudAspect = false;
396397

397398
m_flLastSlaughterTime = -1.0f;
399+
m_flCurMaxFPS = -1.0f;
398400

399401
#if defined( _X360 )
400402
m_pScoreboard = NULL;
@@ -1544,8 +1546,13 @@ void ClientModeTFNormal::FireGameEvent( IGameEvent *event )
15441546
{
15451547
m_eConnectState = k_eConnectState_Connecting;
15461548
m_bPendingRichPresenceUpdate = true;
1549+
// TODO(mcoms): test out always restricting info panel
1550+
#if 0
15471551
const char *pchSource = event->GetString( "source" );
15481552
m_bRestrictInfoPanel = pchSource && ( FStrEq( "matchmaking", pchSource ) || !Q_strncmp( pchSource, "quickplay_", 10 ) );
1553+
#else
1554+
m_bRestrictInfoPanel = true;
1555+
#endif
15491556

15501557
m_bInfoPanelShown = false;
15511558
}
@@ -1977,6 +1984,12 @@ void ClientModeTFNormal::Update()
19771984
UpdateSteamRichPresence();
19781985
}
19791986

1987+
if ( m_eLastConnectState != m_eConnectState )
1988+
{
1989+
OnConnectStateChanged();
1990+
m_eLastConnectState = m_eConnectState;
1991+
}
1992+
19801993
TFModalStack()->Update();
19811994

19821995
NotificationQueue_Update();
@@ -2209,6 +2222,47 @@ bool ClientModeTFNormal::IsTauntSelectPanelVisible() const
22092222
return m_pMenuTauntSelection && m_pMenuTauntSelection->IsVisible();
22102223
}
22112224

2225+
//----------------------------------------------------------------------------
2226+
void ClientModeTFNormal::OnConnectStateChanged()
2227+
{
2228+
static ConVarRef fps_max( "fps_max" );
2229+
static ConVarRef ui_fps_max( "ui_fps_max" );
2230+
2231+
switch ( m_eConnectState )
2232+
{
2233+
case k_eConnectState_Connecting:
2234+
{
2235+
if ( m_flCurMaxFPS < 0.0f )
2236+
{
2237+
m_flCurMaxFPS = fps_max.GetFloat();
2238+
}
2239+
// while loading, keep it at our lowest
2240+
fps_max.SetValue( 30.0f );
2241+
break;
2242+
}
2243+
case k_eConnectState_Connected:
2244+
{
2245+
// after loading, restore it.
2246+
Assert( m_flCurMaxFPS >= 0.0f );
2247+
fps_max.SetValue( m_flCurMaxFPS >= 0.0f ? m_flCurMaxFPS : 1000.0f );
2248+
m_flCurMaxFPS = -1.0f;
2249+
break;
2250+
}
2251+
default:
2252+
{
2253+
if ( m_flCurMaxFPS < 0.0f )
2254+
{
2255+
m_flCurMaxFPS = fps_max.GetFloat();
2256+
}
2257+
// if not in game, set fps_max to UI mode.
2258+
fps_max.SetValue( ui_fps_max.GetFloat() );
2259+
break;
2260+
}
2261+
}
2262+
2263+
GetGameStateManager()->QueueEvent( "ingame", m_eConnectState == k_eConnectState_Connected ? "1" : "0" );
2264+
}
2265+
22122266
//----------------------------------------------------------------------------
22132267
void ClientModeTFNormal::UpdateSteamRichPresence() const
22142268
{

src/game/client/tf/clientmode_tf.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ DECLARE_CLASS( ClientModeTFNormal, ClientModeShared );
9292
bool IsSpyDisguiseVisible() const;
9393
bool IsUpgradePanelVisible() const;
9494
bool IsTauntSelectPanelVisible() const;
95+
96+
void OnConnectStateChanged();
9597

9698
void UpdateSteamRichPresence() const;
9799
// Given a client state, match group loc token and pretty map name, build a localized status line.
@@ -141,18 +143,23 @@ DECLARE_CLASS( ClientModeTFNormal, ClientModeShared );
141143

142144
bool m_bInitializedHudAspect;
143145

144-
enum EConnectState {
146+
enum EConnectState
147+
{
148+
k_eConnectState_Uninitialized,
145149
k_eConnectState_Disconnected,
146150
k_eConnectState_Connecting,
147151
k_eConnectState_Connected,
148152
};
149-
EConnectState m_eConnectState = k_eConnectState_Disconnected;
153+
EConnectState m_eConnectState = k_eConnectState_Disconnected;
154+
EConnectState m_eLastConnectState = k_eConnectState_Uninitialized;
150155
// Valid only when m_eConnectState >= k_eConnectState_Connected
151156
// This is the base name of a map, and doesn't include workshop decorations/path/etc.
152157
char m_szMapBaseName[MAX_MAP_NAME] = { 0 };
153158

154159
float m_flNextAllowedHighFiveHintTime;
155160

161+
float m_flCurMaxFPS = -1.0f;
162+
156163
// When game events should trigger updates, we want to let all other systems think first (e.g. partyclient) as their
157164
// state is looked at by the update loop. Setting this triggers an update on next think.
158165
bool m_bPendingRichPresenceUpdate = false;

src/game/client/tf/tf_hud_mainmenuoverride.cpp

Lines changed: 12 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ CHudMainMenuOverride::CHudMainMenuOverride( IViewPort *pViewPort ) : BaseClass(
192192
m_flPlayMusicTime = -1.0f;
193193
m_iPlayMusicFrame = 0;
194194

195-
m_bInGame = false;
196-
m_bIsConnectedOnly = true; // start true so we go to false
197-
m_flCurMaxFPS = -1.0f;
198-
199195
m_iCharacterImageIdx = -1;
200196

201197
m_pCharacterModelPanel = NULL;
@@ -350,19 +346,23 @@ void CHudMainMenuOverride::OnTick()
350346
{
351347
if ( m_pMainMenuWebUi )
352348
{
353-
const bool bShouldWebUiShow = bInGame ? enginevgui->IsGameUIVisible() : !bIsConnected;
349+
const bool bShouldWebUiShow = ( bInGame && !bBackgroundLevel ) ? enginevgui->IsGameUIVisible() : ( !bIsConnected || bBackgroundLevel );
350+
351+
if ( GetGameStateManager()->IsReady() )
352+
{
353+
m_pMainMenuWebUi->LoadInteractivePanel();
354+
}
354355

355356
if ( m_pMainMenuWebUi->IsVisible() != bShouldWebUiShow )
356357
{
357-
if ( !bShouldWebUiShow )
358-
{
359-
GetGameStateManager()->QueueEvent( "closedmenu", "" );
360-
}
361-
else if ( GetGameStateManager()->IsReady() )
358+
if ( GetGameStateManager()->IsReady() )
362359
{
363-
m_pMainMenuWebUi->LoadInteractivePanel();
360+
if ( !bShouldWebUiShow )
361+
{
362+
GetGameStateManager()->QueueEvent( "closedmenu", "" );
363+
}
364+
m_pMainMenuWebUi->SetVisible( bShouldWebUiShow );
364365
}
365-
m_pMainMenuWebUi->SetVisible( bShouldWebUiShow );
366366
}
367367
}
368368
}
@@ -377,8 +377,6 @@ void CHudMainMenuOverride::OnTick()
377377
engine->ExecuteClientCmd( CFmtStr( "connect %s -%s\n", szConnectAdr, "ConnectStringOnCommandline" ) );
378378
}
379379
}
380-
381-
382380
}
383381

384382
//-----------------------------------------------------------------------------
@@ -1448,47 +1446,6 @@ void CHudMainMenuOverride::OnUpdateMenu( void )
14481446
}
14491447
}
14501448

1451-
static ConVarRef fps_max("fps_max");
1452-
static ConVarRef ui_fps_max("ui_fps_max");
1453-
if ( m_bInGame != ( bInGame && bIsConnected ) )
1454-
{
1455-
m_bInGame = bInGame;
1456-
GetGameStateManager()->QueueEvent( "ingame", m_bInGame ? "1" : "0" );
1457-
1458-
if ( m_bInGame )
1459-
{
1460-
// after loading, restore it.
1461-
fps_max.SetValue( m_flCurMaxFPS >= 0.0f ? m_flCurMaxFPS : 1000.0f );
1462-
m_flCurMaxFPS = -1.0f;
1463-
}
1464-
}
1465-
1466-
if ( m_bIsConnectedOnly != ( !bInGame && bIsConnected ) )
1467-
{
1468-
m_bIsConnectedOnly = ( !bInGame && bIsConnected );
1469-
if ( m_bIsConnectedOnly )
1470-
{
1471-
if ( m_flCurMaxFPS < 0.0f )
1472-
{
1473-
m_flCurMaxFPS = fps_max.GetFloat();
1474-
}
1475-
// while loading, keep it at our lowest
1476-
fps_max.SetValue( 30.0f );
1477-
}
1478-
// TODO(mcoms): ui_fps_max
1479-
#if 0
1480-
else
1481-
{
1482-
if ( m_flCurMaxFPS < 0.0f )
1483-
{
1484-
m_flCurMaxFPS = fps_max.GetFloat();
1485-
}
1486-
// if not in game, set fps_max to UI mode.
1487-
fps_max.SetValue( ui_fps_max.GetFloat() );
1488-
}
1489-
#endif
1490-
}
1491-
14921449
// Position the entries
14931450
FOR_EACH_VEC( m_pMMButtonEntries, i )
14941451
{

src/game/client/tf/tf_hud_mainmenuoverride.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,6 @@ class CHudMainMenuOverride : public vgui::EditablePanel, public IViewPortPanel,
201201
float m_flPlayMusicTime;
202202
int32 m_iPlayMusicFrame;
203203

204-
bool m_bInGame;
205-
bool m_bIsConnectedOnly;
206-
float m_flCurMaxFPS;
207-
208204
CInteractiveWebPanel* m_pMainMenuWebUi;
209205

210206
int m_MainMenuWebUiZIndex;

src/game/shared/gamestate/gamestate.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ class CHTTPServerThread : public CThread
212212
{
213213
// should never happen.
214214
Assert( 0 );
215+
DevMsg( "connected clients empty!\n" );
215216
m_connectedClients.push_back( &conn );
216217
}
217218
int64_t clientId = GetClientId( conn );
@@ -220,6 +221,7 @@ class CHTTPServerThread : public CThread
220221
// immediately send back a message for closing
221222
crow::json::wvalue resp;
222223
resp["i"] = id;
224+
DevMsg( "ack: disconnect\n" );
223225
conn.send_text( resp.dump() );
224226
m_iPrivilegedClientId = 0;
225227
return;
@@ -229,6 +231,7 @@ class CHTTPServerThread : public CThread
229231
// immediately send back a message for subscribing
230232
crow::json::wvalue resp;
231233
resp["i"] = id;
234+
DevMsg( "ack: subscribe\n" );
232235
conn.send_text( resp.dump() );
233236
if ( m_iPrivilegedClientId != clientId )
234237
{
@@ -242,6 +245,7 @@ class CHTTPServerThread : public CThread
242245
// immediately send back a message for unsubscribing
243246
crow::json::wvalue resp;
244247
resp["i"] = id;
248+
DevMsg( "ack: unsubscribe\n" );
245249
conn.send_text( resp.dump() );
246250
m_SubscribedClientIds.erase( clientId );
247251
if ( m_SubscribedClientIds.size() < 1 )
@@ -310,6 +314,7 @@ class CHTTPServerThread : public CThread
310314
{
311315
if ( conn )
312316
{
317+
DevMsg( "ret(%d): %s\n", pReturn->m_iRpcId, pReturn->m_strValue );
313318
conn->send_text( data.dump() );
314319
}
315320
}
@@ -343,6 +348,7 @@ class CHTTPServerThread : public CThread
343348
int64_t clientId = GetClientId( *conn );
344349
if ( ( bUnprivileged || m_iPrivilegedClientId == clientId ) && ( !bNeedsSubscription || m_SubscribedClientIds.find(clientId) != m_SubscribedClientIds.end() ) )
345350
{
351+
DevMsg( "send: %s(%s)\n", pEvent->m_strEvent.c_str(), pEvent->m_strParams.c_str() );
346352
conn->send_text( data.dump() );
347353
}
348354
}

0 commit comments

Comments
 (0)