mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Warn new players about name with points (fixes #3178)
This commit is contained in:
parent
2ba4d5d6cb
commit
b83b4c8e33
|
@ -49,6 +49,7 @@ protected:
|
|||
|
||||
public:
|
||||
char m_aNews[3000];
|
||||
int m_Points;
|
||||
int64 m_ReconnectTime;
|
||||
|
||||
class CSnapItem
|
||||
|
|
|
@ -328,6 +328,7 @@ CClient::CClient() :
|
|||
str_format(m_aDDNetInfoTmp, sizeof(m_aDDNetInfoTmp), DDNET_INFO ".%d.tmp", pid());
|
||||
m_pDDNetInfoTask = NULL;
|
||||
m_aNews[0] = '\0';
|
||||
m_Points = -1;
|
||||
|
||||
m_CurrentServerInfoRequestTime = -1;
|
||||
|
||||
|
@ -2521,6 +2522,10 @@ void CClient::LoadDDNetInfo()
|
|||
|
||||
str_copy(m_aNews, pNewsString, sizeof(m_aNews));
|
||||
}
|
||||
|
||||
const json_value *pPoints = json_object_get(pDDNetInfo, "points");
|
||||
if(pPoints->type == json_integer)
|
||||
m_Points = pPoints->u.integer;
|
||||
}
|
||||
|
||||
void CClient::PumpNetwork()
|
||||
|
|
|
@ -1440,6 +1440,24 @@ int CMenus::Render()
|
|||
pButtonText = Localize("Ok");
|
||||
ExtraAlign = -1;
|
||||
}
|
||||
else if(m_Popup == POPUP_POINTS)
|
||||
{
|
||||
pTitle = Localize("Existing Player");
|
||||
if(Client()->m_Points > 50)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), Localize("Your nick name '%s' is already used (%d points). Do you still want to use it?"), Client()->PlayerName(), Client()->m_Points);
|
||||
pExtraText = aBuf;
|
||||
}
|
||||
else if(Client()->m_Points >= 0)
|
||||
{
|
||||
m_Popup = POPUP_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pExtraText = Localize("Checking for existing player with your name");
|
||||
}
|
||||
ExtraAlign = -1;
|
||||
}
|
||||
else if(m_Popup == POPUP_WARNING)
|
||||
{
|
||||
BgColor = ColorRGBA{0.5f, 0.0f, 0.0f, 0.7f};
|
||||
|
@ -2024,7 +2042,12 @@ int CMenus::Render()
|
|||
if(DoButton_Menu(&s_EnterButton, Localize("Enter"), 0, &Part) || m_EnterPressed)
|
||||
{
|
||||
Client()->RequestDDNetInfo();
|
||||
m_Popup = POPUP_NONE;
|
||||
if(g_Config.m_BrIndicateFinished)
|
||||
m_Popup = POPUP_POINTS;
|
||||
else
|
||||
{
|
||||
m_Popup = POPUP_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
Box.HSplitBottom(20.f, &Box, &Part);
|
||||
|
@ -2050,6 +2073,27 @@ int CMenus::Render()
|
|||
static float Offset = 0.0f;
|
||||
DoEditBox(&g_Config.m_PlayerName, &TextBox, g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName), 12.0f, &Offset, false, CUI::CORNER_ALL, Client()->PlayerName());
|
||||
}
|
||||
else if(m_Popup == POPUP_POINTS)
|
||||
{
|
||||
CUIRect Yes, No;
|
||||
|
||||
Box.HSplitBottom(20.f, &Box, &Part);
|
||||
Box.HSplitBottom(24.f, &Box, &Part);
|
||||
Part.VMargin(80.0f, &Part);
|
||||
|
||||
Part.VSplitMid(&No, &Yes);
|
||||
|
||||
Yes.VMargin(20.0f, &Yes);
|
||||
No.VMargin(20.0f, &No);
|
||||
|
||||
static int s_ButtonNo = 0;
|
||||
if(DoButton_Menu(&s_ButtonNo, Localize("No"), 0, &No) || m_EscapePressed)
|
||||
m_Popup = POPUP_FIRST_LAUNCH;
|
||||
|
||||
static int s_ButtonYes = 0;
|
||||
if(DoButton_Menu(&s_ButtonYes, Localize("Yes"), 0, &Yes) || m_EnterPressed)
|
||||
m_Popup = POPUP_NONE;
|
||||
}
|
||||
else if(m_Popup == POPUP_WARNING)
|
||||
{
|
||||
Box.HSplitBottom(20.f, &Box, &Part);
|
||||
|
|
|
@ -502,6 +502,7 @@ public:
|
|||
{
|
||||
POPUP_NONE = 0,
|
||||
POPUP_FIRST_LAUNCH,
|
||||
POPUP_POINTS,
|
||||
POPUP_CONNECTING,
|
||||
POPUP_MESSAGE,
|
||||
POPUP_DISCONNECTED,
|
||||
|
|
Loading…
Reference in a new issue