Skip to content

Ask before disconnecting using game menu #4181

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 3 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
15 changes: 13 additions & 2 deletions Client/core/CMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,14 @@ bool CMainMenu::OnMenuClick(CGUIMouseEventArgs Args)
case MENU_ITEM_MAP_EDITOR:
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
return true;
case MENU_ITEM_DISCONNECT:
if (g_pCore->GetCVars()->GetValue("ask_before_disconnect", true))
{
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
return true;
}

break;
default:
break;
}
Expand All @@ -863,7 +871,7 @@ bool CMainMenu::OnMenuClick(CGUIMouseEventArgs Args)
switch (m_pHoveredItem->menuType)
{
case MENU_ITEM_DISCONNECT:
OnDisconnectButtonClick(pElement);
OnDisconnectButtonClick();
break;
case MENU_ITEM_QUICK_CONNECT:
OnQuickConnectButtonClick(pElement, Args.button == LeftButton);
Expand Down Expand Up @@ -948,7 +956,7 @@ void CMainMenu::HideServerInfo()
m_ServerInfo.Hide();
}

bool CMainMenu::OnDisconnectButtonClick(CGUIElement* pElement)
bool CMainMenu::OnDisconnectButtonClick()
{
// Return if we haven't faded in yet
if (m_ucFade != FADE_VISIBLE)
Expand Down Expand Up @@ -1251,6 +1259,9 @@ void CMainMenu::WantsToDisconnectCallBack(void* pData, uint uiButton)
case MENU_ITEM_MAP_EDITOR:
OnEditorButtonClick();
break;
case MENU_ITEM_DISCONNECT:
OnDisconnectButtonClick();
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Client/core/CMainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CMainMenu
bool OnResumeButtonClick(CGUIElement* pElement);
bool OnBrowseServersButtonClick(CGUIElement* pElement);
bool OnHostGameButtonClick();
bool OnDisconnectButtonClick(CGUIElement* pElement);
bool OnDisconnectButtonClick();
bool OnEditorButtonClick();
bool OnSettingsButtonClick(CGUIElement* pElement);
bool OnAboutButtonClick(CGUIElement* pElement);
Expand Down
12 changes: 12 additions & 0 deletions Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ void CSettings::CreateGUI()
m_pPhotoSavingCheckbox->GetPosition(vecTemp, false);
m_pPhotoSavingCheckbox->AutoSize(NULL, 20.0f);

m_pCheckBoxAskBeforeDisconnect = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Ask before disconnecting from server using main menu"), true));
m_pCheckBoxAskBeforeDisconnect->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 20.0f));
m_pCheckBoxAskBeforeDisconnect->GetPosition(vecTemp, false);
m_pCheckBoxAskBeforeDisconnect->AutoSize(NULL, 20.0f);

m_pCheckBoxCustomizedSAFiles = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Use customized GTA:SA files"), true));
m_pCheckBoxCustomizedSAFiles->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 20.0f));
m_pCheckBoxCustomizedSAFiles->GetPosition(vecTemp, false);
Expand Down Expand Up @@ -3080,6 +3085,10 @@ void CSettings::LoadData()
CVARS_GET("allow_discord_rpc", bAllowDiscordRPC);
m_pCheckBoxAllowDiscordRPC->SetSelected(bAllowDiscordRPC);

bool bAskBeforeDisconnect;
CVARS_GET("ask_before_disconnect", bAskBeforeDisconnect);
m_pCheckBoxAskBeforeDisconnect->SetSelected(bAskBeforeDisconnect);

// Customized sa files
m_pCheckBoxCustomizedSAFiles->SetSelected(GetApplicationSettingInt("customized-sa-files-request") != 0);
m_pCheckBoxCustomizedSAFiles->SetVisible(GetApplicationSettingInt("customized-sa-files-show") != 0);
Expand Down Expand Up @@ -3557,6 +3566,9 @@ void CSettings::SaveData()
}
}

bool bAskBeforeDisconnect = m_pCheckBoxAskBeforeDisconnect->GetSelected();
CVARS_SET("ask_before_disconnect", bAskBeforeDisconnect);

// Grass
bool bGrassEnabled = m_pCheckBoxGrass->GetSelected();
CVARS_SET("grass", bGrassEnabled);
Expand Down
1 change: 1 addition & 0 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class CSettings
CGUICheckBox* m_pWin8ColorCheckBox;
CGUICheckBox* m_pWin8MouseCheckBox;
CGUICheckBox* m_pPhotoSavingCheckbox;
CGUICheckBox* m_pCheckBoxAskBeforeDisconnect;
CGUICheckBox* m_pProcessAffinityCheckbox;
CGUILabel* m_pUpdateBuildTypeLabel;
CGUIComboBox* m_pUpdateBuildTypeCombo;
Expand Down