Skip to content
Permalink
Browse files

Add "beta" CVAR "_beta_qc_rightclick_command"

This variable lets you execute a command of your choice when you right
click the "quick connect" button.

By default this CVAR is set to "reconnect", but you can set it to
anything - "connect orange.mtasa.com" or "nick timw0w".

In the console, type "_beta_qc_rightclick_command" and press enter. This
will tell you the current value of the CVAR.

You can do "_beta_qc_rightclick_command=nick timw0w" to change the
value of the CVAR.
  • Loading branch information
qaisjp committed Mar 21, 2020
1 parent 6ede4f2 commit 92e1c73fe05dadc20dae3a92f7afd6f2e3a39e33
Showing with 56 additions and 49 deletions.
  1. +1 −0 Client/core/CClientVariables.cpp
  2. +54 −48 Client/core/CMainMenu.cpp
  3. +1 −1 Client/core/CMainMenu.h
@@ -350,6 +350,7 @@ void CClientVariables::LoadDefaults()
DEFAULT("browser_remote_websites", true); // Load remote websites?
DEFAULT("browser_remote_javascript", true); // Execute javascript on remote websites?
DEFAULT("filter_duplicate_log_lines", true); // Filter duplicate log lines for debug view and clientscript.log
DEFAULT("_beta_qc_rightclick_command", _S("reconnect")); // Command to run when right clicking quick connect (beta - can be removed at any time)

if (!Exists("locale"))
{
@@ -796,74 +796,80 @@ bool CMainMenu::OnMenuClick(CGUIMouseEventArgs Args)
{
CGUIElement* pElement = Args.pWindow;

// Handle all our clicks to the menu from here
if (m_pHoveredItem)
{
// For detecting startup problems
WatchDogUserDidInteractWithMenu();
// Only handle all our clicks to the menu from here
if (!m_pHoveredItem)
return true;

// Possible disconnect question for user
if (g_pCore->IsConnected())
{
switch (m_pHoveredItem->menuType)
{
case MENU_ITEM_HOST_GAME:
case MENU_ITEM_MAP_EDITOR:
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
return true;
default:
break;
}
}
if (Args.button != LeftButton && m_pHoveredItem->menuType != MENU_ITEM_QUICK_CONNECT)
return true;

// For detecting startup problems
WatchDogUserDidInteractWithMenu();

// Possible disconnect question for user
if (g_pCore->IsConnected())
{
switch (m_pHoveredItem->menuType)
{
case MENU_ITEM_DISCONNECT:
OnDisconnectButtonClick(pElement);
break;
case MENU_ITEM_QUICK_CONNECT:
OnQuickConnectButtonClick(pElement);
break;
case MENU_ITEM_BROWSE_SERVERS:
OnBrowseServersButtonClick(pElement);
break;
case MENU_ITEM_HOST_GAME:
OnHostGameButtonClick();
break;
case MENU_ITEM_MAP_EDITOR:
OnEditorButtonClick();
break;
case MENU_ITEM_SETTINGS:
OnSettingsButtonClick(pElement);
break;
case MENU_ITEM_ABOUT:
OnAboutButtonClick(pElement);
break;
case MENU_ITEM_QUIT:
OnQuitButtonClick(pElement);
break;
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
return true;
default:
break;
}
}

switch (m_pHoveredItem->menuType)
{
case MENU_ITEM_DISCONNECT:
OnDisconnectButtonClick(pElement);
break;
case MENU_ITEM_QUICK_CONNECT:
OnQuickConnectButtonClick(pElement, Args.button == LeftButton);
break;
case MENU_ITEM_BROWSE_SERVERS:
OnBrowseServersButtonClick(pElement);
break;
case MENU_ITEM_HOST_GAME:
OnHostGameButtonClick();
break;
case MENU_ITEM_MAP_EDITOR:
OnEditorButtonClick();
break;
case MENU_ITEM_SETTINGS:
OnSettingsButtonClick(pElement);
break;
case MENU_ITEM_ABOUT:
OnAboutButtonClick(pElement);
break;
case MENU_ITEM_QUIT:
OnQuitButtonClick(pElement);
break;
default:
break;
}

return true;
}

bool CMainMenu::OnQuickConnectButtonClick(CGUIElement* pElement)
bool CMainMenu::OnQuickConnectButtonClick(CGUIElement* pElement, bool left)
{
// Return if we haven't faded in yet
if (m_ucFade != FADE_VISIBLE)
return false;

// If we're right clicking, execute special command
if (!left)
{
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();
/*
// if ( !m_bIsInSubWindow )
{
m_QuickConnect.SetVisible ( true );
// m_bIsInSubWindow = true;
}
*/
return true;
}

@@ -82,7 +82,7 @@ class CMainMenu
bool OnMenuEnter(CGUIElement* pElement);
bool OnMenuExit(CGUIElement* pElement);
bool OnMenuClick(CGUIMouseEventArgs Args);
bool OnQuickConnectButtonClick(CGUIElement* pElement);
bool OnQuickConnectButtonClick(CGUIElement* pElement, bool left);
bool OnResumeButtonClick(CGUIElement* pElement);
bool OnBrowseServersButtonClick(CGUIElement* pElement);
bool OnHostGameButtonClick();

0 comments on commit 92e1c73

Please sign in to comment.
You can’t perform that action at this time.