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:
|
public:
|
||||||
char m_aNews[3000];
|
char m_aNews[3000];
|
||||||
|
int m_Points;
|
||||||
int64 m_ReconnectTime;
|
int64 m_ReconnectTime;
|
||||||
|
|
||||||
class CSnapItem
|
class CSnapItem
|
||||||
|
|
|
@ -328,6 +328,7 @@ CClient::CClient() :
|
||||||
str_format(m_aDDNetInfoTmp, sizeof(m_aDDNetInfoTmp), DDNET_INFO ".%d.tmp", pid());
|
str_format(m_aDDNetInfoTmp, sizeof(m_aDDNetInfoTmp), DDNET_INFO ".%d.tmp", pid());
|
||||||
m_pDDNetInfoTask = NULL;
|
m_pDDNetInfoTask = NULL;
|
||||||
m_aNews[0] = '\0';
|
m_aNews[0] = '\0';
|
||||||
|
m_Points = -1;
|
||||||
|
|
||||||
m_CurrentServerInfoRequestTime = -1;
|
m_CurrentServerInfoRequestTime = -1;
|
||||||
|
|
||||||
|
@ -2521,6 +2522,10 @@ void CClient::LoadDDNetInfo()
|
||||||
|
|
||||||
str_copy(m_aNews, pNewsString, sizeof(m_aNews));
|
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()
|
void CClient::PumpNetwork()
|
||||||
|
|
|
@ -1440,6 +1440,24 @@ int CMenus::Render()
|
||||||
pButtonText = Localize("Ok");
|
pButtonText = Localize("Ok");
|
||||||
ExtraAlign = -1;
|
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)
|
else if(m_Popup == POPUP_WARNING)
|
||||||
{
|
{
|
||||||
BgColor = ColorRGBA{0.5f, 0.0f, 0.0f, 0.7f};
|
BgColor = ColorRGBA{0.5f, 0.0f, 0.0f, 0.7f};
|
||||||
|
@ -2024,8 +2042,13 @@ int CMenus::Render()
|
||||||
if(DoButton_Menu(&s_EnterButton, Localize("Enter"), 0, &Part) || m_EnterPressed)
|
if(DoButton_Menu(&s_EnterButton, Localize("Enter"), 0, &Part) || m_EnterPressed)
|
||||||
{
|
{
|
||||||
Client()->RequestDDNetInfo();
|
Client()->RequestDDNetInfo();
|
||||||
|
if(g_Config.m_BrIndicateFinished)
|
||||||
|
m_Popup = POPUP_POINTS;
|
||||||
|
else
|
||||||
|
{
|
||||||
m_Popup = POPUP_NONE;
|
m_Popup = POPUP_NONE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Box.HSplitBottom(20.f, &Box, &Part);
|
Box.HSplitBottom(20.f, &Box, &Part);
|
||||||
Box.HSplitBottom(24.f, &Box, &Part);
|
Box.HSplitBottom(24.f, &Box, &Part);
|
||||||
|
@ -2050,6 +2073,27 @@ int CMenus::Render()
|
||||||
static float Offset = 0.0f;
|
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());
|
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)
|
else if(m_Popup == POPUP_WARNING)
|
||||||
{
|
{
|
||||||
Box.HSplitBottom(20.f, &Box, &Part);
|
Box.HSplitBottom(20.f, &Box, &Part);
|
||||||
|
|
|
@ -502,6 +502,7 @@ public:
|
||||||
{
|
{
|
||||||
POPUP_NONE = 0,
|
POPUP_NONE = 0,
|
||||||
POPUP_FIRST_LAUNCH,
|
POPUP_FIRST_LAUNCH,
|
||||||
|
POPUP_POINTS,
|
||||||
POPUP_CONNECTING,
|
POPUP_CONNECTING,
|
||||||
POPUP_MESSAGE,
|
POPUP_MESSAGE,
|
||||||
POPUP_DISCONNECTED,
|
POPUP_DISCONNECTED,
|
||||||
|
|
Loading…
Reference in a new issue