Skip to content

Show disconnect warning when using Quick Connect while connected #4344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Client/core/CCommandFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ void CCommandFuncs::Reconnect(const char* szParameters)
// Start the connect
if (CCore::GetSingleton().GetConnectManager()->Reconnect(strHost.c_str(), usPort, strPassword.c_str(), false))
{
if (CCore::GetSingleton().GetConnectManager()->WasQuickConnect())
{
CCore::GetSingleton().GetConnectManager()->SetQuickConnect(false);
}
CCore::GetSingleton().GetConsole()->Printf(_("reconnect: Reconnecting to %s:%u..."), strHost.c_str(), usPort);
}
else
Expand Down
3 changes: 2 additions & 1 deletion Client/core/CConnectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ CConnectManager::CConnectManager()
m_bIsConnecting = false;
m_bSave = true;
m_tConnectStarted = 0;

bool m_quickConnect{false};

m_pOnCancelClick = new GUI_CALLBACK(&CConnectManager::Event_OnCancelClick, this);

m_pServerItem = NULL;
Expand Down
5 changes: 5 additions & 0 deletions Client/core/CConnectManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ class CConnectManager

bool Abort();

bool WasQuickConnect() const noexcept { return m_quickConnect; }

void DoPulse();

void OnServerExists();

void SetQuickConnect(bool quick) noexcept { m_quickConnect = quick; }

static void OpenServerFirewall(in_addr Address, ushort usHttpPort = 80, bool bHighPriority = false);

static bool StaticProcessPacket(unsigned char ucPacketID, class NetBitStreamInterface& bitStream);
Expand All @@ -52,6 +56,7 @@ class CConnectManager
bool m_bSave;
time_t m_tConnectStarted;
bool m_bHasTriedSecondConnect;
bool m_quickConnect;

GUI_CALLBACK* m_pOnCancelClick;

Expand Down
13 changes: 10 additions & 3 deletions Client/core/CMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,11 @@ bool CMainMenu::OnMenuClick(CGUIMouseEventArgs Args)
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
return true;
}

break;

break;
case MENU_ITEM_QUICK_CONNECT:
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
return true;
default:
break;
}
Expand Down Expand Up @@ -914,7 +917,8 @@ bool CMainMenu::OnQuickConnectButtonClick(CGUIElement* pElement, bool left)
ShowNetworkNotReadyWindow();
return true;
}


g_pCore->GetConnectManager()->SetQuickConnect(true);
g_pCore->GetCommands()->Execute("reconnect", "");
}
else
Expand Down Expand Up @@ -1262,6 +1266,9 @@ void CMainMenu::WantsToDisconnectCallBack(void* pData, uint uiButton)
case MENU_ITEM_DISCONNECT:
OnDisconnectButtonClick();
break;
case MENU_ITEM_QUICK_CONNECT:
OnQuickConnectButtonClick(nullptr, true);
break;
default:
break;
}
Expand Down