coding style + added cl_notification_time

This commit is contained in:
Corantin H 2019-05-23 23:17:12 +02:00
parent 858a85e7b5
commit bf435e8b72
6 changed files with 20 additions and 24 deletions

3
.gitignore vendored
View file

@ -3,9 +3,6 @@
data/
!/data/
build/
!/build/
bundle/
!/other/bundle/

View file

@ -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; }

View file

@ -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);

View file

@ -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")

View file

@ -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)

View file

@ -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))
{