mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
3010: Use hours in score hud and record r=Learath2 a=def- 3014: Scale auto mapper text size (partially fixes #3013) r=Learath2 a=def- Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
1f7d544349
|
@ -338,7 +338,13 @@ void CHud::RenderScoreHud()
|
|||
if(m_pClient->m_GameInfo.m_TimeScore && g_Config.m_ClDDRaceScoreBoard)
|
||||
{
|
||||
if(apPlayerInfo[t]->m_Score != -9999)
|
||||
str_format(aScore[t], sizeof(aScore[t]), "%02d:%02d", abs(apPlayerInfo[t]->m_Score) / 60, abs(apPlayerInfo[t]->m_Score) % 60);
|
||||
{
|
||||
int Secs = abs(apPlayerInfo[t]->m_Score);
|
||||
if(Secs > 3600)
|
||||
str_format(aScore[t], sizeof(aScore[t]), "%02d:%02d:%02d", Secs / 3600, (Secs % 3600) / 60, Secs % 60);
|
||||
else
|
||||
str_format(aScore[t], sizeof(aScore[t]), "%02d:%02d", Secs / 60, Secs % 60);
|
||||
}
|
||||
else
|
||||
aScore[t][0] = 0;
|
||||
}
|
||||
|
@ -913,7 +919,10 @@ void CHud::RenderRecord()
|
|||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), Localize("Server best:"));
|
||||
TextRender()->Text(0, 5, 40, 6, aBuf, -1.0f);
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%05.2f", (int)m_ServerRecord / 60, m_ServerRecord - ((int)m_ServerRecord / 60 * 60));
|
||||
if(m_ServerRecord > 3600)
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%02d:%05.2f", (int)m_ServerRecord / 3600, ((int)m_ServerRecord % 3600) / 60, m_ServerRecord - ((int)m_ServerRecord / 60 * 60));
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), " %02d:%05.2f", (int)m_ServerRecord / 60, m_ServerRecord - ((int)m_ServerRecord / 60 * 60));
|
||||
TextRender()->Text(0, 53, 40, 6, aBuf, -1.0f);
|
||||
}
|
||||
|
||||
|
@ -923,7 +932,10 @@ void CHud::RenderRecord()
|
|||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), Localize("Personal best:"));
|
||||
TextRender()->Text(0, 5, 47, 6, aBuf, -1.0f);
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%05.2f", (int)PlayerRecord / 60, PlayerRecord - ((int)PlayerRecord / 60 * 60));
|
||||
if(PlayerRecord > 3600)
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%02d:%05.2f", (int)PlayerRecord / 3600, ((int)PlayerRecord % 3600) / 60, PlayerRecord - ((int)PlayerRecord / 60 * 60));
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), " %02d:%05.2f", (int)PlayerRecord / 60, PlayerRecord - ((int)PlayerRecord / 60 * 60));
|
||||
TextRender()->Text(0, 53, 47, 6, aBuf, -1.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2940,6 +2940,23 @@ void CEditor::DoMapEditor(CUIRect View)
|
|||
//UI()->ClipDisable();
|
||||
}
|
||||
|
||||
float CEditor::ScaleFontSize(char *aBuf, float FontSize, int Width)
|
||||
{
|
||||
while(TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f) > Width)
|
||||
{
|
||||
if(FontSize > 6.0f)
|
||||
{
|
||||
FontSize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
aBuf[str_length(aBuf) - 4] = '\0';
|
||||
str_append(aBuf, "...", sizeof(aBuf));
|
||||
}
|
||||
}
|
||||
return FontSize;
|
||||
}
|
||||
|
||||
int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *pNewVal, ColorRGBA Color)
|
||||
{
|
||||
int Change = -1;
|
||||
|
@ -3096,27 +3113,12 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
|
|||
else if(pProps[i].m_Type == PROPTYPE_IMAGE)
|
||||
{
|
||||
char aBuf[64];
|
||||
float FontSize = 10.0f;
|
||||
|
||||
if(pProps[i].m_Value < 0)
|
||||
str_copy(aBuf, "None", sizeof(aBuf));
|
||||
else
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%s", m_Map.m_lImages[pProps[i].m_Value]->m_aName);
|
||||
while(TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f) > Shifter.w)
|
||||
{
|
||||
if(FontSize > 6.0f)
|
||||
{
|
||||
FontSize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
aBuf[str_length(aBuf) - 4] = '\0';
|
||||
str_append(aBuf, "...", sizeof(aBuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float FontSize = ScaleFontSize(aBuf, 10.0f, Shifter.w);
|
||||
if(DoButton_Ex(&pIDs[i], aBuf, 0, &Shifter, 0, 0, CUI::CORNER_ALL, FontSize))
|
||||
PopupSelectImageInvoke(pProps[i].m_Value, UI()->MouseX(), UI()->MouseY());
|
||||
|
||||
|
@ -3165,27 +3167,12 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
|
|||
else if(pProps[i].m_Type == PROPTYPE_SOUND)
|
||||
{
|
||||
char aBuf[64];
|
||||
float FontSize = 10.0f;
|
||||
|
||||
if(pProps[i].m_Value < 0)
|
||||
str_copy(aBuf, "None", sizeof(aBuf));
|
||||
else
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%s", m_Map.m_lSounds[pProps[i].m_Value]->m_aName);
|
||||
while(TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f) > Shifter.w)
|
||||
{
|
||||
if(FontSize > 6.0f)
|
||||
{
|
||||
FontSize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
aBuf[str_length(aBuf) - 4] = '\0';
|
||||
str_append(aBuf, "...", sizeof(aBuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float FontSize = ScaleFontSize(aBuf, 10.0f, Shifter.w);
|
||||
if(DoButton_Ex(&pIDs[i], aBuf, 0, &Shifter, 0, 0, CUI::CORNER_ALL, FontSize))
|
||||
PopupSelectSoundInvoke(pProps[i].m_Value, UI()->MouseX(), UI()->MouseY());
|
||||
|
||||
|
@ -3204,7 +3191,8 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
|
|||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%s", m_Map.m_lImages[pProps[i].m_Min]->m_AutoMapper.GetConfigName(pProps[i].m_Value));
|
||||
|
||||
if(DoButton_Editor(&pIDs[i], aBuf, 0, &Shifter, 0, 0))
|
||||
float FontSize = ScaleFontSize(aBuf, 10.0f, Shifter.w);
|
||||
if(DoButton_Ex(&pIDs[i], aBuf, 0, &Shifter, 0, 0, CUI::CORNER_ALL, FontSize))
|
||||
PopupSelectConfigAutoMapInvoke(pProps[i].m_Value, UI()->MouseX(), UI()->MouseY());
|
||||
|
||||
int r = PopupSelectConfigAutoMapResult();
|
||||
|
@ -3218,7 +3206,6 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
|
|||
{
|
||||
CUIRect Inc, Dec;
|
||||
char aBuf[64];
|
||||
float FontSize = 10.0f;
|
||||
int CurValue = pProps[i].m_Value;
|
||||
|
||||
Shifter.VSplitRight(10.0f, &Shifter, &Inc);
|
||||
|
@ -3226,27 +3213,12 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
|
|||
|
||||
if(CurValue <= 0)
|
||||
str_copy(aBuf, "None", sizeof(aBuf));
|
||||
else if(m_Map.m_lEnvelopes[CurValue - 1]->m_aName[0])
|
||||
str_format(aBuf, sizeof(aBuf), "%d: %s", CurValue, m_Map.m_lEnvelopes[CurValue - 1]->m_aName);
|
||||
else
|
||||
{
|
||||
if(m_Map.m_lEnvelopes[CurValue - 1]->m_aName[0])
|
||||
str_format(aBuf, sizeof(aBuf), "%d: %s", CurValue, m_Map.m_lEnvelopes[CurValue - 1]->m_aName);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%d", CurValue);
|
||||
|
||||
while(TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f) > Shifter.w)
|
||||
{
|
||||
if(FontSize > 6.0f)
|
||||
{
|
||||
FontSize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
aBuf[str_length(aBuf) - 4] = '\0';
|
||||
str_append(aBuf, "...", sizeof(aBuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
str_format(aBuf, sizeof(aBuf), "%d", CurValue);
|
||||
|
||||
float FontSize = ScaleFontSize(aBuf, 10.0f, Shifter.w);
|
||||
RenderTools()->DrawUIRect(&Shifter, Color, 0, 5.0f);
|
||||
UI()->DoLabel(&Shifter, aBuf, FontSize, 0, -1);
|
||||
|
||||
|
@ -4877,21 +4849,7 @@ void CEditor::RenderStatusbar(CUIRect View)
|
|||
else
|
||||
str_copy(aBuf, m_pTooltip, sizeof(aBuf));
|
||||
|
||||
float FontSize = 10.0f;
|
||||
|
||||
while(TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f) > View.w)
|
||||
{
|
||||
if(FontSize > 6.0f)
|
||||
{
|
||||
FontSize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
aBuf[str_length(aBuf) - 4] = '\0';
|
||||
str_append(aBuf, "...", sizeof(aBuf));
|
||||
}
|
||||
}
|
||||
|
||||
float FontSize = ScaleFontSize(aBuf, 10.0f, View.w);
|
||||
UI()->DoLabel(&View, aBuf, FontSize, -1, View.w);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -801,6 +801,7 @@ public:
|
|||
bool IsQuadSelected(int Index);
|
||||
int FindSelectedQuadIndex(int Index);
|
||||
|
||||
float ScaleFontSize(char *aBuf, float FontSize, int Width);
|
||||
int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, ColorRGBA Color = ColorRGBA(1, 1, 1, 0.5f));
|
||||
|
||||
int m_Mode;
|
||||
|
|
Loading…
Reference in a new issue