Skip to content
Permalink
Browse files

Merge pull request #1306 from multitheftauto/feature/qc_rightclick

Add CVAR _beta_qc_rightclick_command
  • Loading branch information
qaisjp committed Mar 21, 2020
2 parents 2c5251a + 92e1c73 commit d1c60675fc0f0f62b69707ae81a82e6bbdf36042
@@ -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"))
{
@@ -205,7 +205,7 @@ CMainMenu::CMainMenu(CGUI* pManager)
m_pMenuArea->SetSize(CVector2D(m_menuBX - m_menuAX, m_menuBY - m_menuAY) + BODGE_FACTOR_6, false);
m_pMenuArea->SetAlpha(0);
m_pMenuArea->SetZOrderingEnabled(false);
m_pMenuArea->SetClickHandler(GUI_CALLBACK(&CMainMenu::OnMenuClick, this));
m_pMenuArea->SetClickHandler(GUI_CALLBACK_MOUSE(&CMainMenu::OnMenuClick, this));
m_pMenuArea->SetMouseEnterHandler(GUI_CALLBACK(&CMainMenu::OnMenuEnter, this));
m_pMenuArea->SetMouseLeaveHandler(GUI_CALLBACK(&CMainMenu::OnMenuExit, this));

@@ -792,76 +792,84 @@ bool CMainMenu::OnMenuExit(CGUIElement* pElement)
return true;
}

bool CMainMenu::OnMenuClick(CGUIElement* pElement)
bool CMainMenu::OnMenuClick(CGUIMouseEventArgs Args)
{
// Handle all our clicks to the menu from here
if (m_pHoveredItem)
{
// For detecting startup problems
WatchDogUserDidInteractWithMenu();
CGUIElement* pElement = Args.pWindow;

// 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;
}
}
// Only handle all our clicks to the menu from here
if (!m_pHoveredItem)
return true;

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;
}

@@ -81,8 +81,8 @@ class CMainMenu

bool OnMenuEnter(CGUIElement* pElement);
bool OnMenuExit(CGUIElement* pElement);
bool OnMenuClick(CGUIElement* pElement);
bool OnQuickConnectButtonClick(CGUIElement* pElement);
bool OnMenuClick(CGUIMouseEventArgs Args);
bool OnQuickConnectButtonClick(CGUIElement* pElement, bool left);
bool OnResumeButtonClick(CGUIElement* pElement);
bool OnBrowseServersButtonClick(CGUIElement* pElement);
bool OnHostGameButtonClick();
@@ -495,6 +495,11 @@ void CGUIElement_Impl::SetClickHandler(GUI_CALLBACK Callback)
m_OnClick = Callback;
}

void CGUIElement_Impl::SetClickHandler(const GUI_CALLBACK_MOUSE& Callback)
{
m_OnClickWithArgs = Callback;
}

void CGUIElement_Impl::SetDoubleClickHandler(GUI_CALLBACK Callback)
{
m_OnDoubleClick = Callback;
@@ -565,10 +570,29 @@ bool CGUIElement_Impl::Event_OnSized(const CEGUI::EventArgs& e)
return true;
}

bool CGUIElement_Impl::Event_OnClick()
bool CGUIElement_Impl::Event_OnClick(const CEGUI::EventArgs& eBase)
{
const CEGUI::MouseEventArgs& e = reinterpret_cast<const CEGUI::MouseEventArgs&>(eBase);
CGUIElement* pElement = reinterpret_cast<CGUIElement*>(this);

if (m_OnClick)
m_OnClick(reinterpret_cast<CGUIElement*>(this));
m_OnClick(pElement);

if (m_OnClickWithArgs)
{
CGUIMouseEventArgs NewArgs;

// copy the variables
NewArgs.button = static_cast<CGUIMouse::MouseButton>(e.button);
NewArgs.moveDelta = CVector2D(e.moveDelta.d_x, e.moveDelta.d_y);
NewArgs.position = CGUIPosition(e.position.d_x, e.position.d_y);
NewArgs.sysKeys = e.sysKeys;
NewArgs.wheelChange = e.wheelChange;
NewArgs.pWindow = pElement;

m_OnClickWithArgs(NewArgs);
}

return true;
}

@@ -661,4 +685,4 @@ bool CGUIElement_Impl::Event_OnKeyDown(const CEGUI::EventArgs& e)
inline void CGUIElement_Impl::ForceRedraw()
{
m_pWindow->forceRedraw();
}
}
@@ -103,6 +103,7 @@ class CGUIElement_Impl : public CGUIElement
void SetMovedHandler(GUI_CALLBACK Callback);
void SetSizedHandler(GUI_CALLBACK Callback);
void SetClickHandler(GUI_CALLBACK Callback);
void SetClickHandler(const GUI_CALLBACK_MOUSE& Callback);
void SetDoubleClickHandler(GUI_CALLBACK Callback);
void SetMouseEnterHandler(GUI_CALLBACK Callback);
void SetMouseLeaveHandler(GUI_CALLBACK Callback);
@@ -113,7 +114,7 @@ class CGUIElement_Impl : public CGUIElement
void SetKeyDownHandler(const GUI_CALLBACK_KEY& Callback);
void SetEnterKeyHandler(GUI_CALLBACK Callback);

