mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Update checkpoint diff display to use time format with hours:minutes:centisecs
Add time diff to finish display. Increase time the finish time display is displayed to 6 sec. Allow to trigger time checkpoints out of order
This commit is contained in:
parent
498c2dbbcf
commit
ae80287c1b
|
@ -67,15 +67,16 @@ void CHud::OnWindowResize()
|
||||||
|
|
||||||
void CHud::OnReset()
|
void CHud::OnReset()
|
||||||
{
|
{
|
||||||
m_CheckpointDiff = 0.0f;
|
m_TimeCpDiff = 0.0f;
|
||||||
m_DDRaceTime = 0;
|
m_DDRaceTime = 0;
|
||||||
m_LastReceivedTimeTick = 0;
|
m_FinishTimeLastReceivedTick = 0;
|
||||||
m_CheckpointTick = 0;
|
m_TimeCpLastReceivedTick = 0;
|
||||||
m_FinishTime = false;
|
m_ShowFinishTime = false;
|
||||||
m_DDRaceTimeReceived = false;
|
|
||||||
m_ServerRecord = -1.0f;
|
m_ServerRecord = -1.0f;
|
||||||
m_PlayerRecord[0] = -1.0f;
|
m_PlayerRecord[0] = -1.0f;
|
||||||
m_PlayerRecord[1] = -1.0f;
|
m_PlayerRecord[1] = -1.0f;
|
||||||
|
m_LastPlayerRecord[0] = -1.0f;
|
||||||
|
m_LastPlayerRecord[1] = -1.0f;
|
||||||
|
|
||||||
ResetHudContainers();
|
ResetHudContainers();
|
||||||
}
|
}
|
||||||
|
@ -1622,20 +1623,20 @@ void CHud::OnMessage(int MsgType, void *pRawMsg)
|
||||||
{
|
{
|
||||||
if(MsgType == NETMSGTYPE_SV_DDRACETIME || MsgType == NETMSGTYPE_SV_DDRACETIMELEGACY)
|
if(MsgType == NETMSGTYPE_SV_DDRACETIME || MsgType == NETMSGTYPE_SV_DDRACETIMELEGACY)
|
||||||
{
|
{
|
||||||
m_DDRaceTimeReceived = true;
|
|
||||||
|
|
||||||
CNetMsg_Sv_DDRaceTime *pMsg = (CNetMsg_Sv_DDRaceTime *)pRawMsg;
|
CNetMsg_Sv_DDRaceTime *pMsg = (CNetMsg_Sv_DDRaceTime *)pRawMsg;
|
||||||
|
|
||||||
m_DDRaceTime = pMsg->m_Time;
|
m_DDRaceTime = pMsg->m_Time;
|
||||||
|
|
||||||
m_LastReceivedTimeTick = Client()->GameTick(g_Config.m_ClDummy);
|
m_ShowFinishTime = pMsg->m_Finish != 0;
|
||||||
|
|
||||||
m_FinishTime = pMsg->m_Finish != 0;
|
if(!m_ShowFinishTime)
|
||||||
|
|
||||||
if(!m_FinishTime)
|
|
||||||
{
|
{
|
||||||
m_CheckpointDiff = (float)pMsg->m_Check / 100;
|
m_TimeCpDiff = (float)pMsg->m_Check / 100;
|
||||||
m_CheckpointTick = Client()->GameTick(g_Config.m_ClDummy);
|
m_TimeCpLastReceivedTick = Client()->GameTick(g_Config.m_ClDummy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_FinishTimeLastReceivedTick = Client()->GameTick(g_Config.m_ClDummy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(MsgType == NETMSGTYPE_SV_RECORD || MsgType == NETMSGTYPE_SV_RECORDLEGACY)
|
else if(MsgType == NETMSGTYPE_SV_RECORD || MsgType == NETMSGTYPE_SV_RECORDLEGACY)
|
||||||
|
@ -1645,64 +1646,101 @@ void CHud::OnMessage(int MsgType, void *pRawMsg)
|
||||||
// NETMSGTYPE_SV_RACETIME on old race servers
|
// NETMSGTYPE_SV_RACETIME on old race servers
|
||||||
if(MsgType == NETMSGTYPE_SV_RECORDLEGACY && m_pClient->m_GameInfo.m_DDRaceRecordMessage)
|
if(MsgType == NETMSGTYPE_SV_RECORDLEGACY && m_pClient->m_GameInfo.m_DDRaceRecordMessage)
|
||||||
{
|
{
|
||||||
m_DDRaceTimeReceived = true;
|
|
||||||
|
|
||||||
m_DDRaceTime = pMsg->m_ServerTimeBest; // First value: m_Time
|
m_DDRaceTime = pMsg->m_ServerTimeBest; // First value: m_Time
|
||||||
|
|
||||||
m_LastReceivedTimeTick = Client()->GameTick(g_Config.m_ClDummy);
|
m_FinishTimeLastReceivedTick = Client()->GameTick(g_Config.m_ClDummy);
|
||||||
|
|
||||||
if(pMsg->m_PlayerTimeBest) // Second value: m_Check
|
if(pMsg->m_PlayerTimeBest) // Second value: m_Check
|
||||||
{
|
{
|
||||||
m_CheckpointDiff = (float)pMsg->m_PlayerTimeBest / 100;
|
m_TimeCpDiff = (float)pMsg->m_PlayerTimeBest / 100;
|
||||||
m_CheckpointTick = Client()->GameTick(g_Config.m_ClDummy);
|
m_TimeCpLastReceivedTick = Client()->GameTick(g_Config.m_ClDummy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(MsgType == NETMSGTYPE_SV_RECORD || m_pClient->m_GameInfo.m_RaceRecordMessage)
|
else if(MsgType == NETMSGTYPE_SV_RECORD || m_pClient->m_GameInfo.m_RaceRecordMessage)
|
||||||
{
|
{
|
||||||
m_ServerRecord = (float)pMsg->m_ServerTimeBest / 100;
|
m_ServerRecord = (float)pMsg->m_ServerTimeBest / 100;
|
||||||
|
m_LastPlayerRecord[g_Config.m_ClDummy] = m_PlayerRecord[g_Config.m_ClDummy];
|
||||||
m_PlayerRecord[g_Config.m_ClDummy] = (float)pMsg->m_PlayerTimeBest / 100;
|
m_PlayerRecord[g_Config.m_ClDummy] = (float)pMsg->m_PlayerTimeBest / 100;
|
||||||
|
if(m_LastPlayerRecord[g_Config.m_ClDummy] == -1.0f)
|
||||||
|
{
|
||||||
|
m_LastPlayerRecord[g_Config.m_ClDummy] = m_PlayerRecord[g_Config.m_ClDummy];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHud::RenderDDRaceEffects()
|
void CHud::RenderDDRaceEffects()
|
||||||
{
|
{
|
||||||
// check racestate
|
|
||||||
if(m_FinishTime && m_LastReceivedTimeTick + Client()->GameTickSpeed() * 2 < Client()->GameTick(g_Config.m_ClDummy))
|
|
||||||
{
|
|
||||||
m_FinishTime = false;
|
|
||||||
m_DDRaceTimeReceived = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_DDRaceTime)
|
if(m_DDRaceTime)
|
||||||
{
|
{
|
||||||
char aBuf[64];
|
char aBuf[64];
|
||||||
char aTime[32];
|
char aTime[32];
|
||||||
if(m_FinishTime)
|
if(m_ShowFinishTime && m_FinishTimeLastReceivedTick + Client()->GameTickSpeed() * 6 > Client()->GameTick(g_Config.m_ClDummy))
|
||||||
{
|
{
|
||||||
str_time(m_DDRaceTime, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
str_time(m_DDRaceTime, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
||||||
str_format(aBuf, sizeof(aBuf), "Finish time: %s", aTime);
|
str_format(aBuf, sizeof(aBuf), "Finish time: %s", aTime);
|
||||||
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(0, 12, aBuf, -1, -1.0f) / 2, 20, 12, aBuf, -1.0f);
|
|
||||||
}
|
|
||||||
else if(m_CheckpointTick + Client()->GameTickSpeed() * 6 > Client()->GameTick(g_Config.m_ClDummy))
|
|
||||||
{
|
|
||||||
str_format(aBuf, sizeof(aBuf), "%+5.2f", m_CheckpointDiff);
|
|
||||||
|
|
||||||
// calculate alpha (4 sec 1 than get lower the next 2 sec)
|
// calculate alpha (4 sec 1 than get lower the next 2 sec)
|
||||||
float a = 1.0f;
|
float alpha = 1.0f;
|
||||||
if(m_CheckpointTick + Client()->GameTickSpeed() * 4 < Client()->GameTick(g_Config.m_ClDummy) && m_CheckpointTick + Client()->GameTickSpeed() * 6 > Client()->GameTick(g_Config.m_ClDummy))
|
if(m_FinishTimeLastReceivedTick + Client()->GameTickSpeed() * 4 < Client()->GameTick(g_Config.m_ClDummy) && m_FinishTimeLastReceivedTick + Client()->GameTickSpeed() * 6 > Client()->GameTick(g_Config.m_ClDummy))
|
||||||
{
|
{
|
||||||
// lower the alpha slowly to blend text out
|
// lower the alpha slowly to blend text out
|
||||||
a = ((float)(m_CheckpointTick + Client()->GameTickSpeed() * 6) - (float)Client()->GameTick(g_Config.m_ClDummy)) / (float)(Client()->GameTickSpeed() * 2);
|
alpha = ((float)(m_FinishTimeLastReceivedTick + Client()->GameTickSpeed() * 6) - (float)Client()->GameTick(g_Config.m_ClDummy)) / (float)(Client()->GameTickSpeed() * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_CheckpointDiff > 0)
|
TextRender()->TextColor(1, 1, 1, alpha);
|
||||||
TextRender()->TextColor(1.0f, 0.5f, 0.5f, a); // red
|
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(0, 12, aBuf, -1, -1.0f) / 2, 20, 12, aBuf, -1.0f);
|
||||||
else if(m_CheckpointDiff < 0)
|
|
||||||
TextRender()->TextColor(0.5f, 1.0f, 0.5f, a); // green
|
if(m_LastPlayerRecord[g_Config.m_ClDummy] > 0.0f)
|
||||||
else if(!m_CheckpointDiff)
|
{
|
||||||
TextRender()->TextColor(1, 1, 1, a); // white
|
const float FinishTimeDiff = m_DDRaceTime / 100.0f - m_LastPlayerRecord[g_Config.m_ClDummy];
|
||||||
|
if(FinishTimeDiff < 0)
|
||||||
|
{
|
||||||
|
str_time_float(-FinishTimeDiff, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
||||||
|
str_format(aBuf, sizeof(aBuf), "-%s", aTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str_time_float(FinishTimeDiff, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
||||||
|
str_format(aBuf, sizeof(aBuf), "+%s", aTime);
|
||||||
|
}
|
||||||
|
if(FinishTimeDiff > 0)
|
||||||
|
TextRender()->TextColor(1.0f, 0.5f, 0.5f, alpha); // red
|
||||||
|
else if(FinishTimeDiff < 0)
|
||||||
|
TextRender()->TextColor(0.5f, 1.0f, 0.5f, alpha); // green
|
||||||
|
else if(!FinishTimeDiff)
|
||||||
|
TextRender()->TextColor(1, 1, 1, alpha); // white
|
||||||
|
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(0, 10, aBuf, -1, -1.0f) / 2, 34, 10, aBuf, -1.0f);
|
||||||
|
}
|
||||||
|
TextRender()->TextColor(1, 1, 1, 1);
|
||||||
|
}
|
||||||
|
else if(!m_ShowFinishTime && m_TimeCpLastReceivedTick + Client()->GameTickSpeed() * 6 > Client()->GameTick(g_Config.m_ClDummy))
|
||||||
|
{
|
||||||
|
if(m_TimeCpDiff < 0)
|
||||||
|
{
|
||||||
|
str_time_float(-m_TimeCpDiff, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
||||||
|
str_format(aBuf, sizeof(aBuf), "-%s", aTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str_time_float(m_TimeCpDiff, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
||||||
|
str_format(aBuf, sizeof(aBuf), "+%s", aTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate alpha (4 sec 1 than get lower the next 2 sec)
|
||||||
|
float alpha = 1.0f;
|
||||||
|
if(m_TimeCpLastReceivedTick + Client()->GameTickSpeed() * 4 < Client()->GameTick(g_Config.m_ClDummy) && m_TimeCpLastReceivedTick + Client()->GameTickSpeed() * 6 > Client()->GameTick(g_Config.m_ClDummy))
|
||||||
|
{
|
||||||
|
// lower the alpha slowly to blend text out
|
||||||
|
alpha = ((float)(m_TimeCpLastReceivedTick + Client()->GameTickSpeed() * 6) - (float)Client()->GameTick(g_Config.m_ClDummy)) / (float)(Client()->GameTickSpeed() * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_TimeCpDiff > 0)
|
||||||
|
TextRender()->TextColor(1.0f, 0.5f, 0.5f, alpha); // red
|
||||||
|
else if(m_TimeCpDiff < 0)
|
||||||
|
TextRender()->TextColor(0.5f, 1.0f, 0.5f, alpha); // green
|
||||||
|
else if(!m_TimeCpDiff)
|
||||||
|
TextRender()->TextColor(1, 1, 1, alpha); // white
|
||||||
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(0, 10, aBuf, -1, -1.0f) / 2, 20, 10, aBuf, -1.0f);
|
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(0, 10, aBuf, -1, -1.0f) / 2, 20, 10, aBuf, -1.0f);
|
||||||
|
|
||||||
TextRender()->TextColor(1, 1, 1, 1);
|
TextRender()->TextColor(1, 1, 1, 1);
|
||||||
|
@ -1712,26 +1750,26 @@ void CHud::RenderDDRaceEffects()
|
||||||
|
|
||||||
void CHud::RenderRecord()
|
void CHud::RenderRecord()
|
||||||
{
|
{
|
||||||
if(m_ServerRecord > 0)
|
if(m_ServerRecord > 0.0f)
|
||||||
{
|
{
|
||||||
char aBuf[64];
|
char aBuf[64];
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("Server best:"));
|
str_format(aBuf, sizeof(aBuf), Localize("Server best:"));
|
||||||
TextRender()->Text(0, 5, 40, 6, aBuf, -1.0f);
|
TextRender()->Text(0, 5, 75, 6, aBuf, -1.0f);
|
||||||
char aTime[32];
|
char aTime[32];
|
||||||
str_time_float(m_ServerRecord, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
str_time_float(m_ServerRecord, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
||||||
str_format(aBuf, sizeof(aBuf), "%s%s", m_ServerRecord > 3600 ? "" : " ", aTime);
|
str_format(aBuf, sizeof(aBuf), "%s%s", m_ServerRecord > 3600 ? "" : " ", aTime);
|
||||||
TextRender()->Text(0, 53, 40, 6, aBuf, -1.0f);
|
TextRender()->Text(0, 53, 75, 6, aBuf, -1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float PlayerRecord = m_PlayerRecord[g_Config.m_ClDummy];
|
const float PlayerRecord = m_PlayerRecord[g_Config.m_ClDummy];
|
||||||
if(PlayerRecord > 0)
|
if(PlayerRecord > 0.0f)
|
||||||
{
|
{
|
||||||
char aBuf[64];
|
char aBuf[64];
|
||||||
str_format(aBuf, sizeof(aBuf), Localize("Personal best:"));
|
str_format(aBuf, sizeof(aBuf), Localize("Personal best:"));
|
||||||
TextRender()->Text(0, 5, 47, 6, aBuf, -1.0f);
|
TextRender()->Text(0, 5, 82, 6, aBuf, -1.0f);
|
||||||
char aTime[32];
|
char aTime[32];
|
||||||
str_time_float(PlayerRecord, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
str_time_float(PlayerRecord, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
|
||||||
str_format(aBuf, sizeof(aBuf), "%s%s", PlayerRecord > 3600 ? "" : " ", aTime);
|
str_format(aBuf, sizeof(aBuf), "%s%s", PlayerRecord > 3600 ? "" : " ", aTime);
|
||||||
TextRender()->Text(0, 53, 47, 6, aBuf, -1.0f);
|
TextRender()->Text(0, 53, 82, 6, aBuf, -1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,14 +85,14 @@ public:
|
||||||
private:
|
private:
|
||||||
void RenderRecord();
|
void RenderRecord();
|
||||||
void RenderDDRaceEffects();
|
void RenderDDRaceEffects();
|
||||||
float m_CheckpointDiff;
|
float m_TimeCpDiff;
|
||||||
float m_ServerRecord;
|
float m_ServerRecord;
|
||||||
float m_PlayerRecord[NUM_DUMMIES];
|
float m_PlayerRecord[NUM_DUMMIES];
|
||||||
|
float m_LastPlayerRecord[NUM_DUMMIES];
|
||||||
int m_DDRaceTime;
|
int m_DDRaceTime;
|
||||||
int m_LastReceivedTimeTick;
|
int m_FinishTimeLastReceivedTick;
|
||||||
int m_CheckpointTick;
|
int m_TimeCpLastReceivedTick;
|
||||||
bool m_FinishTime;
|
bool m_ShowFinishTime;
|
||||||
bool m_DDRaceTimeReceived;
|
|
||||||
|
|
||||||
inline float GetMovementInformationBoxHeight();
|
inline float GetMovementInformationBoxHeight();
|
||||||
inline int GetDigitsIndex(int Value, int Max);
|
inline int GetDigitsIndex(int Value, int Max);
|
||||||
|
|
|
@ -45,7 +45,6 @@ void CScoreboard::OnMessage(int MsgType, void *pRawMsg)
|
||||||
{
|
{
|
||||||
CNetMsg_Sv_Record *pMsg = (CNetMsg_Sv_Record *)pRawMsg;
|
CNetMsg_Sv_Record *pMsg = (CNetMsg_Sv_Record *)pRawMsg;
|
||||||
m_ServerRecord = (float)pMsg->m_ServerTimeBest / 100;
|
m_ServerRecord = (float)pMsg->m_ServerTimeBest / 100;
|
||||||
//m_PlayerRecord = (float)pMsg->m_PlayerTimeBest/100;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1350,15 +1350,15 @@ bool CCharacter::IsSwitchActiveCb(int Number, void *pUser)
|
||||||
|
|
||||||
void CCharacter::SetTimeCheckpoint(int TimeCheckpoint)
|
void CCharacter::SetTimeCheckpoint(int TimeCheckpoint)
|
||||||
{
|
{
|
||||||
if(TimeCheckpoint != -1 && m_DDRaceState == DDRACE_STARTED && TimeCheckpoint > m_LastTimeCp)
|
if(TimeCheckpoint > -1 && m_DDRaceState == DDRACE_STARTED && m_aCurrentTimeCp[TimeCheckpoint] == 0.0f && m_Time != 0.0f)
|
||||||
{
|
{
|
||||||
m_LastTimeCp = TimeCheckpoint;
|
m_LastTimeCp = TimeCheckpoint;
|
||||||
m_aCurrentTimeCp[TimeCheckpoint] = m_Time;
|
m_aCurrentTimeCp[m_LastTimeCp] = m_Time;
|
||||||
m_TimeCpBroadcastEndTick = Server()->Tick() + Server()->TickSpeed() * 2;
|
m_TimeCpBroadcastEndTick = Server()->Tick() + Server()->TickSpeed() * 2;
|
||||||
if(m_pPlayer->GetClientVersion() >= VERSION_DDRACE)
|
if(m_pPlayer->GetClientVersion() >= VERSION_DDRACE)
|
||||||
{
|
{
|
||||||
CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID());
|
CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID());
|
||||||
if(pData->m_BestTime && pData->m_aBestTimeCp[m_LastTimeCp] != 0 && m_LastTimeCp != -1)
|
if(pData->m_BestTime && pData->m_aBestTimeCp[m_LastTimeCp] != 0.0f)
|
||||||
{
|
{
|
||||||
CNetMsg_Sv_DDRaceTime Msg;
|
CNetMsg_Sv_DDRaceTime Msg;
|
||||||
Msg.m_Time = (int)(m_Time * 100.0f);
|
Msg.m_Time = (int)(m_Time * 100.0f);
|
||||||
|
|
Loading…
Reference in a new issue