Skip to content
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

Refactor Quick Connect button #3843

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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: 0 additions & 4 deletions Client/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,6 @@ void CClientVariables::LoadDefaults()
DEFAULT("host", _S("127.0.0.1")); // hostname
DEFAULT("port", 22003); // port
DEFAULT("password", _S("")); // password
DEFAULT("qc_host", _S("127.0.0.1")); // quick connect hostname
DEFAULT("qc_port", 22003); // quick connect port
DEFAULT("qc_password", _S("")); // quick connect password
DEFAULT("debugfile", _S("")); // debug filename
DEFAULT("console_pos", CVector2D(0, 0)); // console position
DEFAULT("console_size", CVector2D(200, 200)); // console size
Expand Down Expand Up @@ -359,7 +356,6 @@ void CClientVariables::LoadDefaults()
DEFAULT("allow_discord_rpc", true); // Enable Discord Rich Presence
DEFAULT("discord_rpc_share_data", false); // Consistent Rich Presence data sharing
DEFAULT("discord_rpc_share_data_firsttime", false); // Display the user data sharing consent dialog box - for the first time
DEFAULT("_beta_qc_rightclick_command", _S("reconnect")); // Command to run when right clicking quick connect (beta - can be removed at any time)
DEFAULT("browser_enable_gpu", true); // Enable GPU in CEF? (allows stuff like WebGL to function)

if (!Exists("locale"))
Expand Down
9 changes: 4 additions & 5 deletions Client/core/CCommandFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ void CCommandFuncs::Reconnect(const char* szParameters)
unsigned int uiPort;

CVARS_GET("host", strHost);
CVARS_GET("nick", strNick);
CVARS_GET("password", strPassword);
CVARS_GET("port", uiPort);

Expand All @@ -315,7 +314,7 @@ void CCommandFuncs::Reconnect(const char* szParameters)
// Verify and convert the port number
if (uiPort <= 0 || uiPort > 0xFFFF)
{
CCore::GetSingleton().GetConsole()->Print(_("connect: Bad port number"));
CCore::GetSingleton().GetConsole()->Print(_("reconnect: Bad port number"));
return;
}

Expand All @@ -330,16 +329,16 @@ void CCommandFuncs::Reconnect(const char* szParameters)
// Start the connect
if (CCore::GetSingleton().GetConnectManager()->Reconnect(strHost.c_str(), usPort, strPassword.c_str(), false))
{
CCore::GetSingleton().GetConsole()->Printf(_("connect: Connecting to %s:%u..."), strHost.c_str(), usPort);
CCore::GetSingleton().GetConsole()->Printf(_("reconnect: Reconnecting to %s:%u..."), strHost.c_str(), usPort);
}
else
{
CCore::GetSingleton().GetConsole()->Printf(_("connect: could not connect to %s:%u!"), strHost.c_str(), usPort);
CCore::GetSingleton().GetConsole()->Printf(_("reconnect: could not connect to %s:%u!"), strHost.c_str(), usPort);
}
}
else
{
CCore::GetSingleton().GetConsole()->Print("connect: Failed to unload current mod");
CCore::GetSingleton().GetConsole()->Print("reconnect: Failed to unload current mod");
}
}

Expand Down
2 changes: 2 additions & 0 deletions Client/core/CConnectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ bool CConnectManager::Connect(const char* szHost, unsigned short usPort, const c

// Display the status box
SString strBuffer(_("Connecting to %s:%u ..."), m_strHost.c_str(), m_usPort);
if (m_bReconnect)
strBuffer = SString(_("Reconnecting to %s:%u ..."), m_strHost.c_str(), m_usPort);
CCore::GetSingleton().ShowMessageBox(_("CONNECTING"), strBuffer, MB_BUTTON_CANCEL | MB_ICON_INFO, m_pOnCancelClick);
WriteDebugEvent(SString("Connecting to %s:%u ...", m_strHost.c_str(), m_usPort));

Expand Down
14 changes: 5 additions & 9 deletions Client/core/CMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,17 +912,13 @@ bool CMainMenu::OnQuickConnectButtonClick(CGUIElement* pElement, bool left)
if (m_ucFade != FADE_VISIBLE)
return false;

// If we're right clicking, execute special command
if (!left)
if (left)
g_pCore->GetCommands()->Execute("reconnect", "");
else
{
std::string command;
CVARS_GET("_beta_qc_rightclick_command", command);
g_pCore->GetCommands()->Execute(command.data());
return true;
m_ServerBrowser.SetVisible(true);
m_ServerBrowser.OnQuickConnectButtonClick();
}

m_ServerBrowser.SetVisible(true);
m_ServerBrowser.OnQuickConnectButtonClick();
return true;
}

Expand Down
39 changes: 0 additions & 39 deletions Client/core/ServerBrowser/CServerBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,30 +924,6 @@ void CServerBrowser::CreateHistoryList()
}
}

// If we had no history, import it from our old quick connect
if (bEmpty)
{
std::string strAddress;
CVARS_GET("qc_host", strAddress);

if (!strAddress.empty())
{
std::string strPort;
CVARS_GET("qc_port", strPort);

if (!strPort.empty())
{
in_addr Address;
if (CServerListItem::Parse(strAddress.c_str(), Address))
{
m_ServersHistory.AddUnique(Address, atoi(strPort.c_str()));
CreateHistoryList(); // Restart with our new list.
return;
}
}
}
}

m_ServersHistory.Refresh();
}

Expand Down Expand Up @@ -2030,21 +2006,6 @@ std::string CServerBrowser::GetServerPassword(const std::string& strHost)
}
}
}

// If the server is the one from old quick connect, try importing the password from that
std::string strQCEndpoint;
CVARS_GET("qc_host", strQCEndpoint);

std::string strTemp;
CVARS_GET("qc_port", strTemp);

strQCEndpoint = strQCEndpoint + ":" + strTemp;
if (strQCEndpoint == strHost)
{
CVARS_GET("qc_password", strTemp);
return strTemp;
}

return "";
}

Expand Down
Loading