bool Event_OnClick();
bool Event_OnClick(const CEGUI::EventArgs& e);
bool Event_OnDoubleClick();
bool Event_OnMouseEnter();
bool Event_OnMouseLeave();
@@ -143,16 +144,18 @@ class CGUIElement_Impl : public CGUIElement

std::list<CGUIProperty*> m_Properties;

GUI_CALLBACK m_OnClick;
GUI_CALLBACK m_OnDoubleClick;
GUI_CALLBACK m_OnMoved;
GUI_CALLBACK m_OnSized;
GUI_CALLBACK m_OnMouseEnter;
GUI_CALLBACK m_OnMouseLeave;
GUI_CALLBACK m_OnMouseDown;
GUI_CALLBACK m_OnActivate;
GUI_CALLBACK m_OnDeactivate;
GUI_CALLBACK m_OnKeyDown;
GUI_CALLBACK m_OnEnter;
GUI_CALLBACK_KEY m_OnKeyDownWithArgs;
GUI_CALLBACK m_OnClick;
GUI_CALLBACK m_OnDoubleClick;
GUI_CALLBACK m_OnMoved;
GUI_CALLBACK m_OnSized;
GUI_CALLBACK m_OnMouseEnter;
GUI_CALLBACK m_OnMouseLeave;
GUI_CALLBACK m_OnMouseDown;
GUI_CALLBACK m_OnActivate;
GUI_CALLBACK m_OnDeactivate;
GUI_CALLBACK m_OnKeyDown;
GUI_CALLBACK m_OnEnter;

GUI_CALLBACK_MOUSE m_OnClickWithArgs;
GUI_CALLBACK_KEY m_OnKeyDownWithArgs;
};
@@ -248,6 +248,10 @@ void SetClickHandler(GUI_CALLBACK Callback)
{
CGUIElement_Impl::SetClickHandler(Callback);
};
void SetClickHandler(const GUI_CALLBACK_MOUSE& Callback)
{
CGUIElement_Impl::SetClickHandler(Callback);
};
void SetDoubleClickHandler(GUI_CALLBACK Callback)
{
CGUIElement_Impl::SetDoubleClickHandler(Callback);
@@ -293,9 +297,9 @@ void SetEnterKeyHandler(GUI_CALLBACK Callback)
CGUIElement_Impl::SetEnterKeyHandler(Callback);
};

bool Event_OnClick()
bool Event_OnClick(const CEGUI::EventArgs& e)
{
return CGUIElement_Impl::Event_OnClick();
return CGUIElement_Impl::Event_OnClick(e);
};
bool Event_OnDoubleClick()
{
@@ -1041,7 +1041,7 @@ bool CGUI_Impl::Event_MouseClick(const CEGUI::EventArgs& Args)

// Call global and object handlers
if (pElement)
pElement->Event_OnClick();
pElement->Event_OnClick(Args);

if (m_MouseClickHandlers[m_Channel])
{
@@ -18,6 +18,12 @@ class CGUIElement;
#include <string>
#include "CGUITypes.h"

// Forward declaration
namespace CEGUI
{
class EventArgs;
}

enum eCGUIType
{
CGUI_BUTTON,
@@ -119,6 +125,7 @@ class CGUIElement
virtual void SetMovedHandler(GUI_CALLBACK Callback) = 0;
virtual void SetSizedHandler(GUI_CALLBACK Callback) = 0;
virtual void SetClickHandler(GUI_CALLBACK Callback) = 0;
virtual void SetClickHandler(const GUI_CALLBACK_MOUSE& Callback) = 0;
virtual void SetDoubleClickHandler(GUI_CALLBACK Callback) = 0;
virtual void SetMouseEnterHandler(GUI_CALLBACK Callback) = 0;
virtual void SetMouseLeaveHandler(GUI_CALLBACK Callback) = 0;
@@ -129,7 +136,7 @@ class CGUIElement
virtual void SetKeyDownHandler(const GUI_CALLBACK_KEY& Callback) = 0;
virtual void SetEnterKeyHandler(GUI_CALLBACK Callback) = 0;

virtual bool Event_OnClick() = 0;
virtual bool Event_OnClick(const CEGUI::EventArgs& e) = 0;
virtual bool Event_OnDoubleClick() = 0;
virtual bool Event_OnMouseEnter() = 0;
virtual bool Event_OnMouseLeave() = 0;

0 comments on commit d1c6067

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