2010-11-20 10:37:14 +00:00
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
2010-05-29 07:25:38 +00:00
# include <base/math.h>
2022-05-18 16:00:05 +00:00
# include <base/system.h>
2008-09-29 11:34:49 +00:00
2010-08-09 12:14:15 +00:00
# include <engine/demo.h>
2022-05-23 18:16:18 +00:00
# include <engine/favorites.h>
2011-03-23 12:06:35 +00:00
# include <engine/friends.h>
2017-09-09 15:04:19 +00:00
# include <engine/ghost.h>
2011-04-06 18:18:31 +00:00
# include <engine/graphics.h>
2010-05-29 07:25:38 +00:00
# include <engine/serverbrowser.h>
# include <engine/shared/config.h>
2022-12-09 15:15:19 +00:00
# include <engine/shared/localization.h>
2020-09-26 19:41:58 +00:00
# include <engine/textrender.h>
2008-09-29 11:34:49 +00:00
2010-05-29 07:25:38 +00:00
# include <game/generated/client_data.h>
2020-09-26 19:41:58 +00:00
# include <game/generated/protocol.h>
2008-09-29 11:34:49 +00:00
2011-03-22 21:41:27 +00:00
# include <game/client/animstate.h>
2020-09-26 19:41:58 +00:00
# include <game/client/components/countryflags.h>
2011-03-22 21:41:27 +00:00
# include <game/client/gameclient.h>
# include <game/client/render.h>
# include <game/client/ui.h>
2023-01-05 11:21:10 +00:00
# include <game/client/ui_listbox.h>
2022-08-15 21:19:56 +00:00
# include <game/client/ui_scrollregion.h>
2020-09-26 19:41:58 +00:00
# include <game/localization.h>
2008-09-29 11:34:49 +00:00
2010-05-29 07:25:38 +00:00
# include "menus.h"
# include "motd.h"
# include "voting.h"
2008-09-29 11:34:49 +00:00
2020-09-26 19:41:58 +00:00
# include "ghost.h"
2011-02-04 17:25:04 +00:00
# include <engine/keys.h>
# include <engine/storage.h>
2008-09-29 11:34:49 +00:00
2022-05-18 16:00:05 +00:00
# include <chrono>
2023-04-03 23:40:54 +00:00
using namespace FontIcons ;
2022-05-18 16:00:05 +00:00
using namespace std : : chrono_literals ;
2010-05-29 07:25:38 +00:00
void CMenus : : RenderGame ( CUIRect MainView )
2008-09-29 11:34:49 +00:00
{
2020-09-03 10:08:00 +00:00
CUIRect Button , ButtonBar , ButtonBar2 ;
2011-04-06 18:18:31 +00:00
MainView . HSplitTop ( 45.0f , & ButtonBar , & MainView ) ;
2022-08-07 16:12:07 +00:00
ButtonBar . Draw ( ms_ColorTabbarActive , IGraphics : : CORNER_B , 10.0f ) ;
2011-04-13 18:37:12 +00:00
2011-03-22 21:41:27 +00:00
// button bar
ButtonBar . HSplitTop ( 10.0f , 0 , & ButtonBar ) ;
ButtonBar . HSplitTop ( 25.0f , & ButtonBar , 0 ) ;
ButtonBar . VMargin ( 10.0f , & ButtonBar ) ;
2011-04-13 18:37:12 +00:00
2020-09-03 10:08:00 +00:00
ButtonBar . HSplitTop ( 30.0f , 0 , & ButtonBar2 ) ;
ButtonBar2 . HSplitTop ( 25.0f , & ButtonBar2 , 0 ) ;
2011-03-22 21:41:27 +00:00
ButtonBar . VSplitRight ( 120.0f , & ButtonBar , & Button ) ;
2020-09-03 10:08:00 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_DisconnectButton ;
2010-05-29 07:25:38 +00:00
if ( DoButton_Menu ( & s_DisconnectButton , Localize ( " Disconnect " ) , 0 , & Button ) )
2014-07-08 18:21:19 +00:00
{
2019-03-29 13:56:02 +00:00
if ( Client ( ) - > GetCurrentRaceTime ( ) / 60 > = g_Config . m_ClConfirmDisconnectTime & & g_Config . m_ClConfirmDisconnectTime > = 0 )
2019-03-25 19:02:50 +00:00
{
2022-11-30 22:06:44 +00:00
PopupConfirm ( Localize ( " Disconnect " ) , Localize ( " Are you sure that you want to disconnect? " ) , Localize ( " Yes " ) , Localize ( " No " ) , & CMenus : : PopupConfirmDisconnect ) ;
2019-03-25 19:02:50 +00:00
}
2014-07-10 14:50:59 +00:00
else
2019-03-25 19:02:50 +00:00
{
2014-07-10 14:50:59 +00:00
Client ( ) - > Disconnect ( ) ;
2022-09-23 17:59:18 +00:00
RefreshBrowserTab ( g_Config . m_UiPage ) ;
2019-03-25 19:02:50 +00:00
}
2014-07-08 18:21:19 +00:00
}
2008-09-29 11:34:49 +00:00
2020-09-03 10:08:00 +00:00
ButtonBar . VSplitRight ( 5.0f , & ButtonBar , 0 ) ;
ButtonBar . VSplitRight ( 170.0f , & ButtonBar , & Button ) ;
bool DummyConnecting = Client ( ) - > DummyConnecting ( ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_DummyButton ;
2021-11-17 19:35:39 +00:00
if ( ! Client ( ) - > DummyAllowed ( ) )
{
2022-07-26 19:17:29 +00:00
DoButton_Menu ( & s_DummyButton , Localize ( " Connect Dummy " ) , 1 , & Button , nullptr , IGraphics : : CORNER_ALL , 5.0f , 0.0f , vec4 ( 1.0f , 0.5f , 0.5f , 0.75f ) , vec4 ( 1 , 0.5f , 0.5f , 0.5f ) ) ;
2021-11-17 19:35:39 +00:00
}
else if ( DummyConnecting )
2020-09-03 10:08:00 +00:00
{
DoButton_Menu ( & s_DummyButton , Localize ( " Connecting dummy " ) , 1 , & Button ) ;
}
else if ( DoButton_Menu ( & s_DummyButton , Client ( ) - > DummyConnected ( ) ? Localize ( " Disconnect Dummy " ) : Localize ( " Connect Dummy " ) , 0 , & Button ) )
{
if ( ! Client ( ) - > DummyConnected ( ) )
{
Client ( ) - > DummyConnect ( ) ;
}
else
{
if ( Client ( ) - > GetCurrentRaceTime ( ) / 60 > = g_Config . m_ClConfirmDisconnectTime & & g_Config . m_ClConfirmDisconnectTime > = 0 )
{
2022-11-30 22:06:44 +00:00
PopupConfirm ( Localize ( " Disconnect Dummy " ) , Localize ( " Are you sure that you want to disconnect your dummy? " ) , Localize ( " Yes " ) , Localize ( " No " ) , & CMenus : : PopupConfirmDisconnectDummy ) ;
2020-09-03 10:08:00 +00:00
}
else
{
Client ( ) - > DummyDisconnect ( 0 ) ;
2020-09-05 15:13:32 +00:00
SetActive ( false ) ;
2020-09-03 10:08:00 +00:00
}
}
}
ButtonBar . VSplitRight ( 5.0f , & ButtonBar , 0 ) ;
ButtonBar . VSplitRight ( 140.0f , & ButtonBar , & Button ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_DemoButton ;
2020-09-03 10:08:00 +00:00
bool Recording = DemoRecorder ( RECORDER_MANUAL ) - > IsRecording ( ) ;
if ( DoButton_Menu ( & s_DemoButton , Recording ? Localize ( " Stop record " ) : Localize ( " Record demo " ) , 0 , & Button ) )
{
if ( ! Recording )
Client ( ) - > DemoRecorder_Start ( Client ( ) - > GetCurrentMap ( ) , true , RECORDER_MANUAL ) ;
else
Client ( ) - > DemoRecorder_Stop ( RECORDER_MANUAL ) ;
}
2022-07-16 13:32:06 +00:00
static CButtonContainer s_SpectateButton ;
static CButtonContainer s_JoinRedButton ;
static CButtonContainer s_JoinBlueButton ;
2015-04-19 12:24:20 +00:00
2020-10-10 10:43:05 +00:00
bool Paused = false ;
bool Spec = false ;
if ( m_pClient - > m_Snap . m_LocalClientID > = 0 )
{
Paused = m_pClient - > m_aClients [ m_pClient - > m_Snap . m_LocalClientID ] . m_Paused ;
Spec = m_pClient - > m_aClients [ m_pClient - > m_Snap . m_LocalClientID ] . m_Spec ;
}
2020-09-03 10:08:00 +00:00
if ( m_pClient - > m_Snap . m_pLocalInfo & & m_pClient - > m_Snap . m_pGameInfoObj & & ! Paused & & ! Spec )
2008-09-29 11:34:49 +00:00
{
2011-01-03 11:50:38 +00:00
if ( m_pClient - > m_Snap . m_pLocalInfo - > m_Team ! = TEAM_SPECTATORS )
2008-09-29 11:34:49 +00:00
{
2014-05-03 22:11:11 +00:00
ButtonBar . VSplitLeft ( 5.0f , 0 , & ButtonBar ) ;
2011-03-22 21:41:27 +00:00
ButtonBar . VSplitLeft ( 120.0f , & Button , & ButtonBar ) ;
2015-04-19 12:40:05 +00:00
if ( ! DummyConnecting & & DoButton_Menu ( & s_SpectateButton , Localize ( " Spectate " ) , 0 , & Button ) )
2008-09-29 11:34:49 +00:00
{
2020-09-03 10:08:00 +00:00
if ( g_Config . m_ClDummy = = 0 | | Client ( ) - > DummyConnected ( ) )
2014-07-08 00:00:13 +00:00
{
m_pClient - > SendSwitchTeam ( TEAM_SPECTATORS ) ;
SetActive ( false ) ;
}
2008-09-29 11:34:49 +00:00
}
}
2011-04-13 18:37:12 +00:00
2011-03-04 16:08:10 +00:00
if ( m_pClient - > m_Snap . m_pGameInfoObj - > m_GameFlags & GAMEFLAG_TEAMS )
2008-09-29 11:34:49 +00:00
{
2011-01-03 11:50:38 +00:00
if ( m_pClient - > m_Snap . m_pLocalInfo - > m_Team ! = TEAM_RED )
2008-09-29 11:34:49 +00:00
{
2014-05-03 22:11:11 +00:00
ButtonBar . VSplitLeft ( 5.0f , 0 , & ButtonBar ) ;
2011-03-22 21:41:27 +00:00
ButtonBar . VSplitLeft ( 120.0f , & Button , & ButtonBar ) ;
2015-05-28 21:11:01 +00:00
if ( ! DummyConnecting & & DoButton_Menu ( & s_JoinRedButton , Localize ( " Join red " ) , 0 , & Button ) )
2008-09-29 11:34:49 +00:00
{
2011-01-03 11:50:38 +00:00
m_pClient - > SendSwitchTeam ( TEAM_RED ) ;
2010-05-29 07:25:38 +00:00
SetActive ( false ) ;
2008-09-29 11:34:49 +00:00
}
}
2011-01-03 11:50:38 +00:00
if ( m_pClient - > m_Snap . m_pLocalInfo - > m_Team ! = TEAM_BLUE )
2008-09-29 11:34:49 +00:00
{
2014-05-03 22:11:11 +00:00
ButtonBar . VSplitLeft ( 5.0f , 0 , & ButtonBar ) ;
2011-03-22 21:41:27 +00:00
ButtonBar . VSplitLeft ( 120.0f , & Button , & ButtonBar ) ;
2015-05-28 21:11:01 +00:00
if ( ! DummyConnecting & & DoButton_Menu ( & s_JoinBlueButton , Localize ( " Join blue " ) , 0 , & Button ) )
2008-09-29 11:34:49 +00:00
{
2011-01-03 11:50:38 +00:00
m_pClient - > SendSwitchTeam ( TEAM_BLUE ) ;
2010-05-29 07:25:38 +00:00
SetActive ( false ) ;
2008-09-29 11:34:49 +00:00
}
}
}
else
{
2010-05-29 07:25:38 +00:00
if ( m_pClient - > m_Snap . m_pLocalInfo - > m_Team ! = 0 )
2008-09-29 11:34:49 +00:00
{
2014-05-03 22:11:11 +00:00
ButtonBar . VSplitLeft ( 5.0f , 0 , & ButtonBar ) ;
2011-03-22 21:41:27 +00:00
ButtonBar . VSplitLeft ( 120.0f , & Button , & ButtonBar ) ;
2015-04-19 12:40:05 +00:00
if ( ! DummyConnecting & & DoButton_Menu ( & s_SpectateButton , Localize ( " Join game " ) , 0 , & Button ) )
2008-09-29 11:34:49 +00:00
{
2010-05-29 07:25:38 +00:00
m_pClient - > SendSwitchTeam ( 0 ) ;
SetActive ( false ) ;
2008-09-29 11:34:49 +00:00
}
}
}
2010-08-09 12:14:15 +00:00
2020-09-03 10:08:00 +00:00
if ( m_pClient - > m_Snap . m_pLocalInfo - > m_Team ! = TEAM_SPECTATORS )
{
ButtonBar . VSplitLeft ( 5.0f , 0 , & ButtonBar ) ;
ButtonBar . VSplitLeft ( 65.0f , & Button , & ButtonBar ) ;
2014-04-26 18:29:42 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_KillButton ;
2020-09-03 10:08:00 +00:00
if ( DoButton_Menu ( & s_KillButton , Localize ( " Kill " ) , 0 , & Button ) )
{
m_pClient - > SendKill ( - 1 ) ;
SetActive ( false ) ;
}
}
2015-04-19 12:40:05 +00:00
}
2020-09-03 10:08:00 +00:00
2020-09-05 08:44:50 +00:00
if ( m_pClient - > m_ReceivedDDNetPlayer & & m_pClient - > m_Snap . m_pLocalInfo & & m_pClient - > m_Snap . m_pGameInfoObj )
2014-04-26 18:29:42 +00:00
{
2020-09-03 10:08:00 +00:00
if ( m_pClient - > m_Snap . m_pLocalInfo - > m_Team ! = TEAM_SPECTATORS | | Paused | | Spec )
2014-04-26 18:29:42 +00:00
{
2020-09-03 10:08:00 +00:00
ButtonBar . VSplitLeft ( 5.0f , 0 , & ButtonBar ) ;
ButtonBar . VSplitLeft ( ( ! Paused & & ! Spec ) ? 65.0f : 120.0f , & Button , & ButtonBar ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_PauseButton ;
2020-09-03 10:08:00 +00:00
if ( DoButton_Menu ( & s_PauseButton , ( ! Paused & & ! Spec ) ? Localize ( " Pause " ) : Localize ( " Join game " ) , 0 , & Button ) )
2019-03-25 19:02:50 +00:00
{
2020-09-03 10:08:00 +00:00
m_pClient - > Console ( ) - > ExecuteLine ( " say /pause " ) ;
SetActive ( false ) ;
2019-03-25 19:02:50 +00:00
}
2014-04-26 18:29:42 +00:00
}
}
2011-04-06 18:18:31 +00:00
}
2022-11-30 22:06:44 +00:00
void CMenus : : PopupConfirmDisconnect ( )
{
Client ( ) - > Disconnect ( ) ;
}
void CMenus : : PopupConfirmDisconnectDummy ( )
{
Client ( ) - > DummyDisconnect ( 0 ) ;
SetActive ( false ) ;
}
2011-04-06 18:18:31 +00:00
void CMenus : : RenderPlayers ( CUIRect MainView )
{
2014-02-19 13:49:08 +00:00
CUIRect Button , Button2 , ButtonBar , Options , Player ;
2022-08-07 16:12:07 +00:00
MainView . Draw ( ms_ColorTabbarActive , IGraphics : : CORNER_B , 10.0f ) ;
2011-03-22 21:41:27 +00:00
// player options
MainView . Margin ( 10.0f , & Options ) ;
2022-08-07 16:12:07 +00:00
Options . Draw ( ColorRGBA ( 1.0f , 1.0f , 1.0f , 0.25f ) , IGraphics : : CORNER_ALL , 10.0f ) ;
2011-03-22 21:41:27 +00:00
Options . Margin ( 10.0f , & Options ) ;
Options . HSplitTop ( 50.0f , & Button , & Options ) ;
2023-04-09 19:24:06 +00:00
UI ( ) - > DoLabel ( & Button , Localize ( " Player options " ) , 34.0f , TEXTALIGN_ML ) ;
2011-03-22 21:41:27 +00:00
2011-04-06 18:18:31 +00:00
// headline
Options . HSplitTop ( 34.0f , & ButtonBar , & Options ) ;
2020-06-27 20:58:28 +00:00
ButtonBar . VSplitRight ( 231.0f , & Player , & ButtonBar ) ;
2023-04-09 19:24:06 +00:00
UI ( ) - > DoLabel ( & Player , Localize ( " Player " ) , 24.0f , TEXTALIGN_ML ) ;
2011-04-06 18:18:31 +00:00
ButtonBar . HMargin ( 1.0f , & ButtonBar ) ;
2020-09-26 19:41:58 +00:00
float Width = ButtonBar . h * 2.0f ;
2011-04-06 18:18:31 +00:00
ButtonBar . VSplitLeft ( Width , & Button , & ButtonBar ) ;
2022-06-25 15:15:37 +00:00
RenderTools ( ) - > RenderIcon ( IMAGE_GUIICONS , SPRITE_GUIICON_MUTE , & Button ) ;
2011-04-06 18:18:31 +00:00
2023-01-05 11:21:10 +00:00
ButtonBar . VSplitLeft ( 20.0f , nullptr , & ButtonBar ) ;
2020-06-26 22:06:07 +00:00
ButtonBar . VSplitLeft ( Width , & Button , & ButtonBar ) ;
2022-06-25 15:15:37 +00:00
RenderTools ( ) - > RenderIcon ( IMAGE_GUIICONS , SPRITE_GUIICON_EMOTICON_MUTE , & Button ) ;
2020-06-26 22:06:07 +00:00
2023-01-05 11:21:10 +00:00
ButtonBar . VSplitLeft ( 20.0f , nullptr , & ButtonBar ) ;
2011-04-06 18:18:31 +00:00
ButtonBar . VSplitLeft ( Width , & Button , & ButtonBar ) ;
2022-06-25 15:15:37 +00:00
RenderTools ( ) - > RenderIcon ( IMAGE_GUIICONS , SPRITE_GUIICON_FRIEND , & Button ) ;
2011-04-06 18:18:31 +00:00
2013-12-31 21:14:59 +00:00
int TotalPlayers = 0 ;
Declare variables as `const` when possible
According to cppcheck's `constVariable` error:
```
src\engine\client\backend\opengl\opengl_sl.cpp:74:43: style: Variable 'Define' can be declared as reference to const [constVariable]
for(CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_vDefines)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:2149:12: style: Variable 'GraphicThreadCommandBuffer' can be declared as reference to const [constVariable]
auto &GraphicThreadCommandBuffer = m_vvThreadDrawCommandBuffers[i + 1][m_CurImageIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3192:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3200:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[State.m_Texture].m_VKStandard3DTexturedDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3810:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
for(auto &Mode : vPresentModeList)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3818:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
for(auto &Mode : vPresentModeList)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6511:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6555:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_VKStandard3DTexturedDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6660:9: style: Variable 'MemBlock' can be declared as reference to const [constVariable]
auto &MemBlock = m_vBufferObjects[BufferIndex].m_BufferObject.m_Mem;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6799:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6808:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6902:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6907:9: style: Variable 'TextTextureDescr' can be declared as reference to const [constVariable]
auto &TextTextureDescr = m_vTextures[pCommand->m_TextTextureIndex].m_VKTextDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6961:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6970:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\game\client\components\hud.cpp:178:8: style: Variable 'aFlagCarrier' can be declared as const array [constVariable]
int aFlagCarrier[2] = {
^
src\game\client\components\hud.cpp:519:16: style: Variable 's_aTextWidth' can be declared as const array [constVariable]
static float s_aTextWidth[5] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000};
^
src\game\client\components\killmessages.cpp:305:30: style: Variable 'Client' can be declared as reference to const [constVariable]
CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_KillerID];
^
src\game\client\components\killmessages.cpp:314:30: style: Variable 'Client' can be declared as reference to const [constVariable]
CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_VictimID];
^
src\game\client\components\menus_ingame.cpp:243:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
^
src\game\client\components\menus_ingame.cpp:530:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
^
src\game\client\components\players.cpp:767:44: style: Variable 'CharacterInfo' can be declared as reference to const [constVariable]
CGameClient::CSnapState::CCharacterInfo &CharacterInfo = m_pClient->m_Snap.m_aCharacters[i];
^
src\game\client\components\spectator.cpp:122:27: style: Variable 'Snap' can be declared as reference to const [constVariable]
CGameClient::CSnapState &Snap = pSelf->m_pClient->m_Snap;
^
src\game\client\components\spectator.cpp:221:12: style: Variable 'pInfo' can be declared as reference to const [constVariable]
for(auto &pInfo : m_pClient->m_Snap.m_apInfoByDDTeamName)
^
src\game\client\gameclient.cpp:2220:15: style: Variable 'OwnClientData' can be declared as reference to const [constVariable]
CClientData &OwnClientData = m_aClients[ownID];
^
src\game\client\gameclient.cpp:2227:16: style: Variable 'cData' can be declared as reference to const [constVariable]
CClientData &cData = m_aClients[i];
^
src\game\client\prediction\entities\character.cpp:397:11: style: Variable 'aSpreading' can be declared as const array [constVariable]
float aSpreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
^
src\game\client\prediction\entities\laser.cpp:53:9: style: Variable 'HitPos' can be declared as reference to const [constVariable]
vec2 &HitPos = pHit->Core()->m_Pos;
^
src\game\editor\auto_map.cpp:507:18: style: Variable 'Index' can be declared as reference to const [constVariable]
for(auto &Index : pRule->m_vIndexList)
^
src\game\editor\auto_map.cpp:518:18: style: Variable 'Index' can be declared as reference to const [constVariable]
for(auto &Index : pRule->m_vIndexList)
^
src\game\editor\editor.cpp:118:12: style: Variable 'Item' can be declared as reference to const [constVariable]
for(auto &Item : vList)
^
src\game\editor\editor.cpp:2983:11: style: Variable 'aAspects' can be declared as const array [constVariable]
float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
^
src\game\editor\editor.cpp:3141:15: style: Variable 's_aShift' can be declared as const array [constVariable]
static int s_aShift[] = {24, 16, 8, 0};
^
src\engine\server\server.cpp:2807:14: style: Variable 'Client' can be declared as reference to const [constVariable]
for(auto &Client : m_aClients)
^
src\engine\server\sql_string_helpers.cpp:51:6: style: Variable 'aTimes' can be declared as const array [constVariable]
int aTimes[7] =
^
src\test\secure_random.cpp:24:6: style: Variable 'BOUNDS' can be declared as const array [constVariable]
int BOUNDS[] = {2, 3, 4, 5, 10, 100, 127, 128, 129};
^
```
2022-11-13 15:29:13 +00:00
for ( const auto & pInfoByName : m_pClient - > m_Snap . m_apInfoByName )
2013-12-31 21:14:59 +00:00
{
2020-10-26 14:14:07 +00:00
if ( ! pInfoByName )
2013-12-31 21:14:59 +00:00
continue ;
2020-10-26 14:14:07 +00:00
int Index = pInfoByName - > m_ClientID ;
2013-12-31 21:14:59 +00:00
if ( Index = = m_pClient - > m_Snap . m_LocalClientID )
continue ;
TotalPlayers + + ;
}
2023-01-05 11:21:10 +00:00
static CListBox s_ListBox ;
s_ListBox . DoStart ( 24.0f , TotalPlayers , 1 , 3 , - 1 , & Options ) ;
2013-12-31 21:14:59 +00:00
2011-04-06 18:18:31 +00:00
// options
2023-01-05 11:21:10 +00:00
static char s_aPlayerIDs [ MAX_CLIENTS ] [ 3 ] = { { 0 } } ;
2013-12-31 21:14:59 +00:00
2011-04-06 18:18:31 +00:00
for ( int i = 0 , Count = 0 ; i < MAX_CLIENTS ; + + i )
2011-03-22 21:41:27 +00:00
{
2022-06-30 22:36:32 +00:00
if ( ! m_pClient - > m_Snap . m_apInfoByName [ i ] )
2011-08-04 21:43:39 +00:00
continue ;
2022-06-30 22:36:32 +00:00
int Index = m_pClient - > m_Snap . m_apInfoByName [ i ] - > m_ClientID ;
2011-08-04 21:43:39 +00:00
if ( Index = = m_pClient - > m_Snap . m_LocalClientID )
2011-03-22 21:41:27 +00:00
continue ;
2023-01-05 11:21:10 +00:00
CGameClient : : CClientData & CurrentClient = m_pClient - > m_aClients [ Index ] ;
const CListboxItem Item = s_ListBox . DoNextItem ( & CurrentClient ) ;
2014-02-02 20:06:05 +00:00
2013-12-31 21:14:59 +00:00
Count + + ;
if ( ! Item . m_Visible )
continue ;
2023-01-05 11:21:10 +00:00
CUIRect Row = Item . m_Rect ;
2020-09-26 19:41:58 +00:00
if ( Count % 2 = = 1 )
2023-01-05 11:21:10 +00:00
Row . Draw ( ColorRGBA ( 1.0f , 1.0f , 1.0f , 0.25f ) , IGraphics : : CORNER_ALL , 5.0f ) ;
Row . VSplitRight ( s_ListBox . ScrollbarWidthMax ( ) - s_ListBox . ScrollbarWidth ( ) , & Row , nullptr ) ;
Row . VSplitRight ( 300.0f , & Player , & Row ) ;
2011-03-22 21:41:27 +00:00
// player info
2011-03-28 19:10:37 +00:00
Player . VSplitLeft ( 28.0f , & Button , & Player ) ;
2021-04-09 18:11:53 +00:00
2023-01-05 11:21:10 +00:00
CTeeRenderInfo TeeInfo = CurrentClient . m_RenderInfo ;
2021-04-09 18:11:53 +00:00
TeeInfo . m_Size = Button . h ;
CAnimState * pIdleState = CAnimState : : GetIdle ( ) ;
vec2 OffsetToMid ;
RenderTools ( ) - > GetRenderTeeOffsetToRenderedTee ( pIdleState , & TeeInfo , OffsetToMid ) ;
vec2 TeeRenderPos ( Button . x + Button . h / 2 , Button . y + Button . h / 2 + OffsetToMid . y ) ;
RenderTools ( ) - > RenderTee ( pIdleState , & TeeInfo , EMOTE_NORMAL , vec2 ( 1.0f , 0.0f ) , TeeRenderPos ) ;
2011-03-22 21:41:27 +00:00
2023-01-05 11:21:10 +00:00
Player . HSplitTop ( 1.5f , nullptr , & Player ) ;
2011-03-22 21:41:27 +00:00
Player . VSplitMid ( & Player , & Button ) ;
2023-01-05 11:21:10 +00:00
Row . VSplitRight ( 210.0f , & Button2 , & Row ) ;
2011-03-22 21:41:27 +00:00
CTextCursor Cursor ;
2020-09-26 19:41:58 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Player . x , Player . y + ( Player . h - 14.f ) / 2.f , 14.0f , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-03-22 21:41:27 +00:00
Cursor . m_LineWidth = Player . w ;
2023-01-05 11:21:10 +00:00
TextRender ( ) - > TextEx ( & Cursor , CurrentClient . m_aName , - 1 ) ;
2011-03-22 21:41:27 +00:00
2020-09-26 19:41:58 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Button . x , Button . y + ( Button . h - 14.f ) / 2.f , 14.0f , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-03-22 21:41:27 +00:00
Cursor . m_LineWidth = Button . w ;
2023-01-05 11:21:10 +00:00
TextRender ( ) - > TextEx ( & Cursor , CurrentClient . m_aClan , - 1 ) ;
2011-03-22 21:41:27 +00:00
2019-04-26 21:47:34 +00:00
ColorRGBA Color ( 1.0f , 1.0f , 1.0f , 0.5f ) ;
2023-01-05 11:21:10 +00:00
m_pClient - > m_CountryFlags . Render ( CurrentClient . m_Country , & Color ,
2022-03-21 06:10:44 +00:00
Button2 . x , Button2 . y + Button2 . h / 2.0f - 0.75f * Button2 . h / 2.0f , 1.5f * Button2 . h , 0.75f * Button2 . h ) ;
2014-02-19 13:49:08 +00:00
2020-06-26 22:06:07 +00:00
// ignore chat button
2023-01-05 11:21:10 +00:00
Row . HMargin ( 2.0f , & Row ) ;
Row . VSplitLeft ( Width , & Button , & Row ) ;
Button . VSplitLeft ( ( Width - Button . h ) / 4.0f , nullptr , & Button ) ;
Button . VSplitLeft ( Button . h , & Button , nullptr ) ;
if ( g_Config . m_ClShowChatFriends & & ! CurrentClient . m_Friend )
2012-01-10 22:03:23 +00:00
DoButton_Toggle ( & s_aPlayerIDs [ Index ] [ 0 ] , 1 , & Button , false ) ;
2023-01-05 11:21:10 +00:00
else if ( DoButton_Toggle ( & s_aPlayerIDs [ Index ] [ 0 ] , CurrentClient . m_ChatIgnore , & Button , true ) )
CurrentClient . m_ChatIgnore ^ = 1 ;
2011-03-23 12:06:35 +00:00
2020-06-26 22:06:07 +00:00
// ignore emoticon button
2023-01-05 11:21:10 +00:00
Row . VSplitLeft ( 30.0f , nullptr , & Row ) ;
Row . VSplitLeft ( Width , & Button , & Row ) ;
Button . VSplitLeft ( ( Width - Button . h ) / 4.0f , nullptr , & Button ) ;
Button . VSplitLeft ( Button . h , & Button , nullptr ) ;
if ( g_Config . m_ClShowChatFriends & & ! CurrentClient . m_Friend )
2020-06-26 22:06:07 +00:00
DoButton_Toggle ( & s_aPlayerIDs [ Index ] [ 1 ] , 1 , & Button , false ) ;
2023-01-05 11:21:10 +00:00
else if ( DoButton_Toggle ( & s_aPlayerIDs [ Index ] [ 1 ] , CurrentClient . m_EmoticonIgnore , & Button , true ) )
CurrentClient . m_EmoticonIgnore ^ = 1 ;
2020-06-26 22:06:07 +00:00
2011-03-23 12:06:35 +00:00
// friend button
2023-01-05 11:21:10 +00:00
Row . VSplitLeft ( 10.0f , nullptr , & Row ) ;
Row . VSplitLeft ( Width , & Button , & Row ) ;
Button . VSplitLeft ( ( Width - Button . h ) / 4.0f , nullptr , & Button ) ;
Button . VSplitLeft ( Button . h , & Button , nullptr ) ;
if ( DoButton_Toggle ( & s_aPlayerIDs [ Index ] [ 2 ] , CurrentClient . m_Friend , & Button , true ) )
2011-05-04 23:43:27 +00:00
{
2023-01-05 11:21:10 +00:00
if ( CurrentClient . m_Friend )
m_pClient - > Friends ( ) - > RemoveFriend ( CurrentClient . m_aName , CurrentClient . m_aClan ) ;
2011-04-06 18:18:31 +00:00
else
2023-01-05 11:21:10 +00:00
m_pClient - > Friends ( ) - > AddFriend ( CurrentClient . m_aName , CurrentClient . m_aClan ) ;
2011-05-04 23:43:27 +00:00
}
2011-03-22 21:41:27 +00:00
}
2011-04-13 18:37:12 +00:00
2023-01-05 11:21:10 +00:00
s_ListBox . DoEnd ( ) ;
2008-09-29 11:34:49 +00:00
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderServerInfo ( CUIRect MainView )
2008-09-29 11:34:49 +00:00
{
2011-03-13 10:14:35 +00:00
if ( ! m_pClient - > m_Snap . m_pLocalInfo )
return ;
2008-10-17 21:16:23 +00:00
// fetch server info
2010-05-29 07:25:38 +00:00
CServerInfo CurrentServerInfo ;
Client ( ) - > GetServerInfo ( & CurrentServerInfo ) ;
2011-04-13 18:37:12 +00:00
2008-09-29 11:34:49 +00:00
// render background
2022-08-07 16:12:07 +00:00
MainView . Draw ( ms_ColorTabbarActive , IGraphics : : CORNER_B , 10.0f ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CUIRect View , ServerInfo , GameInfo , Motd ;
2011-04-13 18:37:12 +00:00
2008-09-29 11:34:49 +00:00
float x = 0.0f ;
float y = 0.0f ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
char aBuf [ 1024 ] ;
2011-04-13 18:37:12 +00:00
2008-09-29 11:34:49 +00:00
// set view to use for all sub-modules
2010-05-29 07:25:38 +00:00
MainView . Margin ( 10.0f , & View ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
// serverinfo
2022-06-12 08:34:09 +00:00
View . HSplitTop ( View . h / 2 - 5.0f , & ServerInfo , & Motd ) ;
ServerInfo . VSplitLeft ( View . w / 2 - 5.0f , & ServerInfo , & GameInfo ) ;
2022-08-07 16:12:07 +00:00
ServerInfo . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_ALL , 10.0f ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
ServerInfo . Margin ( 5.0f , & ServerInfo ) ;
2011-04-13 18:37:12 +00:00
2008-09-29 11:34:49 +00:00
x = 5.0f ;
y = 0.0f ;
2011-04-13 18:37:12 +00:00
2023-02-26 10:43:43 +00:00
TextRender ( ) - > Text ( ServerInfo . x + x , ServerInfo . y + y , 32 , Localize ( " Server info " ) , - 1.0f ) ;
2020-09-26 19:41:58 +00:00
y + = 32.0f + 5.0f ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
mem_zero ( aBuf , sizeof ( aBuf ) ) ;
2008-09-29 11:34:49 +00:00
str_format (
2010-05-29 07:25:38 +00:00
aBuf ,
sizeof ( aBuf ) ,
2008-09-29 11:34:49 +00:00
" %s \n \n "
2009-06-15 07:34:25 +00:00
" %s: %s \n "
" %s: %d \n "
" %s: %s \n "
" %s: %s \n " ,
2010-05-29 07:25:38 +00:00
CurrentServerInfo . m_aName ,
2013-12-18 03:11:26 +00:00
Localize ( " Address " ) , CurrentServerInfo . m_aAddress ,
2010-05-29 07:25:38 +00:00
Localize ( " Ping " ) , m_pClient - > m_Snap . m_pLocalInfo - > m_Latency ,
Localize ( " Version " ) , CurrentServerInfo . m_aVersion ,
2020-09-26 19:41:58 +00:00
Localize ( " Password " ) , CurrentServerInfo . m_Flags & 1 ? Localize ( " Yes " ) : Localize ( " No " ) ) ;
2011-04-13 18:37:12 +00:00
2023-02-26 10:43:43 +00:00
TextRender ( ) - > Text ( ServerInfo . x + x , ServerInfo . y + y , 20 , aBuf , ServerInfo . w - 10.0f ) ;
2011-04-13 18:37:12 +00:00
2023-01-06 20:14:26 +00:00
// copy info button
{
CUIRect Button ;
ServerInfo . HSplitBottom ( 20.0f , & ServerInfo , & Button ) ;
Button . VSplitRight ( 200.0f , & ServerInfo , & Button ) ;
static CButtonContainer s_CopyButton ;
if ( DoButton_Menu ( & s_CopyButton , Localize ( " Copy info " ) , 0 , & Button ) )
{
char aInfo [ 256 ] ;
CurrentServerInfo . InfoToString ( aInfo , sizeof ( aInfo ) ) ;
Input ( ) - > SetClipboardText ( aInfo ) ;
}
}
// favorite checkbox
2008-09-29 11:34:49 +00:00
{
2010-05-29 07:25:38 +00:00
CUIRect Button ;
2022-05-23 18:16:18 +00:00
NETADDR ServerAddr = Client ( ) - > ServerAddress ( ) ;
TRISTATE IsFavorite = Favorites ( ) - > IsFavorite ( & ServerAddr , 1 ) ;
2010-05-29 07:25:38 +00:00
ServerInfo . HSplitBottom ( 20.0f , & ServerInfo , & Button ) ;
static int s_AddFavButton = 0 ;
2022-05-23 18:16:18 +00:00
if ( DoButton_CheckBox ( & s_AddFavButton , Localize ( " Favorite " ) , IsFavorite ! = TRISTATE : : NONE , & Button ) )
2008-09-29 11:34:49 +00:00
{
2022-05-23 18:16:18 +00:00
if ( IsFavorite ! = TRISTATE : : NONE )
Favorites ( ) - > Remove ( & ServerAddr , 1 ) ;
2008-09-29 11:34:49 +00:00
else
2022-05-23 18:16:18 +00:00
Favorites ( ) - > Add ( & ServerAddr , 1 ) ;
2008-09-29 11:34:49 +00:00
}
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
// gameinfo
GameInfo . VSplitLeft ( 10.0f , 0x0 , & GameInfo ) ;
2022-08-07 16:12:07 +00:00
GameInfo . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_ALL , 10.0f ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
GameInfo . Margin ( 5.0f , & GameInfo ) ;
2011-04-13 18:37:12 +00:00
2008-09-29 11:34:49 +00:00
x = 5.0f ;
y = 0.0f ;
2011-04-13 18:37:12 +00:00
2023-02-26 10:43:43 +00:00
TextRender ( ) - > Text ( GameInfo . x + x , GameInfo . y + y , 32 , Localize ( " Game info " ) , - 1.0f ) ;
2020-09-26 19:41:58 +00:00
y + = 32.0f + 5.0f ;
2011-04-13 18:37:12 +00:00
2011-03-04 16:08:10 +00:00
if ( m_pClient - > m_Snap . m_pGameInfoObj )
{
mem_zero ( aBuf , sizeof ( aBuf ) ) ;
str_format (
aBuf ,
sizeof ( aBuf ) ,
" \n \n "
" %s: %s \n "
" %s: %s \n "
" %s: %d \n "
" %s: %d \n "
" \n "
" %s: %d/%d \n " ,
Localize ( " Game type " ) , CurrentServerInfo . m_aGameType ,
Localize ( " Map " ) , CurrentServerInfo . m_aMap ,
Localize ( " Score limit " ) , m_pClient - > m_Snap . m_pGameInfoObj - > m_ScoreLimit ,
Localize ( " Time limit " ) , m_pClient - > m_Snap . m_pGameInfoObj - > m_TimeLimit ,
2020-09-26 19:41:58 +00:00
Localize ( " Players " ) , m_pClient - > m_Snap . m_NumPlayers , CurrentServerInfo . m_MaxClients ) ;
2023-02-26 10:43:43 +00:00
TextRender ( ) - > Text ( GameInfo . x + x , GameInfo . y + y , 20 , aBuf , GameInfo . w - 10.0f ) ;
2011-03-04 16:08:10 +00:00
}
2011-04-13 18:37:12 +00:00
2023-02-19 11:17:56 +00:00
RenderServerInfoMotd ( Motd ) ;
}
void CMenus : : RenderServerInfoMotd ( CUIRect Motd )
{
2022-08-15 21:19:56 +00:00
const float MotdFontSize = 16.0f ;
Motd . HSplitTop ( 10.0f , nullptr , & Motd ) ;
2022-08-07 16:12:07 +00:00
Motd . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_ALL , 10.0f ) ;
2022-08-15 21:19:56 +00:00
Motd . HMargin ( 5.0f , & Motd ) ;
Motd . VMargin ( 10.0f , & Motd ) ;
CUIRect MotdHeader ;
Motd . HSplitTop ( 2.0f * MotdFontSize , & MotdHeader , & Motd ) ;
Motd . HSplitTop ( 5.0f , nullptr , & Motd ) ;
2023-02-17 17:13:20 +00:00
TextRender ( ) - > Text ( MotdHeader . x , MotdHeader . y , 2.0f * MotdFontSize , Localize ( " MOTD " ) , - 1.0f ) ;
2022-08-15 21:19:56 +00:00
2023-02-19 11:17:56 +00:00
if ( ! m_pClient - > m_Motd . ServerMotd ( ) [ 0 ] )
return ;
2022-08-15 21:19:56 +00:00
static CScrollRegion s_ScrollRegion ;
vec2 ScrollOffset ( 0.0f , 0.0f ) ;
CScrollRegionParams ScrollParams ;
ScrollParams . m_ScrollUnit = 5 * MotdFontSize ;
s_ScrollRegion . Begin ( & Motd , & ScrollOffset , & ScrollParams ) ;
Motd . y + = ScrollOffset . y ;
2023-02-19 11:17:56 +00:00
static float s_MotdHeight = 0.0f ;
static int64_t s_MotdLastUpdateTime = - 1 ;
if ( m_MotdTextContainerIndex = = - 1 | | s_MotdLastUpdateTime = = - 1 | | s_MotdLastUpdateTime ! = m_pClient - > m_Motd . ServerMotdUpdateTime ( ) )
{
CTextCursor Cursor ;
TextRender ( ) - > SetCursor ( & Cursor , 0.0f , 0.0f , MotdFontSize , TEXTFLAG_RENDER ) ;
Cursor . m_LineWidth = Motd . w ;
TextRender ( ) - > RecreateTextContainer ( m_MotdTextContainerIndex , & Cursor , m_pClient - > m_Motd . ServerMotd ( ) ) ;
s_MotdHeight = Cursor . Height ( ) ;
s_MotdLastUpdateTime = m_pClient - > m_Motd . ServerMotdUpdateTime ( ) ;
}
2022-08-15 21:19:56 +00:00
CUIRect MotdTextArea ;
2023-02-19 11:17:56 +00:00
Motd . HSplitTop ( s_MotdHeight , & MotdTextArea , & Motd ) ;
2022-08-15 21:19:56 +00:00
s_ScrollRegion . AddRect ( MotdTextArea ) ;
2023-02-19 11:17:56 +00:00
if ( m_MotdTextContainerIndex ! = - 1 )
TextRender ( ) - > RenderTextContainer ( m_MotdTextContainerIndex , TextRender ( ) - > DefaultTextColor ( ) , TextRender ( ) - > DefaultTextOutlineColor ( ) , MotdTextArea . x , MotdTextArea . y ) ;
2022-08-15 21:19:56 +00:00
s_ScrollRegion . End ( ) ;
2008-09-29 11:34:49 +00:00
}
2016-04-27 18:04:31 +00:00
bool CMenus : : RenderServerControlServer ( CUIRect MainView )
2008-09-29 11:34:49 +00:00
{
2010-05-29 07:25:38 +00:00
CUIRect List = MainView ;
2021-07-12 09:43:56 +00:00
int Total = m_pClient - > m_Voting . m_NumVoteOptions ;
2015-04-18 22:31:45 +00:00
int NumVoteOptions = 0 ;
2015-04-02 23:27:07 +00:00
int aIndices [ MAX_VOTE_OPTIONS ] ;
2015-03-14 14:32:04 +00:00
static int s_CurVoteOption = 0 ;
2015-07-25 16:43:54 +00:00
int TotalShown = 0 ;
2021-07-12 09:43:56 +00:00
for ( CVoteOptionClient * pOption = m_pClient - > m_Voting . m_pFirst ; pOption ; pOption = pOption - > m_pNext )
2015-07-25 16:43:54 +00:00
{
2021-06-28 20:51:14 +00:00
if ( m_aFilterString [ 0 ] ! = ' \0 ' & & ! str_utf8_find_nocase ( pOption - > m_aDescription , m_aFilterString ) )
2015-07-25 16:43:54 +00:00
continue ;
TotalShown + + ;
}
2015-03-14 10:05:08 +00:00
2023-01-05 11:21:10 +00:00
static CListBox s_ListBox ;
s_ListBox . DoStart ( 19.0f , TotalShown , 1 , 3 , s_CurVoteOption , & List ) ;
2011-04-13 18:37:12 +00:00
2015-03-14 14:32:04 +00:00
int i = - 1 ;
2021-07-12 09:43:56 +00:00
for ( CVoteOptionClient * pOption = m_pClient - > m_Voting . m_pFirst ; pOption ; pOption = pOption - > m_pNext )
2008-09-29 11:34:49 +00:00
{
2015-03-14 14:32:04 +00:00
i + + ;
2021-06-28 20:51:14 +00:00
if ( m_aFilterString [ 0 ] ! = ' \0 ' & & ! str_utf8_find_nocase ( pOption - > m_aDescription , m_aFilterString ) )
2015-03-13 15:44:05 +00:00
continue ;
2015-03-14 14:32:04 +00:00
if ( NumVoteOptions < Total )
aIndices [ NumVoteOptions ] = i ;
NumVoteOptions + + ;
2023-01-05 11:21:10 +00:00
const CListboxItem Item = s_ListBox . DoNextItem ( pOption ) ;
if ( ! Item . m_Visible )
continue ;
2023-04-09 19:24:06 +00:00
UI ( ) - > DoLabel ( & Item . m_Rect , pOption - > m_aDescription , 13.0f , TEXTALIGN_ML ) ;
2008-10-06 18:05:01 +00:00
}
2011-04-13 18:37:12 +00:00
2023-01-05 11:21:10 +00:00
s_CurVoteOption = s_ListBox . DoEnd ( ) ;
2015-03-14 14:32:04 +00:00
if ( s_CurVoteOption < Total )
m_CallvoteSelectedOption = aIndices [ s_CurVoteOption ] ;
2023-01-05 11:21:10 +00:00
return s_ListBox . WasItemActivated ( ) ;
2008-09-29 11:34:49 +00:00
}
2016-04-27 18:04:31 +00:00
bool CMenus : : RenderServerControlKick ( CUIRect MainView , bool FilterSpectators )
2008-09-29 11:34:49 +00:00
{
2010-05-31 15:36:20 +00:00
int NumOptions = 0 ;
2020-11-12 13:20:38 +00:00
int Selected = 0 ;
2010-05-31 20:05:45 +00:00
static int aPlayerIDs [ MAX_CLIENTS ] ;
Declare variables as `const` when possible
According to cppcheck's `constVariable` error:
```
src\engine\client\backend\opengl\opengl_sl.cpp:74:43: style: Variable 'Define' can be declared as reference to const [constVariable]
for(CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_vDefines)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:2149:12: style: Variable 'GraphicThreadCommandBuffer' can be declared as reference to const [constVariable]
auto &GraphicThreadCommandBuffer = m_vvThreadDrawCommandBuffers[i + 1][m_CurImageIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3192:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3200:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[State.m_Texture].m_VKStandard3DTexturedDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3810:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
for(auto &Mode : vPresentModeList)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3818:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
for(auto &Mode : vPresentModeList)
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6511:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6555:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_VKStandard3DTexturedDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6660:9: style: Variable 'MemBlock' can be declared as reference to const [constVariable]
auto &MemBlock = m_vBufferObjects[BufferIndex].m_BufferObject.m_Mem;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6799:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6808:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6902:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6907:9: style: Variable 'TextTextureDescr' can be declared as reference to const [constVariable]
auto &TextTextureDescr = m_vTextures[pCommand->m_TextTextureIndex].m_VKTextDescrSet;
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6961:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6970:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
auto &DescrSet = m_vTextures[State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
^
src\game\client\components\hud.cpp:178:8: style: Variable 'aFlagCarrier' can be declared as const array [constVariable]
int aFlagCarrier[2] = {
^
src\game\client\components\hud.cpp:519:16: style: Variable 's_aTextWidth' can be declared as const array [constVariable]
static float s_aTextWidth[5] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000};
^
src\game\client\components\killmessages.cpp:305:30: style: Variable 'Client' can be declared as reference to const [constVariable]
CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_KillerID];
^
src\game\client\components\killmessages.cpp:314:30: style: Variable 'Client' can be declared as reference to const [constVariable]
CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_VictimID];
^
src\game\client\components\menus_ingame.cpp:243:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
^
src\game\client\components\menus_ingame.cpp:530:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
^
src\game\client\components\players.cpp:767:44: style: Variable 'CharacterInfo' can be declared as reference to const [constVariable]
CGameClient::CSnapState::CCharacterInfo &CharacterInfo = m_pClient->m_Snap.m_aCharacters[i];
^
src\game\client\components\spectator.cpp:122:27: style: Variable 'Snap' can be declared as reference to const [constVariable]
CGameClient::CSnapState &Snap = pSelf->m_pClient->m_Snap;
^
src\game\client\components\spectator.cpp:221:12: style: Variable 'pInfo' can be declared as reference to const [constVariable]
for(auto &pInfo : m_pClient->m_Snap.m_apInfoByDDTeamName)
^
src\game\client\gameclient.cpp:2220:15: style: Variable 'OwnClientData' can be declared as reference to const [constVariable]
CClientData &OwnClientData = m_aClients[ownID];
^
src\game\client\gameclient.cpp:2227:16: style: Variable 'cData' can be declared as reference to const [constVariable]
CClientData &cData = m_aClients[i];
^
src\game\client\prediction\entities\character.cpp:397:11: style: Variable 'aSpreading' can be declared as const array [constVariable]
float aSpreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
^
src\game\client\prediction\entities\laser.cpp:53:9: style: Variable 'HitPos' can be declared as reference to const [constVariable]
vec2 &HitPos = pHit->Core()->m_Pos;
^
src\game\editor\auto_map.cpp:507:18: style: Variable 'Index' can be declared as reference to const [constVariable]
for(auto &Index : pRule->m_vIndexList)
^
src\game\editor\auto_map.cpp:518:18: style: Variable 'Index' can be declared as reference to const [constVariable]
for(auto &Index : pRule->m_vIndexList)
^
src\game\editor\editor.cpp:118:12: style: Variable 'Item' can be declared as reference to const [constVariable]
for(auto &Item : vList)
^
src\game\editor\editor.cpp:2983:11: style: Variable 'aAspects' can be declared as const array [constVariable]
float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
^
src\game\editor\editor.cpp:3141:15: style: Variable 's_aShift' can be declared as const array [constVariable]
static int s_aShift[] = {24, 16, 8, 0};
^
src\engine\server\server.cpp:2807:14: style: Variable 'Client' can be declared as reference to const [constVariable]
for(auto &Client : m_aClients)
^
src\engine\server\sql_string_helpers.cpp:51:6: style: Variable 'aTimes' can be declared as const array [constVariable]
int aTimes[7] =
^
src\test\secure_random.cpp:24:6: style: Variable 'BOUNDS' can be declared as const array [constVariable]
int BOUNDS[] = {2, 3, 4, 5, 10, 100, 127, 128, 129};
^
```
2022-11-13 15:29:13 +00:00
for ( const auto & pInfoByName : m_pClient - > m_Snap . m_apInfoByName )
2010-05-31 15:36:20 +00:00
{
2020-10-26 14:14:07 +00:00
if ( ! pInfoByName )
2010-05-31 15:36:20 +00:00
continue ;
2011-08-11 08:59:14 +00:00
2020-10-26 14:14:07 +00:00
int Index = pInfoByName - > m_ClientID ;
if ( Index = = m_pClient - > m_Snap . m_LocalClientID | | ( FilterSpectators & & pInfoByName - > m_Team = = TEAM_SPECTATORS ) )
2010-05-31 15:36:20 +00:00
continue ;
2015-03-14 10:05:08 +00:00
2021-06-28 20:51:14 +00:00
if ( ! str_utf8_find_nocase ( m_pClient - > m_aClients [ Index ] . m_aName , m_aFilterString ) )
2015-03-14 10:05:08 +00:00
continue ;
2011-08-04 21:43:39 +00:00
if ( m_CallvoteSelectedPlayer = = Index )
2010-05-31 20:05:45 +00:00
Selected = NumOptions ;
2011-08-04 21:43:39 +00:00
aPlayerIDs [ NumOptions + + ] = Index ;
2010-05-31 15:36:20 +00:00
}
2008-09-29 11:34:49 +00:00
2023-01-05 11:21:10 +00:00
static CListBox s_ListBox ;
s_ListBox . DoStart ( 24.0f , NumOptions , 1 , 3 , Selected , & MainView ) ;
2011-04-13 18:37:12 +00:00
2010-05-31 20:05:45 +00:00
for ( int i = 0 ; i < NumOptions ; i + + )
2008-09-29 11:34:49 +00:00
{
2023-01-05 11:21:10 +00:00
const CListboxItem Item = s_ListBox . DoNextItem ( & aPlayerIDs [ i ] ) ;
if ( ! Item . m_Visible )
continue ;
2011-04-13 18:37:12 +00:00
2023-01-05 11:21:10 +00:00
CUIRect TeeRect , Label ;
Item . m_Rect . VSplitLeft ( Item . m_Rect . h , & TeeRect , & Label ) ;
2021-04-09 18:11:53 +00:00
2023-01-05 11:21:10 +00:00
CTeeRenderInfo TeeInfo = m_pClient - > m_aClients [ aPlayerIDs [ i ] ] . m_RenderInfo ;
TeeInfo . m_Size = TeeRect . h ;
2021-04-09 18:11:53 +00:00
2023-01-05 11:21:10 +00:00
CAnimState * pIdleState = CAnimState : : GetIdle ( ) ;
vec2 OffsetToMid ;
RenderTools ( ) - > GetRenderTeeOffsetToRenderedTee ( pIdleState , & TeeInfo , OffsetToMid ) ;
vec2 TeeRenderPos ( TeeRect . x + TeeInfo . m_Size / 2 , TeeRect . y + TeeInfo . m_Size / 2 + OffsetToMid . y ) ;
2021-04-09 18:11:53 +00:00
2023-01-05 11:21:10 +00:00
RenderTools ( ) - > RenderTee ( pIdleState , & TeeInfo , EMOTE_NORMAL , vec2 ( 1.0f , 0.0f ) , TeeRenderPos ) ;
2023-04-09 19:24:06 +00:00
UI ( ) - > DoLabel ( & Label , m_pClient - > m_aClients [ aPlayerIDs [ i ] ] . m_aName , 16.0f , TEXTALIGN_ML ) ;
2008-09-29 11:34:49 +00:00
}
2011-04-13 18:37:12 +00:00
2023-01-05 11:21:10 +00:00
Selected = s_ListBox . DoEnd ( ) ;
2010-05-31 20:05:45 +00:00
m_CallvoteSelectedPlayer = Selected ! = - 1 ? aPlayerIDs [ Selected ] : - 1 ;
2023-01-05 11:21:10 +00:00
return s_ListBox . WasItemActivated ( ) ;
2008-09-29 11:34:49 +00:00
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderServerControl ( CUIRect MainView )
2008-09-29 11:34:49 +00:00
{
2010-05-29 07:25:38 +00:00
static int s_ControlPage = 0 ;
2011-04-13 18:37:12 +00:00
2008-09-29 11:34:49 +00:00
// render background
2020-10-27 17:23:20 +00:00
CUIRect Bottom , RconExtension , TabBar , Button ;
2011-04-08 22:03:56 +00:00
MainView . HSplitTop ( 20.0f , & Bottom , & MainView ) ;
2022-08-07 16:12:07 +00:00
Bottom . Draw ( ms_ColorTabbarActive , 0 , 10.0f ) ;
2011-04-08 22:03:56 +00:00
MainView . HSplitTop ( 20.0f , & TabBar , & MainView ) ;
2022-08-07 16:12:07 +00:00
MainView . Draw ( ms_ColorTabbarActive , IGraphics : : CORNER_B , 10.0f ) ;
2011-04-06 09:41:40 +00:00
MainView . Margin ( 10.0f , & MainView ) ;
2020-10-27 17:23:20 +00:00
if ( Client ( ) - > RconAuthed ( ) )
MainView . HSplitBottom ( 90.0f , & MainView , & RconExtension ) ;
2011-04-06 09:41:40 +00:00
// tab bar
2008-09-29 11:34:49 +00:00
{
2020-09-26 19:41:58 +00:00
TabBar . VSplitLeft ( TabBar . w / 3 , & Button , & TabBar ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_Button0 ;
2011-04-08 22:03:56 +00:00
if ( DoButton_MenuTab ( & s_Button0 , Localize ( " Change settings " ) , s_ControlPage = = 0 , & Button , 0 ) )
2011-04-06 09:41:40 +00:00
s_ControlPage = 0 ;
TabBar . VSplitMid ( & Button , & TabBar ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_Button1 ;
2011-04-06 09:41:40 +00:00
if ( DoButton_MenuTab ( & s_Button1 , Localize ( " Kick player " ) , s_ControlPage = = 1 , & Button , 0 ) )
s_ControlPage = 1 ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_Button2 ;
2011-04-08 22:03:56 +00:00
if ( DoButton_MenuTab ( & s_Button2 , Localize ( " Move player to spectators " ) , s_ControlPage = = 2 , & TabBar , 0 ) )
2011-04-06 09:41:40 +00:00
s_ControlPage = 2 ;
2008-09-29 11:34:49 +00:00
}
2011-03-31 13:43:12 +00:00
// render page
2020-09-26 19:41:58 +00:00
MainView . HSplitBottom ( ms_ButtonHeight + 5 * 2 , & MainView , & Bottom ) ;
2010-05-29 07:25:38 +00:00
Bottom . HMargin ( 5.0f , & Bottom ) ;
2011-03-31 13:43:12 +00:00
2016-04-27 18:04:31 +00:00
bool Call = false ;
2010-05-29 07:25:38 +00:00
if ( s_ControlPage = = 0 )
2016-04-27 18:04:31 +00:00
Call = RenderServerControlServer ( MainView ) ;
2010-05-29 07:25:38 +00:00
else if ( s_ControlPage = = 1 )
2016-04-27 18:04:31 +00:00
Call = RenderServerControlKick ( MainView , false ) ;
2011-03-26 15:56:59 +00:00
else if ( s_ControlPage = = 2 )
2016-04-27 18:04:31 +00:00
Call = RenderServerControlKick ( MainView , true ) ;
2008-09-29 11:34:49 +00:00
2011-03-31 13:43:12 +00:00
// vote menu
2008-09-29 11:34:49 +00:00
{
2022-03-20 11:57:50 +00:00
CUIRect QuickSearch ;
2015-03-13 15:15:05 +00:00
// render quick search
{
Bottom . VSplitLeft ( 240.0f , & QuickSearch , & Bottom ) ;
QuickSearch . HSplitTop ( 5.0f , 0 , & QuickSearch ) ;
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetCurFont ( TextRender ( ) - > GetFont ( TEXT_FONT_ICON_FONT ) ) ;
2020-10-06 10:25:10 +00:00
TextRender ( ) - > SetRenderFlags ( ETextRenderFlags : : TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_OVERSIZE ) ;
2022-03-11 16:34:48 +00:00
2023-04-09 19:24:06 +00:00
UI ( ) - > DoLabel ( & QuickSearch , FONT_ICON_MAGNIFYING_GLASS , 14.0f , TEXTALIGN_ML ) ;
2023-04-03 23:40:54 +00:00
float wSearch = TextRender ( ) - > TextWidth ( 14.0f , FONT_ICON_MAGNIFYING_GLASS , - 1 , - 1.0f ) ;
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetRenderFlags ( 0 ) ;
TextRender ( ) - > SetCurFont ( NULL ) ;
2015-03-13 15:15:05 +00:00
QuickSearch . VSplitLeft ( wSearch , 0 , & QuickSearch ) ;
QuickSearch . VSplitLeft ( 5.0f , 0 , & QuickSearch ) ;
2018-09-20 05:43:05 +00:00
static int s_ClearButton = 0 ;
2021-12-03 19:15:44 +00:00
static float s_Offset = 0.0f ;
2022-03-13 18:09:33 +00:00
SUIExEditBoxProperties EditProps ;
2021-12-18 11:23:20 +00:00
if ( m_ControlPageOpening | | ( Input ( ) - > KeyPress ( KEY_F ) & & Input ( ) - > ModifierIsPressed ( ) ) )
2021-03-14 18:57:21 +00:00
{
2017-07-24 16:05:19 +00:00
UI ( ) - > SetActiveItem ( & m_aFilterString ) ;
2021-03-14 18:57:21 +00:00
m_ControlPageOpening = false ;
2022-03-13 18:09:33 +00:00
EditProps . m_SelectText = true ;
2021-03-14 18:57:21 +00:00
}
2022-03-13 18:09:33 +00:00
EditProps . m_pEmptyText = Localize ( " Search " ) ;
2022-08-07 20:03:34 +00:00
UI ( ) - > DoClearableEditBox ( & m_aFilterString , & s_ClearButton , & QuickSearch , m_aFilterString , sizeof ( m_aFilterString ) , 14.0f , & s_Offset , false , IGraphics : : CORNER_ALL , EditProps ) ;
2015-03-13 15:15:05 +00:00
}
2010-05-29 07:25:38 +00:00
Bottom . VSplitRight ( 120.0f , & Bottom , & Button ) ;
2011-04-13 18:37:12 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_CallVoteButton ;
2016-04-27 18:04:31 +00:00
if ( DoButton_Menu ( & s_CallVoteButton , Localize ( " Call vote " ) , 0 , & Button ) | | Call )
2008-09-29 11:34:49 +00:00
{
2010-05-29 07:25:38 +00:00
if ( s_ControlPage = = 0 )
2016-04-27 18:04:31 +00:00
{
2021-07-12 09:43:56 +00:00
m_pClient - > m_Voting . CallvoteOption ( m_CallvoteSelectedOption , m_aCallvoteReason ) ;
2017-07-25 17:08:16 +00:00
if ( g_Config . m_UiCloseWindowAfterChangingSetting )
SetActive ( false ) ;
2016-04-27 18:04:31 +00:00
}
2010-05-29 07:25:38 +00:00
else if ( s_ControlPage = = 1 )
{
if ( m_CallvoteSelectedPlayer > = 0 & & m_CallvoteSelectedPlayer < MAX_CLIENTS & &
2022-06-30 22:36:32 +00:00
m_pClient - > m_Snap . m_apPlayerInfos [ m_CallvoteSelectedPlayer ] )
2010-05-29 07:25:38 +00:00
{
2021-07-12 09:43:56 +00:00
m_pClient - > m_Voting . CallvoteKick ( m_CallvoteSelectedPlayer , m_aCallvoteReason ) ;
2010-05-29 07:25:38 +00:00
SetActive ( false ) ;
}
}
2011-03-26 15:56:59 +00:00
else if ( s_ControlPage = = 2 )
{
if ( m_CallvoteSelectedPlayer > = 0 & & m_CallvoteSelectedPlayer < MAX_CLIENTS & &
2022-06-30 22:36:32 +00:00
m_pClient - > m_Snap . m_apPlayerInfos [ m_CallvoteSelectedPlayer ] )
2011-03-26 15:56:59 +00:00
{
2021-07-12 09:43:56 +00:00
m_pClient - > m_Voting . CallvoteSpectate ( m_CallvoteSelectedPlayer , m_aCallvoteReason ) ;
2011-03-26 15:56:59 +00:00
SetActive ( false ) ;
}
}
2011-03-25 11:06:45 +00:00
m_aCallvoteReason [ 0 ] = 0 ;
2010-05-29 07:25:38 +00:00
}
2011-04-13 18:37:12 +00:00
2010-10-09 18:34:17 +00:00
// render kick reason
2011-03-25 09:26:59 +00:00
CUIRect Reason ;
Bottom . VSplitRight ( 40.0f , & Bottom , 0 ) ;
Bottom . VSplitRight ( 160.0f , & Bottom , & Reason ) ;
Reason . HSplitTop ( 5.0f , 0 , & Reason ) ;
const char * pLabel = Localize ( " Reason: " ) ;
2023-04-09 19:24:06 +00:00
UI ( ) - > DoLabel ( & Reason , pLabel , 14.0f , TEXTALIGN_ML ) ;
2023-02-17 17:13:20 +00:00
float w = TextRender ( ) - > TextWidth ( 14.0f , pLabel , - 1 , - 1.0f ) ;
2020-09-26 19:41:58 +00:00
Reason . VSplitLeft ( w + 10.0f , 0 , & Reason ) ;
2011-03-25 09:26:59 +00:00
static float s_Offset = 0.0f ;
2021-12-18 11:23:20 +00:00
if ( Input ( ) - > KeyPress ( KEY_R ) & & Input ( ) - > ModifierIsPressed ( ) )
2017-07-24 16:05:19 +00:00
UI ( ) - > SetActiveItem ( & m_aCallvoteReason ) ;
2022-08-07 20:03:34 +00:00
UI ( ) - > DoEditBox ( & m_aCallvoteReason , & Reason , m_aCallvoteReason , sizeof ( m_aCallvoteReason ) , 14.0f , & s_Offset , false , IGraphics : : CORNER_ALL ) ;
2011-04-13 18:37:12 +00:00
2011-03-26 17:43:43 +00:00
// extended features (only available when authed in rcon)
2010-05-29 07:25:38 +00:00
if ( Client ( ) - > RconAuthed ( ) )
{
2020-10-30 03:40:15 +00:00
// background
RconExtension . Margin ( 10.0f , & RconExtension ) ;
RconExtension . HSplitTop ( 20.0f , & Bottom , & RconExtension ) ;
RconExtension . HSplitTop ( 5.0f , 0 , & RconExtension ) ;
2011-03-26 17:43:43 +00:00
// force vote
Bottom . VSplitLeft ( 5.0f , 0 , & Bottom ) ;
2010-05-29 07:25:38 +00:00
Bottom . VSplitLeft ( 120.0f , & Button , & Bottom ) ;
2020-10-27 17:23:20 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ForceVoteButton ;
2010-05-29 07:25:38 +00:00
if ( DoButton_Menu ( & s_ForceVoteButton , Localize ( " Force vote " ) , 0 , & Button ) )
2008-09-29 11:34:49 +00:00
{
2010-05-29 07:25:38 +00:00
if ( s_ControlPage = = 0 )
2021-07-12 09:43:56 +00:00
m_pClient - > m_Voting . CallvoteOption ( m_CallvoteSelectedOption , m_aCallvoteReason , true ) ;
2010-05-29 07:25:38 +00:00
else if ( s_ControlPage = = 1 )
{
if ( m_CallvoteSelectedPlayer > = 0 & & m_CallvoteSelectedPlayer < MAX_CLIENTS & &
2022-06-30 22:36:32 +00:00
m_pClient - > m_Snap . m_apPlayerInfos [ m_CallvoteSelectedPlayer ] )
2010-05-29 07:25:38 +00:00
{
2021-07-12 09:43:56 +00:00
m_pClient - > m_Voting . CallvoteKick ( m_CallvoteSelectedPlayer , m_aCallvoteReason , true ) ;
2010-05-29 07:25:38 +00:00
SetActive ( false ) ;
}
}
2011-03-26 15:56:59 +00:00
else if ( s_ControlPage = = 2 )
2008-09-29 11:34:49 +00:00
{
2010-05-29 07:25:38 +00:00
if ( m_CallvoteSelectedPlayer > = 0 & & m_CallvoteSelectedPlayer < MAX_CLIENTS & &
2022-06-30 22:36:32 +00:00
m_pClient - > m_Snap . m_apPlayerInfos [ m_CallvoteSelectedPlayer ] )
2010-05-29 07:25:38 +00:00
{
2021-07-12 09:43:56 +00:00
m_pClient - > m_Voting . CallvoteSpectate ( m_CallvoteSelectedPlayer , m_aCallvoteReason , true ) ;
2010-05-29 07:25:38 +00:00
SetActive ( false ) ;
}
2008-09-29 11:34:49 +00:00
}
2011-03-25 11:06:45 +00:00
m_aCallvoteReason [ 0 ] = 0 ;
2008-09-29 11:34:49 +00:00
}
2011-03-26 17:43:43 +00:00
if ( s_ControlPage = = 0 )
{
// remove vote
Bottom . VSplitRight ( 10.0f , & Bottom , 0 ) ;
Bottom . VSplitRight ( 120.0f , 0 , & Button ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_RemoveVoteButton ;
2011-03-26 17:43:43 +00:00
if ( DoButton_Menu ( & s_RemoveVoteButton , Localize ( " Remove " ) , 0 , & Button ) )
2021-07-12 09:43:56 +00:00
m_pClient - > m_Voting . RemovevoteOption ( m_CallvoteSelectedOption ) ;
2011-04-13 18:37:12 +00:00
2011-03-26 17:43:43 +00:00
// add vote
2020-10-27 17:23:20 +00:00
RconExtension . HSplitTop ( 20.0f , & Bottom , & RconExtension ) ;
2011-03-26 17:43:43 +00:00
Bottom . VSplitLeft ( 5.0f , 0 , & Bottom ) ;
Bottom . VSplitLeft ( 250.0f , & Button , & Bottom ) ;
2023-04-09 19:24:06 +00:00
UI ( ) - > DoLabel ( & Button , Localize ( " Vote description: " ) , 14.0f , TEXTALIGN_ML ) ;
2011-03-26 17:43:43 +00:00
Bottom . VSplitLeft ( 20.0f , 0 , & Button ) ;
2023-04-09 19:24:06 +00:00
UI ( ) - > DoLabel ( & Button , Localize ( " Vote command: " ) , 14.0f , TEXTALIGN_ML ) ;
2011-03-26 17:43:43 +00:00
static char s_aVoteDescription [ 64 ] = { 0 } ;
static char s_aVoteCommand [ 512 ] = { 0 } ;
2020-10-27 17:23:20 +00:00
RconExtension . HSplitTop ( 20.0f , & Bottom , & RconExtension ) ;
2011-03-26 17:43:43 +00:00
Bottom . VSplitRight ( 10.0f , & Bottom , 0 ) ;
Bottom . VSplitRight ( 120.0f , & Bottom , & Button ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_AddVoteButton ;
2011-03-26 17:43:43 +00:00
if ( DoButton_Menu ( & s_AddVoteButton , Localize ( " Add " ) , 0 , & Button ) )
2011-04-05 18:06:41 +00:00
if ( s_aVoteDescription [ 0 ] ! = 0 & & s_aVoteCommand [ 0 ] ! = 0 )
2021-07-12 09:43:56 +00:00
m_pClient - > m_Voting . AddvoteOption ( s_aVoteDescription , s_aVoteCommand ) ;
2011-03-26 17:43:43 +00:00
Bottom . VSplitLeft ( 5.0f , 0 , & Bottom ) ;
Bottom . VSplitLeft ( 250.0f , & Button , & Bottom ) ;
static float s_OffsetDesc = 0.0f ;
2022-08-07 20:03:34 +00:00
UI ( ) - > DoEditBox ( & s_aVoteDescription , & Button , s_aVoteDescription , sizeof ( s_aVoteDescription ) , 14.0f , & s_OffsetDesc , false , IGraphics : : CORNER_ALL ) ;
2011-03-26 17:43:43 +00:00
2011-04-13 18:37:12 +00:00
Bottom . VMargin ( 20.0f , & Button ) ;
2011-03-26 17:43:43 +00:00
static float s_OffsetCmd = 0.0f ;
2022-08-07 20:03:34 +00:00
UI ( ) - > DoEditBox ( & s_aVoteCommand , & Button , s_aVoteCommand , sizeof ( s_aVoteCommand ) , 14.0f , & s_OffsetCmd , false , IGraphics : : CORNER_ALL ) ;
2008-09-29 11:34:49 +00:00
}
}
2011-03-31 13:43:12 +00:00
}
2011-02-23 07:33:21 +00:00
}
2016-04-27 18:14:03 +00:00
void CMenus : : RenderInGameNetwork ( CUIRect MainView )
2010-10-29 22:44:52 +00:00
{
CUIRect Box = MainView ;
CUIRect Button ;
2015-10-04 16:54:13 +00:00
int Page = g_Config . m_UiPage ;
2010-10-29 22:44:52 +00:00
int NewPage = - 1 ;
2022-08-07 16:12:07 +00:00
MainView . Draw ( ms_ColorTabbarActive , IGraphics : : CORNER_B , 10.0f ) ;
2010-10-29 22:44:52 +00:00
Box . HSplitTop ( 5.0f , & MainView , & MainView ) ;
Box . HSplitTop ( 24.0f , & Box , & MainView ) ;
Box . VSplitLeft ( 100.0f , & Button , & Box ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_InternetButton ;
2020-09-26 19:41:58 +00:00
if ( DoButton_MenuTab ( & s_InternetButton , Localize ( " Internet " ) , Page = = PAGE_INTERNET , & Button , 0 ) )
2010-10-29 22:44:52 +00:00
{
2018-03-13 20:59:07 +00:00
if ( Page ! = PAGE_INTERNET )
2015-10-04 16:54:13 +00:00
ServerBrowser ( ) - > Refresh ( IServerBrowser : : TYPE_INTERNET ) ;
2010-10-29 22:44:52 +00:00
NewPage = PAGE_INTERNET ;
}
Box . VSplitLeft ( 80.0f , & Button , & Box ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_LanButton ;
2020-09-26 19:41:58 +00:00
if ( DoButton_MenuTab ( & s_LanButton , Localize ( " LAN " ) , Page = = PAGE_LAN , & Button , 0 ) )
2010-10-29 22:44:52 +00:00
{
2018-03-13 20:59:07 +00:00
if ( Page ! = PAGE_LAN )
2015-10-04 16:54:13 +00:00
ServerBrowser ( ) - > Refresh ( IServerBrowser : : TYPE_LAN ) ;
2010-10-29 22:44:52 +00:00
NewPage = PAGE_LAN ;
}
Box . VSplitLeft ( 110.0f , & Button , & Box ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_FavoritesButton ;
2020-09-26 19:41:58 +00:00
if ( DoButton_MenuTab ( & s_FavoritesButton , Localize ( " Favorites " ) , Page = = PAGE_FAVORITES , & Button , 0 ) )
2010-10-29 22:44:52 +00:00
{
2018-03-13 20:59:07 +00:00
if ( Page ! = PAGE_FAVORITES )
2015-10-04 16:54:13 +00:00
ServerBrowser ( ) - > Refresh ( IServerBrowser : : TYPE_FAVORITES ) ;
2019-03-24 22:15:38 +00:00
NewPage = PAGE_FAVORITES ;
2010-10-29 22:44:52 +00:00
}
2014-09-20 11:41:20 +00:00
Box . VSplitLeft ( 110.0f , & Button , & Box ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_DDNetButton ;
2020-09-26 19:41:58 +00:00
if ( DoButton_MenuTab ( & s_DDNetButton , " DDNet " , Page = = PAGE_DDNET , & Button , 0 ) | | Page < PAGE_INTERNET | | Page > PAGE_KOG )
2014-09-20 11:41:20 +00:00
{
2018-03-13 20:59:07 +00:00
if ( Page ! = PAGE_DDNET )
2017-09-03 16:17:21 +00:00
{
Client ( ) - > RequestDDNetInfo ( ) ;
2015-10-04 16:54:13 +00:00
ServerBrowser ( ) - > Refresh ( IServerBrowser : : TYPE_DDNET ) ;
2017-09-03 16:17:21 +00:00
}
2019-03-24 22:15:38 +00:00
NewPage = PAGE_DDNET ;
}
Box . VSplitLeft ( 110.0f , & Button , & Box ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_KoGButton ;
2022-07-26 19:17:29 +00:00
if ( DoButton_MenuTab ( & s_KoGButton , " KoG " , Page = = PAGE_KOG , & Button , IGraphics : : CORNER_BR ) )
2019-03-24 22:15:38 +00:00
{
if ( Page ! = PAGE_KOG )
{
Client ( ) - > RequestDDNetInfo ( ) ;
ServerBrowser ( ) - > Refresh ( IServerBrowser : : TYPE_KOG ) ;
}
NewPage = PAGE_KOG ;
2014-09-20 11:41:20 +00:00
}
2010-10-29 22:44:52 +00:00
if ( NewPage ! = - 1 )
{
if ( Client ( ) - > State ( ) ! = IClient : : STATE_OFFLINE )
2020-09-16 05:36:47 +00:00
SetMenuPage ( NewPage ) ;
2010-10-29 22:44:52 +00:00
}
RenderServerbrowser ( MainView ) ;
}
2011-02-04 17:25:04 +00:00
// ghost stuff
2011-04-09 06:41:31 +00:00
int CMenus : : GhostlistFetchCallback ( const char * pName , int IsDir , int StorageType , void * pUser )
2011-02-04 17:25:04 +00:00
{
CMenus * pSelf = ( CMenus * ) pUser ;
2017-09-28 17:13:20 +00:00
const char * pMap = pSelf - > Client ( ) - > GetCurrentMap ( ) ;
2018-07-25 08:29:05 +00:00
if ( IsDir | | ! str_endswith ( pName , " .gho " ) | | ! str_startswith ( pName , pMap ) )
2011-04-09 06:41:31 +00:00
return 0 ;
2021-09-13 08:06:34 +00:00
char aFilename [ IO_MAX_PATH_LENGTH ] ;
2021-07-12 09:43:56 +00:00
str_format ( aFilename , sizeof ( aFilename ) , " %s/%s " , pSelf - > m_pClient - > m_Ghost . GetGhostDir ( ) , pName ) ;
2017-09-09 15:04:19 +00:00
2020-10-10 20:58:33 +00:00
CGhostInfo Info ;
2021-07-12 09:43:56 +00:00
if ( ! pSelf - > m_pClient - > m_Ghost . GhostLoader ( ) - > GetGhostInfo ( aFilename , & Info , pMap , pSelf - > Client ( ) - > GetCurrentMapSha256 ( ) , pSelf - > Client ( ) - > GetCurrentMapCrc ( ) ) )
2011-04-09 06:41:31 +00:00
return 0 ;
2011-02-04 17:25:04 +00:00
CGhostItem Item ;
2022-07-09 16:14:56 +00:00
str_copy ( Item . m_aFilename , aFilename ) ;
str_copy ( Item . m_aPlayer , Info . m_aOwner ) ;
2020-10-10 20:58:33 +00:00
Item . m_Time = Info . m_Time ;
2017-09-09 15:04:19 +00:00
if ( Item . m_Time > 0 )
2022-06-11 19:38:18 +00:00
pSelf - > m_vGhosts . push_back ( Item ) ;
2022-04-02 11:37:59 +00:00
2022-06-13 16:07:29 +00:00
if ( time_get_nanoseconds ( ) - pSelf - > m_GhostPopulateStartTime > 500 ms )
2022-04-02 11:37:59 +00:00
{
2022-06-23 17:59:38 +00:00
pSelf - > GameClient ( ) - > m_Menus . RenderLoading ( Localize ( " Loading ghost files " ) , " " , 0 , false ) ;
2022-04-02 11:37:59 +00:00
}
2011-04-09 06:41:31 +00:00
return 0 ;
2011-02-04 17:25:04 +00:00
}
void CMenus : : GhostlistPopulate ( )
{
2022-06-11 19:38:18 +00:00
m_vGhosts . clear ( ) ;
2022-06-13 16:07:29 +00:00
m_GhostPopulateStartTime = time_get_nanoseconds ( ) ;
2021-07-12 09:43:56 +00:00
Storage ( ) - > ListDirectory ( IStorage : : TYPE_ALL , m_pClient - > m_Ghost . GetGhostDir ( ) , GhostlistFetchCallback , this ) ;
2022-06-11 19:38:18 +00:00
std : : sort ( m_vGhosts . begin ( ) , m_vGhosts . end ( ) ) ;
2011-04-09 06:41:31 +00:00
2022-05-23 19:36:04 +00:00
CGhostItem * pOwnGhost = 0 ;
2022-06-11 19:38:18 +00:00
for ( auto & Ghost : m_vGhosts )
2022-05-23 19:36:04 +00:00
if ( str_comp ( Ghost . m_aPlayer , Client ( ) - > PlayerName ( ) ) = = 0 & & ( ! pOwnGhost | | Ghost < * pOwnGhost ) )
pOwnGhost = & Ghost ;
2011-04-09 06:41:31 +00:00
2017-09-09 16:25:32 +00:00
if ( pOwnGhost )
2011-02-04 17:25:04 +00:00
{
2017-09-09 16:25:32 +00:00
pOwnGhost - > m_Own = true ;
2021-07-12 09:43:56 +00:00
pOwnGhost - > m_Slot = m_pClient - > m_Ghost . Load ( pOwnGhost - > m_aFilename ) ;
2011-02-04 17:25:04 +00:00
}
}
2017-09-09 16:25:32 +00:00
CMenus : : CGhostItem * CMenus : : GetOwnGhost ( )
{
2022-06-11 19:38:18 +00:00
for ( auto & Ghost : m_vGhosts )
2022-05-23 19:36:04 +00:00
if ( Ghost . m_Own )
return & Ghost ;
return nullptr ;
2017-09-09 16:25:32 +00:00
}
2017-09-10 01:48:22 +00:00
void CMenus : : UpdateOwnGhost ( CGhostItem Item )
{
int Own = - 1 ;
2022-06-11 19:38:18 +00:00
for ( size_t i = 0 ; i < m_vGhosts . size ( ) ; i + + )
if ( m_vGhosts [ i ] . m_Own )
2017-09-10 01:48:22 +00:00
Own = i ;
if ( Own ! = - 1 )
{
2022-06-11 19:38:18 +00:00
m_vGhosts [ Own ] . m_Slot = - 1 ;
m_vGhosts [ Own ] . m_Own = false ;
if ( Item . HasFile ( ) | | ! m_vGhosts [ Own ] . HasFile ( ) )
2017-09-10 01:48:22 +00:00
DeleteGhostItem ( Own ) ;
}
Item . m_Own = true ;
2022-06-11 19:38:18 +00:00
m_vGhosts . insert ( std : : lower_bound ( m_vGhosts . begin ( ) , m_vGhosts . end ( ) , Item ) , Item ) ;
2017-09-10 01:48:22 +00:00
}
void CMenus : : DeleteGhostItem ( int Index )
{
2022-06-11 19:38:18 +00:00
if ( m_vGhosts [ Index ] . HasFile ( ) )
Storage ( ) - > RemoveFile ( m_vGhosts [ Index ] . m_aFilename , IStorage : : TYPE_SAVE ) ;
m_vGhosts . erase ( m_vGhosts . begin ( ) + Index ) ;
2017-09-10 01:48:22 +00:00
}
2011-02-04 17:25:04 +00:00
void CMenus : : RenderGhost ( CUIRect MainView )
{
// render background
2022-08-07 16:12:07 +00:00
MainView . Draw ( ms_ColorTabbarActive , IGraphics : : CORNER_B , 10.0f ) ;
2011-04-09 06:41:31 +00:00
2011-02-04 17:25:04 +00:00
MainView . HSplitTop ( 10.0f , 0 , & MainView ) ;
MainView . HSplitBottom ( 5.0f , & MainView , 0 ) ;
MainView . VSplitLeft ( 5.0f , 0 , & MainView ) ;
MainView . VSplitRight ( 5.0f , & MainView , 0 ) ;
2011-04-09 06:41:31 +00:00
2011-02-04 17:25:04 +00:00
CUIRect Headers , Status ;
CUIRect View = MainView ;
View . HSplitTop ( 17.0f , & Headers , & View ) ;
View . HSplitBottom ( 28.0f , & View , & Status ) ;
// split of the scrollbar
2022-08-07 16:12:07 +00:00
Headers . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_T , 5.0f ) ;
2011-02-04 17:25:04 +00:00
Headers . VSplitRight ( 20.0f , & Headers , 0 ) ;
2011-04-09 06:41:31 +00:00
2011-02-04 17:25:04 +00:00
struct CColumn
{
CLocConstString m_Caption ;
2022-07-09 15:07:30 +00:00
int m_Id ;
2011-02-04 17:25:04 +00:00
float m_Width ;
CUIRect m_Rect ;
CUIRect m_Spacer ;
} ;
2011-04-09 06:41:31 +00:00
2011-02-04 17:25:04 +00:00
enum
{
2020-09-26 19:41:58 +00:00
COL_ACTIVE = 0 ,
2011-02-04 17:25:04 +00:00
COL_NAME ,
COL_TIME ,
} ;
2011-04-09 06:41:31 +00:00
2011-02-04 17:25:04 +00:00
static CColumn s_aCols [ ] = {
2022-07-09 15:07:30 +00:00
{ " " , - 1 , 2.0f , { 0 } , { 0 } } ,
{ " " , COL_ACTIVE , 30.0f , { 0 } , { 0 } } ,
2022-12-09 15:15:19 +00:00
{ Localizable ( " Name " ) , COL_NAME , 300.0f , { 0 } , { 0 } } ,
{ Localizable ( " Time " ) , COL_TIME , 200.0f , { 0 } , { 0 } } ,
2011-02-04 17:25:04 +00:00
} ;
2011-04-09 06:41:31 +00:00
2022-03-30 13:16:19 +00:00
int NumCols = std : : size ( s_aCols ) ;
2011-04-09 06:41:31 +00:00
2011-02-04 17:25:04 +00:00
// do layout
for ( int i = 0 ; i < NumCols ; i + + )
{
Headers . VSplitLeft ( s_aCols [ i ] . m_Width , & s_aCols [ i ] . m_Rect , & Headers ) ;
2020-09-26 19:41:58 +00:00
if ( i + 1 < NumCols )
2011-02-04 17:25:04 +00:00
Headers . VSplitLeft ( 2 , & s_aCols [ i ] . m_Spacer , & Headers ) ;
}
2011-04-09 06:41:31 +00:00
2011-02-04 17:25:04 +00:00
// do headers
for ( int i = 0 ; i < NumCols ; i + + )
2021-06-11 05:31:30 +00:00
DoButton_GridHeader ( s_aCols [ i ] . m_Caption , Localize ( s_aCols [ i ] . m_Caption ) , 0 , & s_aCols [ i ] . m_Rect ) ;
2011-04-09 06:41:31 +00:00
2022-08-07 16:12:07 +00:00
View . Draw ( ColorRGBA ( 0 , 0 , 0 , 0.15f ) , 0 , 0 ) ;
2011-02-04 17:25:04 +00:00
2023-01-05 11:21:10 +00:00
const int NumGhosts = m_vGhosts . size ( ) ;
2021-12-03 18:54:22 +00:00
static int s_SelectedIndex = 0 ;
2023-01-05 11:21:10 +00:00
static CListBox s_ListBox ;
s_ListBox . DoStart ( 17.0f , NumGhosts , 1 , 3 , s_SelectedIndex , & View , false ) ;
2011-02-11 06:00:12 +00:00
2018-03-13 20:59:07 +00:00
for ( int i = 0 ; i < NumGhosts ; i + + )
2011-02-04 17:25:04 +00:00
{
2023-01-05 11:21:10 +00:00
const CGhostItem * pGhost = & m_vGhosts [ i ] ;
const CListboxItem Item = s_ListBox . DoNextItem ( pGhost ) ;
if ( ! Item . m_Visible )
continue ;
2011-02-04 17:25:04 +00:00
2019-04-26 12:06:32 +00:00
ColorRGBA rgb = ColorRGBA ( 1.0f , 1.0f , 1.0f ) ;
2023-01-05 11:21:10 +00:00
if ( pGhost - > m_Own )
2019-04-26 12:06:32 +00:00
rgb = color_cast < ColorRGBA > ( ColorHSLA ( 0.33f , 1.0f , 0.75f ) ) ;
2017-09-10 01:48:22 +00:00
2023-01-05 11:21:10 +00:00
TextRender ( ) - > TextColor ( rgb . WithAlpha ( pGhost - > HasFile ( ) ? 1.0f : 0.5f ) ) ;
2017-09-09 18:19:44 +00:00
2011-02-04 17:25:04 +00:00
for ( int c = 0 ; c < NumCols ; c + + )
{
CUIRect Button ;
Button . x = s_aCols [ c ] . m_Rect . x ;
2023-01-05 11:21:10 +00:00
Button . y = Item . m_Rect . y ;
Button . h = Item . m_Rect . h ;
2011-02-04 17:25:04 +00:00
Button . w = s_aCols [ c ] . m_Rect . w ;
int Id = s_aCols [ c ] . m_Id ;
if ( Id = = COL_ACTIVE )
{
2023-01-05 11:21:10 +00:00
if ( pGhost - > Active ( ) )
2011-02-04 17:25:04 +00:00
{
2020-10-09 07:07:05 +00:00
Graphics ( ) - > WrapClamp ( ) ;
2022-06-25 08:39:39 +00:00
Graphics ( ) - > TextureSet ( GameClient ( ) - > m_EmoticonsSkin . m_aSpriteEmoticons [ ( SPRITE_OOP + 7 ) - SPRITE_OOP ] ) ;
2011-02-04 17:25:04 +00:00
Graphics ( ) - > QuadsBegin ( ) ;
2020-09-26 19:41:58 +00:00
IGraphics : : CQuadItem QuadItem ( Button . x + Button . w / 2 , Button . y + Button . h / 2 , 20.0f , 20.0f ) ;
2011-02-04 17:25:04 +00:00
Graphics ( ) - > QuadsDraw ( & QuadItem , 1 ) ;
Graphics ( ) - > QuadsEnd ( ) ;
2020-10-09 07:07:05 +00:00
Graphics ( ) - > WrapNormal ( ) ;
2011-02-04 17:25:04 +00:00
}
}
else if ( Id = = COL_NAME )
{
CTextCursor Cursor ;
2022-06-12 08:34:09 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Button . x , Button . y + ( Button . h - 12.0f ) / 2.f , 12.0f , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-02-04 17:25:04 +00:00
Cursor . m_LineWidth = Button . w ;
2023-01-05 11:21:10 +00:00
TextRender ( ) - > TextEx ( & Cursor , pGhost - > m_aPlayer , - 1 ) ;
2011-02-04 17:25:04 +00:00
}
else if ( Id = = COL_TIME )
{
CTextCursor Cursor ;
2022-06-12 08:34:09 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Button . x , Button . y + ( Button . h - 12.0f ) / 2.f , 12.0f , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-02-04 17:25:04 +00:00
Cursor . m_LineWidth = Button . w ;
char aBuf [ 64 ] ;
2023-01-05 11:21:10 +00:00
str_time ( pGhost - > m_Time / 10 , TIME_HOURS_CENTISECS , aBuf , sizeof ( aBuf ) ) ;
2011-02-04 17:25:04 +00:00
TextRender ( ) - > TextEx ( & Cursor , aBuf , - 1 ) ;
}
}
2017-09-09 18:19:44 +00:00
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
2011-02-04 17:25:04 +00:00
}
2011-04-09 06:41:31 +00:00
2023-01-05 11:21:10 +00:00
s_SelectedIndex = s_ListBox . DoEnd ( ) ;
2011-04-09 06:41:31 +00:00
2022-08-07 16:12:07 +00:00
Status . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_B , 5.0f ) ;
2011-02-04 17:25:04 +00:00
Status . Margin ( 5.0f , & Status ) ;
2011-04-09 06:41:31 +00:00
2011-02-04 17:25:04 +00:00
CUIRect Button ;
2017-09-17 22:57:21 +00:00
Status . VSplitLeft ( 120.0f , & Button , & Status ) ;
2011-04-09 06:41:31 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ReloadButton ;
2020-11-12 13:20:38 +00:00
if ( DoButton_Menu ( & s_ReloadButton , Localize ( " Reload " ) , 0 , & Button ) | | Input ( ) - > KeyPress ( KEY_F5 ) )
2017-09-17 22:57:21 +00:00
{
2021-07-12 09:43:56 +00:00
m_pClient - > m_Ghost . UnloadAll ( ) ;
2017-09-17 22:57:21 +00:00
GhostlistPopulate ( ) ;
}
2022-06-11 19:38:18 +00:00
if ( s_SelectedIndex = = - 1 | | s_SelectedIndex > = ( int ) m_vGhosts . size ( ) )
2017-09-17 22:57:21 +00:00
return ;
2022-06-11 19:38:18 +00:00
CGhostItem * pGhost = & m_vGhosts [ s_SelectedIndex ] ;
2011-04-09 06:41:31 +00:00
2017-09-10 02:57:03 +00:00
CGhostItem * pOwnGhost = GetOwnGhost ( ) ;
int ReservedSlots = ! pGhost - > m_Own & & ! ( pOwnGhost & & pOwnGhost - > Active ( ) ) ;
2021-07-12 09:43:56 +00:00
if ( pGhost - > HasFile ( ) & & ( pGhost - > Active ( ) | | m_pClient - > m_Ghost . FreeSlots ( ) > ReservedSlots ) )
2011-02-04 17:25:04 +00:00
{
2017-09-10 01:48:22 +00:00
Status . VSplitRight ( 120.0f , & Status , & Button ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_GhostButton ;
2017-09-10 01:48:22 +00:00
const char * pText = pGhost - > Active ( ) ? Localize ( " Deactivate " ) : Localize ( " Activate " ) ;
2023-01-05 11:21:10 +00:00
if ( DoButton_Menu ( & s_GhostButton , pText , 0 , & Button ) | | s_ListBox . WasItemActivated ( ) )
2017-09-09 16:25:32 +00:00
{
2017-09-10 01:48:22 +00:00
if ( pGhost - > Active ( ) )
{
2021-07-12 09:43:56 +00:00
m_pClient - > m_Ghost . Unload ( pGhost - > m_Slot ) ;
2017-09-10 01:48:22 +00:00
pGhost - > m_Slot = - 1 ;
}
else
2021-07-12 09:43:56 +00:00
pGhost - > m_Slot = m_pClient - > m_Ghost . Load ( pGhost - > m_aFilename ) ;
2017-09-09 16:25:32 +00:00
}
2017-09-10 01:48:22 +00:00
Status . VSplitRight ( 5.0f , & Status , 0 ) ;
}
Status . VSplitRight ( 120.0f , & Status , & Button ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_DeleteButton ;
2017-09-10 01:48:22 +00:00
if ( DoButton_Menu ( & s_DeleteButton , Localize ( " Delete " ) , 0 , & Button ) )
{
if ( pGhost - > Active ( ) )
2021-07-12 09:43:56 +00:00
m_pClient - > m_Ghost . Unload ( pGhost - > m_Slot ) ;
2017-09-10 01:48:22 +00:00
DeleteGhostItem ( s_SelectedIndex ) ;
}
Status . VSplitRight ( 5.0f , & Status , 0 ) ;
2021-07-12 09:43:56 +00:00
bool Recording = m_pClient - > m_Ghost . GhostRecorder ( ) - > IsRecording ( ) ;
2017-09-10 01:48:22 +00:00
if ( ! pGhost - > HasFile ( ) & & ! Recording & & pGhost - > Active ( ) )
{
2022-07-16 13:32:06 +00:00
static CButtonContainer s_SaveButton ;
2017-09-10 01:48:22 +00:00
Status . VSplitRight ( 120.0f , & Status , & Button ) ;
if ( DoButton_Menu ( & s_SaveButton , Localize ( " Save " ) , 0 , & Button ) )
2021-07-12 09:43:56 +00:00
m_pClient - > m_Ghost . SaveGhost ( pGhost ) ;
2011-02-04 17:25:04 +00:00
}
}
2022-10-02 22:11:01 +00:00
void CMenus : : RenderIngameHint ( )
{
float Width = 300 * Graphics ( ) - > ScreenAspect ( ) ;
Graphics ( ) - > MapScreen ( 0 , 0 , Width , 300 ) ;
TextRender ( ) - > TextColor ( 1 , 1 , 1 , 1 ) ;
2023-02-17 17:13:20 +00:00
TextRender ( ) - > Text ( 5 , 280 , 5 , Localize ( " Menu opened. Press Esc key again to close menu. " ) , - 1.0f ) ;
2022-10-02 22:11:01 +00:00
UI ( ) - > MapScreen ( ) ;
}