show play time move to a new function

This commit is contained in:
sirius 2019-05-17 21:57:00 +08:00
parent 8819f21d3a
commit f62f6d2207
4 changed files with 14 additions and 4 deletions

View file

@ -766,15 +766,21 @@ void CHud::RenderLocalTime(float x)
char aTimeStr[6];
str_timestamp_format(aTimeStr, sizeof(aTimeStr), "%H:%M");
TextRender()->Text(0, x-25.0f, (12.5f - 5.f) / 2.f, 5.0f, aTimeStr, -1);
}
//draw the text
void CHud::RenderPlayTime(float x)
{
if(!g_Config.m_ClShowPlayTimeAlways && !m_pClient->m_pScoreboard->Active())
return;
// get the time
char aPlayTimeStr[6];
time_t CurrTime;
time(&CurrTime);
// str_timestamp_ex(m_pClient->GetPlayingTime(CurrTime), aPlayTimeStr, sizeof(aPlayTimeStr), "%H:%M");
int Time = m_pClient->GetPlayingTime(CurrTime) / 60;
int Time = m_pClient->GetPlayTime(CurrTime) / 60;
str_format(aPlayTimeStr, sizeof(aPlayTimeStr), "%02d:%02d", Time/60, Time%60);
//draw the box
Graphics()->BlendNormal();
Graphics()->TextureSet(-1);
Graphics()->QuadsBegin();
@ -782,6 +788,7 @@ void CHud::RenderLocalTime(float x)
RenderTools()->DrawRoundRectExt(x-95.0f, 0.0f, 30.0f+TextRender()->TextWidth(0, 12, aPlayTimeStr, -1)/2, 12.5f, 3.75f, CUI::CORNER_B);
Graphics()->QuadsEnd();
//draw the text
TextRender()->Text(0, x-70.0f, (12.5f - 5.f) / 2.f, 5.0f, aPlayTimeStr, -1);
TextRender()->Text(0, x-90.0f, (12.5f - 5.f) / 2.f, 5.0f, "PLAYED", -1);
}
@ -818,6 +825,7 @@ void CHud::OnRender()
RenderWarmupTimer();
RenderTextInfo();
RenderLocalTime((m_Width/7)*3);
RenderPlayTime((m_Width/7)*3);
if(Client()->State() != IClient::STATE_DEMOPLAYBACK)
RenderConnectionWarning();
RenderTeambalanceWarning();

View file

@ -59,6 +59,7 @@ class CHud : public CComponent
void RenderSpectatorHud();
void RenderWarmupTimer();
void RenderLocalTime(float x);
void RenderPlayTime(float x);
void MapscreenToGroup(float CenterX, float CenterY, struct CMapItemGroup *PGroup);
public:

View file

@ -147,7 +147,7 @@ public:
int NetobjNumCorrections() { return m_NetObjHandler.NumObjCorrections(); }
const char *NetobjCorrectedOn() { return m_NetObjHandler.CorrectedObjOn(); }
double GetPlayingTime(time_t Curr){ return difftime(Curr, m_InitTime); };
double GetPlayTime(time_t Curr){ return difftime(Curr, m_InitTime); };
bool m_SuppressEvents;
bool m_NewTick;

View file

@ -42,6 +42,7 @@ MACRO_CONFIG_INT(ClShowChatSystem, cl_show_chat_system, 1, 0, 1, CFGFLAG_CLIENT|
MACRO_CONFIG_INT(ClShowKillMessages, cl_showkillmessages, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show kill messages")
MACRO_CONFIG_INT(ClShowVotesAfterVoting, cl_show_votes_after_voting, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show votes window after voting")
MACRO_CONFIG_INT(ClShowLocalTimeAlways, cl_show_local_time_always, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show local time")
MACRO_CONFIG_INT(ClShowPlayTimeAlways, cl_show_play_time_always, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show the time you have played after client opened.")
MACRO_CONFIG_INT(ClShowfps, cl_showfps, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ingame FPS counter")
MACRO_CONFIG_INT(ClShowpred, cl_showpred, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ingame prediction time in milliseconds")
MACRO_CONFIG_INT(ClEyeWheel, cl_eye_wheel, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show eye wheel along together with emotes")