|
28 | 28 | extern ConVar rd_legacy_ui; |
29 | 29 | #ifdef CLIENT_DLL |
30 | 30 | extern std::vector<bool> g_bShouldTracePlayer; |
| 31 | +extern ConVar cl_trace_player_max_targets; |
31 | 32 | #endif |
32 | 33 |
|
33 | 34 | using namespace BaseModUI; |
@@ -102,15 +103,28 @@ CNB_Lobby_Row::CNB_Lobby_Row( vgui::Panel *parent, const char *name ) : BaseClas |
102 | 103 | m_pXPBar->m_flBorder = 1.5f; |
103 | 104 | m_nLobbySlot = 0; |
104 | 105 |
|
| 106 | + color32 lightblue; |
| 107 | + lightblue.r = 66; |
| 108 | + lightblue.g = 142; |
| 109 | + lightblue.b = 192; |
| 110 | + lightblue.a = 255; |
| 111 | + |
105 | 112 | // Create the TraceMe button |
106 | 113 | m_pTraceMeButton = new CBitmapButton( this, "TraceMeButton", ""); |
107 | | - m_pTraceMeButton->AddActionSignalTarget( this ); |
108 | | - m_pTraceMeButton->SetCommand( "TraceMePressed" ); |
| 114 | + m_pTraceMeButton->AddActionSignalTarget(this); |
| 115 | + m_pTraceMeButton->SetCommand("TraceMePressed"); |
| 116 | + m_pTraceMeButton->SetImage(CBitmapButton::BUTTON_ENABLED, "vgui/briefing/trace_me_icon_on", lightblue); |
| 117 | + m_pTraceMeButton->SetImage(CBitmapButton::BUTTON_PRESSED, "vgui/briefing/trace_me_icon_pressed", lightblue); |
| 118 | + m_pTraceMeButton->SetImage(CBitmapButton::BUTTON_ENABLED_MOUSE_OVER, "vgui/briefing/trace_me_icon_mouse_over", lightblue); |
109 | 119 |
|
110 | | - // Create and initialize TracePlayerButton |
| 120 | + // Create the TracePlayerButton |
111 | 121 | m_pTracePlayerButton = new CBitmapButton( this, "TracePlayerButton", "" ); |
112 | 122 | m_pTracePlayerButton->AddActionSignalTarget( this ); |
113 | 123 | m_pTracePlayerButton->SetCommand( "TracePlayerPressed" ); |
| 124 | + m_pTracePlayerButton->SetImage(CBitmapButton::BUTTON_ENABLED, "vgui/briefing/trace_player_icon_off", lightblue); |
| 125 | + m_pTracePlayerButton->SetImage(CBitmapButton::BUTTON_PRESSED, "vgui/briefing/trace_player_icon_pressed", lightblue); |
| 126 | + m_pTracePlayerButton->SetImage(CBitmapButton::BUTTON_ENABLED_MOUSE_OVER, "vgui/briefing/trace_player_icon_mouse_over", lightblue); |
| 127 | + |
114 | 128 |
|
115 | 129 | GetControllerFocus()->AddToFocusList( m_pPortraitButton ); |
116 | 130 | GetControllerFocus()->AddToFocusList( m_pWeaponButton0 ); |
@@ -145,6 +159,15 @@ void CNB_Lobby_Row::ApplySchemeSettings( vgui::IScheme *pScheme ) |
145 | 159 | } |
146 | 160 | m_szLastPortraitImage[ 0 ] = 0; |
147 | 161 | m_lastSteamID.Set( 0, k_EUniverseInvalid, k_EAccountTypeInvalid ); |
| 162 | + |
| 163 | + // place the button |
| 164 | + m_pTraceMeButton->SetPos(XRES(4), YRES(35)); |
| 165 | + m_pTracePlayerButton->SetPos(XRES(4), YRES(35)); |
| 166 | + // set width and height |
| 167 | + m_pTraceMeButton->SetWide(XRES(12)); |
| 168 | + m_pTraceMeButton->SetTall(YRES(12)); |
| 169 | + m_pTracePlayerButton->SetWide(XRES(12)); |
| 170 | + m_pTracePlayerButton->SetTall(YRES(12)); |
148 | 171 | } |
149 | 172 |
|
150 | 173 | void CNB_Lobby_Row::PerformLayout() |
@@ -446,16 +469,6 @@ void CNB_Lobby_Row::UpdateDetails() |
446 | 469 | pSilhouette->SetVisible( false ); |
447 | 470 | } |
448 | 471 | } |
449 | | - |
450 | | - // Set the images for the TraceMe button |
451 | | - const char* szTraceMeButtonEnabled = "vgui/swarm/Emotes/EmoteSmile"; |
452 | | - const char* szTraceMeButtonDisabled = "vgui/swarm/Emotes/EmoteStop"; |
453 | | - const char* szTraceMeButtonPressed = "vgui/swarm/Emotes/EmoteAmmo"; |
454 | | - const char* szTraceMeButtonMouseOver = "vgui/swarm/Emotes/EmoteMedic"; |
455 | | - m_pTraceMeButton->SetImage(CBitmapButton::BUTTON_ENABLED, szTraceMeButtonEnabled, lightblue); |
456 | | - m_pTraceMeButton->SetImage(CBitmapButton::BUTTON_DISABLED, szTraceMeButtonDisabled, lightblue); |
457 | | - m_pTraceMeButton->SetImage(CBitmapButton::BUTTON_PRESSED, szTraceMeButtonPressed, white); |
458 | | - m_pTraceMeButton->SetImage(CBitmapButton::BUTTON_ENABLED_MOUSE_OVER, szTraceMeButtonMouseOver, white); |
459 | 472 | } |
460 | 473 |
|
461 | 474 | void CNB_Lobby_Row::CheckTooltip( CNB_Lobby_Tooltip *pTooltip ) |
@@ -649,10 +662,18 @@ void CNB_Lobby_Row::TraceMePressed() |
649 | 662 | return; // Invalid player index |
650 | 663 | } |
651 | 664 |
|
652 | | - char cmd[128]; |
653 | | - Q_snprintf(cmd, sizeof(cmd), "rd_lobby_suggest_trace_player %d", localPlayerIndex); |
654 | | - // Send a message in chat to all other players to suggest them to trace this player |
655 | | - engine->ClientCmd_Unrestricted(cmd); |
| 665 | + if (lastTraceMePressedTime < 0 || (lastTraceMePressedTime + 30.0) <= gpGlobals->curtime) |
| 666 | + { |
| 667 | + lastTraceMePressedTime = gpGlobals->curtime; // Prevent spamming the command |
| 668 | + char cmd[128]; |
| 669 | + Q_snprintf(cmd, sizeof(cmd), "rd_lobby_suggest_trace_player %d", localPlayerIndex); |
| 670 | + // Send a message in chat to all other players to suggest them to trace this player |
| 671 | + engine->ClientCmd_Unrestricted(cmd); |
| 672 | + } |
| 673 | + else |
| 674 | + { |
| 675 | + ClientPrint(CBasePlayer::GetLocalPlayer(), HUD_PRINTTALK, "asw_trace_me_cooling_down"); |
| 676 | + } |
656 | 677 | } |
657 | 678 | } |
658 | 679 |
|
@@ -685,5 +706,6 @@ void CNB_Lobby_Row::TracePlayerPressed() |
685 | 706 | } |
686 | 707 | // flip the trace state for this player |
687 | 708 | g_bShouldTracePlayer[playerIndex] = !g_bShouldTracePlayer[playerIndex]; |
| 709 | + m_pTracePlayerButton->SetImage(CBitmapButton::BUTTON_ENABLED, g_bShouldTracePlayer[playerIndex] ? "vgui/briefing/trace_player_icon_on" : "vgui/briefing/trace_player_icon_off", color32{ 66, 142, 192, 255 }); |
688 | 710 | Msg("Trace player %d : %s\n", playerIndex, g_bShouldTracePlayer[playerIndex] ? "true" : "false"); |
689 | 711 | } |
0 commit comments