mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fix: switch servers after player confirms
When a player wants to switch servers in-game, but needs to confirm the action because of cl_confirm_disconnect, the game used to not actually connect to the new server. This adds a way to still connect to that server, after the player confirms. Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
0393ac0f88
commit
801ebbd161
|
@ -1752,6 +1752,12 @@ int CMenus::Render()
|
|||
pButtonText = m_aMessageButton;
|
||||
ExtraAlign = -1;
|
||||
}
|
||||
else if(m_Popup == POPUP_SWITCH_SERVER)
|
||||
{
|
||||
pTitle = Localize("Disconnect");
|
||||
pExtraText = Localize("Are you sure that you want to disconnect and switch to a different server?");
|
||||
ExtraAlign = -1;
|
||||
}
|
||||
|
||||
CUIRect Box, Part;
|
||||
Box = Screen;
|
||||
|
@ -2393,6 +2399,29 @@ int CMenus::Render()
|
|||
SetActive(false);
|
||||
}
|
||||
}
|
||||
else if(m_Popup == POPUP_SWITCH_SERVER)
|
||||
{
|
||||
CUIRect Yes, No;
|
||||
Box.HSplitBottom(20.f, &Box, &Part);
|
||||
Box.HSplitBottom(24.f, &Box, &Part);
|
||||
|
||||
// buttons
|
||||
Part.VMargin(80.0f, &Part);
|
||||
Part.VSplitMid(&No, &Yes);
|
||||
Yes.VMargin(20.0f, &Yes);
|
||||
No.VMargin(20.0f, &No);
|
||||
|
||||
static int s_ButtonAbort = 0;
|
||||
if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed)
|
||||
{
|
||||
m_Popup = POPUP_NONE;
|
||||
m_aNextServer[0] = '\0';
|
||||
}
|
||||
|
||||
static int s_ButtonTryAgain = 0;
|
||||
if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed)
|
||||
Client()->Connect(m_aNextServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Box.HSplitBottom(20.f, &Box, &Part);
|
||||
|
|
|
@ -290,6 +290,8 @@ protected:
|
|||
vec2 m_MousePos;
|
||||
bool m_MouseSlow;
|
||||
|
||||
char m_aNextServer[256];
|
||||
|
||||
int64 m_LastInput;
|
||||
|
||||
// images
|
||||
|
@ -679,6 +681,7 @@ public:
|
|||
POPUP_DISCONNECT,
|
||||
POPUP_DISCONNECT_DUMMY,
|
||||
POPUP_WARNING,
|
||||
POPUP_SWITCH_SERVER,
|
||||
|
||||
// demo player states
|
||||
DEMOPLAYER_NONE = 0,
|
||||
|
|
|
@ -487,7 +487,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
if(Input()->MouseDoubleClick() && DoubleClicked)
|
||||
{
|
||||
if(Client()->State() == IClient::STATE_ONLINE && Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmDisconnectTime && g_Config.m_ClConfirmDisconnectTime >= 0)
|
||||
m_Popup = POPUP_DISCONNECT;
|
||||
{
|
||||
m_Popup = POPUP_SWITCH_SERVER;
|
||||
str_copy(m_aNextServer, g_Config.m_UiServerAddress, sizeof(m_aNextServer));
|
||||
}
|
||||
else
|
||||
Client()->Connect(g_Config.m_UiServerAddress);
|
||||
}
|
||||
|
@ -647,7 +650,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
m_EnterPressed)
|
||||
{
|
||||
if(Client()->State() == IClient::STATE_ONLINE && Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmDisconnectTime && g_Config.m_ClConfirmDisconnectTime >= 0)
|
||||
m_Popup = POPUP_DISCONNECT;
|
||||
{
|
||||
m_Popup = POPUP_SWITCH_SERVER;
|
||||
str_copy(m_aNextServer, g_Config.m_UiServerAddress, sizeof(m_aNextServer));
|
||||
}
|
||||
else
|
||||
Client()->Connect(g_Config.m_UiServerAddress);
|
||||
m_EnterPressed = false;
|
||||
|
|
Loading…
Reference in a new issue