From bf435e8b72bb49f6ec1eb29f88011e11b364cc34 Mon Sep 17 00:00:00 2001 From: Corantin H Date: Thu, 23 May 2019 23:17:12 +0200 Subject: [PATCH] coding style + added cl_notification_time --- .gitignore | 3 --- src/engine/client.h | 6 +++--- src/engine/client/client.cpp | 20 +++++++++---------- src/engine/shared/config_variables.h | 1 + src/game/client/components/hud.cpp | 8 ++++---- src/game/client/components/menus_settings.cpp | 6 +++--- 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 69cd83ee0..80aa3dec0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,9 +3,6 @@ data/ !/data/ -build/ -!/build/ - bundle/ !/other/bundle/ diff --git a/src/engine/client.h b/src/engine/client.h index 94d3f7449..605d84ad5 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -34,7 +34,7 @@ protected: // quick access to state of the client int m_State; - CHudNotification m_curNotif; + CHudNotification m_CurrentNotification; // quick access to time variables int m_PrevGameTick[2]; @@ -82,8 +82,8 @@ public: STATE_QUITING, }; - inline CHudNotification *CurrentNotification() { return &m_curNotif; }; - inline bool HasNotification() { return m_curNotif.m_pTitle; }; + inline CHudNotification *CurrentNotification() { return &m_CurrentNotification; }; + inline bool HasNotification() { return m_CurrentNotification.m_pTitle; }; // inline int State() const { return m_State; } diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 31b989a94..280a13dd2 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3322,9 +3322,9 @@ void CClient::SaveReplay() char *pSrc = (&m_DemoRecorder[RECORDER_REPLAYS])->GetCurrentFilename(); // Slice the demo to get only the last cl_replay_length seconds - const int endTick = GameTick(); - const int startTick = endTick - g_Config.m_ClReplayLength * GameTickSpeed(); - m_DemoEditor.Slice(pSrc, aFilename, startTick, endTick, NULL, 0); + const int EndTick = GameTick(); + const int StartTick = EndTick - g_Config.m_ClReplayLength * GameTickSpeed(); + m_DemoEditor.Slice(pSrc, aFilename, StartTick, EndTick, NULL, 0); const char *pFilename = (&m_DemoRecorder[RECORDER_REPLAYS])->GetCurrentFilename(); Storage()->RemoveFile(pFilename, IStorage::TYPE_SAVE); @@ -3342,18 +3342,16 @@ void CClient::SaveReplay() void CClient::Notify(const char *pTitle, const char *pMessage) { - int duration = 3; // Arbitrary value for now - EndNotification(); - new CHudNotification(m_curNotif); - m_curNotif.m_pTitle = pTitle; - m_curNotif.m_pMessage = pMessage; - m_curNotif.m_ExpireTime = time_get() + duration * time_freq(); + new CHudNotification(m_CurrentNotification); + m_CurrentNotification.m_pTitle = pTitle; + m_CurrentNotification.m_pMessage = pMessage; + m_CurrentNotification.m_ExpireTime = time_get() + g_Config.m_ClNotificationTime * time_freq(); } void CClient::EndNotification() { - mem_zero(&m_curNotif, sizeof(m_curNotif)); + mem_zero(&m_CurrentNotification, sizeof(m_CurrentNotification)); } void CClient::DemoSlice(const char *pDstPath, CLIENTFUNC_FILTER pfnFilter, void *pUser) @@ -3711,7 +3709,7 @@ void CClient::RegisterCommands() m_pConsole->Register("demo_play", "", CFGFLAG_CLIENT, Con_DemoPlay, this, "Play demo"); m_pConsole->Register("demo_speed", "i[speed]", CFGFLAG_CLIENT, Con_DemoSpeed, this, "Set demo speed"); - m_pConsole->Register("save_replay", "", CFGFLAG_CLIENT, Con_SaveReplay, this, "Save a replay of 30 seconds"); + m_pConsole->Register("save_replay", "", CFGFLAG_CLIENT, Con_SaveReplay, this, "Save a replay of the last defined amount of seconds"); m_pConsole->Chain("cl_timeout_seed", ConchainTimeoutSeed, this); diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index b5d91a1d5..8362bfb35 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -266,6 +266,7 @@ MACRO_CONFIG_INT(ClScoreboardOnDeath, cl_scoreboard_on_death, 1, 0, 1, CFGFLAG_S MACRO_CONFIG_INT(ClAutoRaceRecord, cl_auto_race_record, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Save the best demo of each race") MACRO_CONFIG_INT(ClRaceReplays, cl_race_replays, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Enable replays") MACRO_CONFIG_INT(ClReplayLength, cl_replay_length, 10, 5, 30, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Set the length of the replays") +MACRO_CONFIG_INT(ClNotificationTime, cl_notification_time, 1, 3, 10, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Set the duration of the notifications (how many seconds they should stay on the screen)") MACRO_CONFIG_INT(ClRaceRecordServerControl, cl_race_record_server_control, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Let the server start the race recorder") MACRO_CONFIG_INT(ClDemoName, cl_demo_name, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Save the player name within the demo") MACRO_CONFIG_INT(ClDemoAssumeRace, cl_demo_assume_race, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Assume that demos are race demos") diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 7015aab5c..3dc7c9dbe 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -822,24 +822,24 @@ void CHud::RenderNotification() const char *pTitle = pNotif->m_pTitle; const char *pMessage = pNotif->m_pMessage; - float Width = 120.0f; + float TextWidth = 120.0f; float Height = 40.0f; Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(0, 0, 0, 0.40f); - RenderTools()->DrawRoundRect(150.0f*Graphics()->ScreenAspect() - Width / 2.0f, 40, Width, Height, 5.0f); + RenderTools()->DrawRoundRect(150.0f*Graphics()->ScreenAspect() - TextWidth / 2.0f, 40, TextWidth, Height, 5.0f); Graphics()->QuadsEnd(); TextRender()->TextColor(1, 1, 1, 1); float FontSize = 9.0f; float w = TextRender()->TextWidth(0, FontSize, pTitle, -1); - TextRender()->Text(0, 150.0f*Graphics()->ScreenAspect() - w/2.0f, 50.0f, FontSize, pTitle, Width - 20); + TextRender()->Text(0, 150.0f*Graphics()->ScreenAspect() - w/2.0f, 50.0f, FontSize, pTitle, TextWidth - 20); FontSize = 6.0f; w = TextRender()->TextWidth(0, FontSize, pMessage, strlen(pMessage)); - TextRender()->Text(0, 150.0f*Graphics()->ScreenAspect() - w/2.0f, 62.0f, FontSize, pMessage, Width - 20); + TextRender()->Text(0, 150.0f*Graphics()->ScreenAspect() - w/2.0f, 62.0f, FontSize, pMessage, TextWidth - 20); } void CHud::OnMessage(int MsgType, void *pRawMsg) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index ff61e4a32..eea03beab 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -2008,11 +2008,11 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) str_format(aBuf, sizeof(aBuf), Localize("Length: %d"), g_Config.m_ClReplayLength); UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1); - int fakeLength = g_Config.m_ClReplayLength - 5; // minimum length is 5 not 0 + int FakeLength = g_Config.m_ClReplayLength - 5; // minimum length is 5 not 0 - fakeLength = (int)(DoScrollbarH(&fakeLength, &Button, fakeLength / 25.0f)*25.0f); + FakeLength = (int)(DoScrollbarH(&FakeLength, &Button, FakeLength / 25.0f)*25.0f); - g_Config.m_ClReplayLength = fakeLength + 5; + g_Config.m_ClReplayLength = FakeLength + 5; if(DoButton_CheckBox(&g_Config.m_ClRaceReplays, Localize("Enable replays"), g_Config.m_ClRaceReplays, &LeftLeft)) {