diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index 101e4b1f50..cef5fabf49 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -5,7 +5,7 @@ #include "binds.h" const int CBinds::s_aaDefaultBindKeys[][2] = { - {KEY_F1, 0}, {KEY_F2, 0}, {KEY_TAB, 0}, {'e', 0}, {'u', 0}, {KEY_F10, 0}, {'s', CBinds::MODIFIER_CTRL}, + {KEY_F1, 0}, {KEY_F2, 0}, {KEY_TAB, 0}, {'w', 0}, {'e', 0}, {'u', 0}, {KEY_F10, 0}, {'s', CBinds::MODIFIER_CTRL}, {'a', 0}, {'d', 0}, {KEY_SPACE, 0}, {KEY_MOUSE_1, 0}, {KEY_MOUSE_2, 0}, {KEY_LSHIFT, 0}, {KEY_RSHIFT, 0}, {KEY_RIGHT, 0}, {KEY_LEFT, 0}, {'1', 0}, {'2', 0}, {'3', 0}, {'4', 0}, {'5', 0}, @@ -15,7 +15,7 @@ const int CBinds::s_aaDefaultBindKeys[][2] = { {'r', 0}, }; const char CBinds::s_aaDefaultBindValues[][32] = { - "toggle_local_console", "toggle_remote_console", "+scoreboard", "+stats", "+show_chat", "screenshot", "snd_toggle", + "toggle_local_console", "toggle_remote_console", "+scoreboard", "+scroll_scoreboard", "+stats", "+show_chat", "screenshot", "snd_toggle", "+left", "+right", "+jump", "+fire", "+hook", "+emote", "+spectate", "spectate_next", "spectate_previous", "+weapon1", "+weapon2", "+weapon3", "+weapon4", "+weapon5", diff --git a/src/game/client/components/menus_callback.cpp b/src/game/client/components/menus_callback.cpp index 196690ac47..ec2ad7429c 100644 --- a/src/game/client/components/menus_callback.cpp +++ b/src/game/client/components/menus_callback.cpp @@ -40,6 +40,7 @@ static CKeyInfo gs_aKeys[] = { "Show chat", "+show_chat", 0, 0}, { "Scoreboard", "+scoreboard", 0, 0}, { "Statboard", "+stats", 0, 0}, + { "Scroll Scoreboard", "+scroll_scoreboard", 0, 0}, { "Emoticon", "+emote", 0, 0}, { "Spectator mode", "+spectate", 0, 0}, @@ -342,7 +343,7 @@ float CMenus::RenderSettingsControlsScoreboard(CUIRect View) } } - int NumOptions = 2; + int NumOptions = 3; int StartOption = 18; float ButtonHeight = 20.0f; float Spacing = 2.0f; @@ -353,7 +354,7 @@ float CMenus::RenderSettingsControlsScoreboard(CUIRect View) DoSettingsControlsButtons(StartOption, StartOption+NumOptions, View, ButtonHeight, Spacing); - View.HSplitTop(ButtonHeight*2+Spacing*3, 0, &View); + View.HSplitTop(ButtonHeight*NumOptions+Spacing*(NumOptions+1), 0, &View); View.VSplitLeft(View.w/3, 0, &View); View.VSplitRight(View.w/2, &View, 0); static int s_StatboardConfigDropdown = 0; @@ -368,7 +369,7 @@ float CMenus::RenderSettingsControlsMisc(CUIRect View) UpdateBindKeys(m_pClient->m_pBinds); int NumOptions = 12; - int StartOption = 20; + int StartOption = 21; float ButtonHeight = 20.0f; float Spacing = 2.0f; float BackgroundHeight = (float)NumOptions*ButtonHeight+(float)NumOptions*Spacing; diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index faaa7a7423..4300afe406 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -40,23 +40,48 @@ void CScoreboard::ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData) pScoreboard->m_Active = false; } else if(!pScoreboard->m_Active) - pScoreboard->m_Activate = true; + { + pScoreboard->m_Activate = true; + pScoreboard->m_Scroll = false; + } +} + +void CScoreboard::ConKeyScroll(IConsole::IResult *pResult, void *pUserData) +{ + CScoreboard *pScoreboard = (CScoreboard *)pUserData; + int Result = pResult->GetInteger(0); + + if(!Result) + { + pScoreboard->m_Scroll = false; + } + else if(pScoreboard->IsActive() && !pScoreboard->m_Scroll) + { + pScoreboard->m_Scroll = true; + } } void CScoreboard::OnReset() { m_Active = false; m_Activate = false; + m_Scroll = false; + m_Line[TEAM_RED] = 0; + m_Line[TEAM_BLUE] = 0; + m_ScrollTimer = 0; } void CScoreboard::OnRelease() { m_Active = false; + m_Scroll = false; + m_ScrollTimer = 0; } void CScoreboard::OnConsoleInit() { Console()->Register("+scoreboard", "", CFGFLAG_CLIENT, ConKeyScoreboard, this, "Show scoreboard"); + Console()->Register("+scroll_scoreboard", "", CFGFLAG_CLIENT, ConKeyScroll, this, "Scroll scoreboard"); } void CScoreboard::RenderGoals(float x, float y, float w) @@ -427,98 +452,32 @@ float CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const c // Non vanilla scoreboard, for now, some parts of the scoreboard are omitted if(NumPlayers > MAX_IDS) { - for(int RenderDead = 0; RenderDead < 2 && NumRenderScoreIDs < MAX_IDS-1; ++RenderDead) + m_Line[Team] %= NumPlayers; + for(int i = m_Line[Team]; NumRenderScoreIDs < MAX_IDS-1; i + 1 < MAX_CLIENTS ? i++ : i = 0) { - for(int i = 0; i < MAX_CLIENTS && NumRenderScoreIDs < MAX_IDS-1; i++) - { - // make sure that we render the correct team - const CGameClient::CPlayerInfoItem *pInfo = &m_pClient->m_Snap.m_aInfoByScore[i]; - if(!pInfo->m_pPlayerInfo || m_pClient->m_aClients[pInfo->m_ClientID].m_Team != Team || (!RenderDead && (pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD)) || - (RenderDead && !(pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD))) - continue; - - RenderScoreIDs[NumRenderScoreIDs] = i; - NumRenderScoreIDs++; - } + // make sure that we render the correct team + const CGameClient::CPlayerInfoItem *pInfo = &m_pClient->m_Snap.m_aInfoByScore[i]; + if(!pInfo->m_pPlayerInfo || m_pClient->m_aClients[pInfo->m_ClientID].m_Team != Team) + continue; + + RenderScoreIDs[NumRenderScoreIDs] = i; + NumRenderScoreIDs++; } NumRenderScoreIDs = MAX_IDS; RenderScoreIDs[MAX_IDS-1] = -1; HoleSizes[0] = m_pClient->m_GameInfo.m_aTeamSize[Team] - (MAX_IDS-1); - - if(m_pClient->m_LocalClientID != -1 && (m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == Team || m_pClient->m_Snap.m_SpecInfo.m_Active)) - { - int Classment = -1; - int TeamScoreIDs[MAX_CLIENTS]; - for(int RenderDead = 0, j = 0; RenderDead < 2; ++RenderDead) - { - for(int i = 0; i < MAX_CLIENTS; i++) - { - // make sure that we render the correct team - const CGameClient::CPlayerInfoItem *pInfo = &m_pClient->m_Snap.m_aInfoByScore[i]; - if(!pInfo->m_pPlayerInfo || m_pClient->m_aClients[pInfo->m_ClientID].m_Team != Team || (!RenderDead && (pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD)) || - (RenderDead && !(pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD))) - continue; - - if(m_pClient->m_LocalClientID == pInfo->m_ClientID || (m_pClient->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientID == m_pClient->m_Snap.m_SpecInfo.m_SpectatorID)) - Classment = j; - - TeamScoreIDs[j] = i; - j++; - } - } - - if(Classment < MAX_IDS-1) {} - else if(Classment == m_pClient->m_GameInfo.m_aTeamSize[Team] - 1) - { - HoleSizes[0] = Classment - MAX_IDS-2; - RenderScoreIDs[MAX_IDS-3] = -1; - RenderScoreIDs[MAX_IDS-2] = TeamScoreIDs[Classment-1]; - RenderScoreIDs[MAX_IDS-1] = TeamScoreIDs[Classment]; - } - else if(Classment == m_pClient->m_GameInfo.m_aTeamSize[Team] - 2) - { - HoleSizes[0] = Classment - MAX_IDS-3; - RenderScoreIDs[MAX_IDS-4] = -1; - RenderScoreIDs[MAX_IDS-3] = TeamScoreIDs[Classment-1]; - RenderScoreIDs[MAX_IDS-2] = TeamScoreIDs[Classment]; - RenderScoreIDs[MAX_IDS-1] = TeamScoreIDs[Classment+1]; - } - else if(Classment == m_pClient->m_GameInfo.m_aTeamSize[Team] - 3) - { - HoleSizes[0] = Classment - MAX_IDS-4; - RenderScoreIDs[MAX_IDS-5] = -1; - RenderScoreIDs[MAX_IDS-4] = TeamScoreIDs[Classment-1]; - RenderScoreIDs[MAX_IDS-3] = TeamScoreIDs[Classment]; - RenderScoreIDs[MAX_IDS-2] = TeamScoreIDs[Classment+1]; - RenderScoreIDs[MAX_IDS-1] = TeamScoreIDs[Classment+2]; - } - else if(Classment < m_pClient->m_GameInfo.m_aTeamSize[Team] - 3) - { - HoleSizes[0] = Classment - MAX_IDS-4; - RenderScoreIDs[MAX_IDS-5] = -1; - RenderScoreIDs[MAX_IDS-4] = TeamScoreIDs[Classment-1]; - RenderScoreIDs[MAX_IDS-3] = TeamScoreIDs[Classment]; - RenderScoreIDs[MAX_IDS-2] = TeamScoreIDs[Classment+1]; - HoleSizes[1] = m_pClient->m_GameInfo.m_aTeamSize[Team] - Classment - 2; - RenderScoreIDs[MAX_IDS-1] = -2; - } - } } else // Normal scoreboard { - for(int RenderDead = 0; RenderDead < 2; ++RenderDead) + for(int i = 0; i < MAX_CLIENTS && NumRenderScoreIDs < MAX_IDS; i++) { - for(int i = 0; i < MAX_CLIENTS && NumRenderScoreIDs < MAX_IDS; i++) - { - // make sure that we render the correct team - const CGameClient::CPlayerInfoItem *pInfo = &m_pClient->m_Snap.m_aInfoByScore[i]; - if(!pInfo->m_pPlayerInfo || m_pClient->m_aClients[pInfo->m_ClientID].m_Team != Team || (!RenderDead && (pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD)) || - (RenderDead && !(pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD))) - continue; - - RenderScoreIDs[NumRenderScoreIDs] = i; - NumRenderScoreIDs++; - } + // make sure that we render the correct team + const CGameClient::CPlayerInfoItem *pInfo = &m_pClient->m_Snap.m_aInfoByScore[i]; + if(!pInfo->m_pPlayerInfo || m_pClient->m_aClients[pInfo->m_ClientID].m_Team != Team) + continue; + + RenderScoreIDs[NumRenderScoreIDs] = i; + NumRenderScoreIDs++; } } @@ -917,6 +876,24 @@ bool CScoreboard::IsActive() const return false; } +void CScoreboard::DoUpdate() +{ + if(m_Scroll) + { + if(m_ScrollTimer > 0) + { + m_ScrollTimer --; + } + else + { + m_Line[TEAM_RED] ++; + m_Line[TEAM_BLUE] ++; + // in ms + m_ScrollTimer = round_to_int((1.0f / (float) Config()->m_ClScoreboardScrollSpeed) * Client()->GameTickSpeed()); + } + } +} + const char *CScoreboard::GetClanName(int Team) { int ClanPlayers = 0; diff --git a/src/game/client/components/scoreboard.h b/src/game/client/components/scoreboard.h index 748bd5c31a..7a698b480b 100644 --- a/src/game/client/components/scoreboard.h +++ b/src/game/client/components/scoreboard.h @@ -13,9 +13,13 @@ class CScoreboard : public CComponent void RenderNetworkQuality(float x, float w); static void ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData); + static void ConKeyScroll(IConsole::IResult *pResult, void *pUserData); bool m_Active; bool m_Activate; + bool m_Scroll; + int m_ScrollTimer; + int m_Line[NUM_TEAMS]; class CUIRect m_TotalRect; public: @@ -25,6 +29,8 @@ class CScoreboard : public CComponent virtual void OnRender(); virtual void OnRelease(); + void DoUpdate(); + bool IsActive() const; void ResetPlayerStats(int ClientID); class CUIRect GetScoreboardRect() const { return m_TotalRect; } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index a2b85f05d7..9ebca1671c 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -443,6 +443,8 @@ void CGameClient::OnUpdate() break; } } + + m_pScoreboard->DoUpdate(); } int CGameClient::OnSnapInput(int *pData) diff --git a/src/game/variables.h b/src/game/variables.h index 78f24f20e3..5f1c0e82ed 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -38,6 +38,8 @@ MACRO_CONFIG_INT(ClCustomizeSkin, cl_customize_skin, 0, 0, 1, CFGFLAG_CLIENT|CFG MACRO_CONFIG_INT(ClShowUserId, cl_show_user_id, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show the ID for every user") +MACRO_CONFIG_INT(ClScoreboardScrollSpeed, cl_scoreboard_scroll_speed, 8, 0, 64, CFGFLAG_CLIENT|CFGFLAG_SAVE, "The number of lines to scroll scoreboard in second") + MACRO_CONFIG_INT(EdZoomTarget, ed_zoom_target, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Zoom to the current mouse target") MACRO_CONFIG_INT(EdShowkeys, ed_showkeys, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Editor shows which keys are pressed") MACRO_CONFIG_INT(EdColorGridInner, ed_color_grid_inner, 0xFFFFFF26, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Color inner grid")