Skip to content

Commit

Permalink
Merge branch 'master' into feature/setElementOnFire
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX authored Dec 30, 2024
2 parents 7b4bb1b + c7644f2 commit 9e7cf77
Show file tree
Hide file tree
Showing 131 changed files with 3,298 additions and 2,479 deletions.
8 changes: 4 additions & 4 deletions Client/cefweb/CWebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,10 +936,10 @@ void CWebView::OnBeforeClose(CefRefPtr<CefBrowser> browser)
// //
// //
////////////////////////////////////////////////////////////////////
bool CWebView::OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue>& extra_info,
bool* no_javascript_access)
bool CWebView::OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int popup_id, const CefString& target_url,
const CefString& target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture,
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info, bool* no_javascript_access)
{
// ATTENTION: This method is called on the IO thread

Expand Down
8 changes: 4 additions & 4 deletions Client/cefweb/CWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ class CWebView : public CWebViewInterface,

// CefLifeSpawnHandler methods
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue>& extra_info,
bool* no_javascript_access) override;
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int popup_id, const CefString& target_url,
const CefString& target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture,
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info, bool* no_javascript_access) override;
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;

// CefJSDialogHandler methods
Expand Down
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
2 changes: 1 addition & 1 deletion Client/core/CQueryReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ SQueryInfo CQueryReceiver::GetServerResponse()

// Recover server ping status if present
const SString strPingStatus = strBuildNumber.Right(strBuildNumber.length() - strlen(strBuildNumber) - 1);
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(*strPingStatus, info.players, info.isStatusVerified);
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(strPingStatus.c_str(), strPingStatus.length(), info.players, info.isStatusVerified);

// Recover server http port if present
const SString strNetRoute = strPingStatus.Right(strPingStatus.length() - strlen(strPingStatus) - 1);
Expand Down
22 changes: 20 additions & 2 deletions Client/core/CScreenShot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ static bool ms_bIsSaving = false;
static uint ms_uiWidth = 0;
static uint ms_uiHeight = 0;

// whether we want to actually save photo in documents folder
static bool savePhotoInDocuments = false;

void CScreenShot::InitiateScreenShot(bool bIsCameraShot)
{
if (ms_bScreenShot || ms_bIsSaving || IsRateLimited(bIsCameraShot))
Expand All @@ -48,8 +51,11 @@ void CScreenShot::InitiateScreenShot(bool bIsCameraShot)

if (bIsCameraShot)
{
// Set the screenshot path to camera gallery path
ms_strScreenDirectoryPath = PathJoin(GetSystemPersonalPath(), "GTA San Andreas User Files", "Gallery");
if (savePhotoInDocuments)
{
// Set the screenshot path to camera gallery path
ms_strScreenDirectoryPath = PathJoin(GetSystemPersonalPath(), "GTA San Andreas User Files", "Gallery");
}
}
else
{
Expand Down Expand Up @@ -82,6 +88,13 @@ void CScreenShot::CheckForScreenShot(bool bBeforeGUI)
// Update last time of taken screenshot of given type
ms_lLastSaveTime[ms_bIsCameraShot] = GetTickCount64_();

if (ms_bIsCameraShot && !savePhotoInDocuments)
{
ClearBuffer();
ms_bScreenShot = false;
return;
}

ms_strScreenShotPath = GetScreenshotPath();
ms_uiWidth = CDirect3DData::GetSingleton().GetViewportWidth();
ms_uiHeight = CDirect3DData::GetSingleton().GetViewportHeight();
Expand Down Expand Up @@ -205,3 +218,8 @@ void CScreenShot::ClearBuffer()
{
ms_ScreenShotBuffer.Clear();
}

void CScreenShot::SetPhotoSavingInsideDocuments(bool savePhoto) noexcept
{
savePhotoInDocuments = savePhoto;
}
1 change: 1 addition & 0 deletions Client/core/CScreenShot.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CScreenShot
public:
static void InitiateScreenShot(bool bIsCameraShot);
static void CheckForScreenShot(bool bBeforeGUI);
static void SetPhotoSavingInsideDocuments(bool bSavePhoto) noexcept;

protected:
static void StartSaveThread();
Expand Down
15 changes: 15 additions & 0 deletions Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,12 @@ void CSettings::CreateGUI()
m_pCachePathValue->AutoSize();
vecTemp.fY += fLineHeight;

// Enable camera photos getting saved to documents folder
m_pPhotoSavingCheckbox = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabAdvanced, _("Save photos taken by camera weapon to GTA San Andreas User Files folder"), true));
m_pPhotoSavingCheckbox->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY));
m_pPhotoSavingCheckbox->AutoSize(NULL, 20.0f);
vecTemp.fY += fLineHeight;

// Auto updater section label
m_pAdvancedUpdaterLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabAdvanced, _("Auto updater")));
m_pAdvancedUpdaterLabel->SetPosition(CVector2D(vecTemp.fX - 10.0f, vecTemp.fY));
Expand Down Expand Up @@ -3218,6 +3224,10 @@ void CSettings::LoadData()
iVar = GetApplicationSettingInt("Win8MouseFix");
m_pWin8MouseCheckBox->SetSelected(iVar != 0);

// Save camera photos inside user documents folder
CVARS_GET("photosaving", bVar);
m_pPhotoSavingCheckbox->SetSelected(bVar);

// Update build type
CVARS_GET("update_build_type", iVar);
if (iVar == 0 || iVar == 1)
Expand Down Expand Up @@ -3609,6 +3619,11 @@ void CSettings::SaveData()
// Windows 8 mouse fix
SetApplicationSettingInt("Win8MouseFix", m_pWin8MouseCheckBox->GetSelected());

// Save photos in documents folder
bool photoSaving = m_pPhotoSavingCheckbox->GetSelected();
CVARS_SET("photosaving", photoSaving);
CScreenShot::SetPhotoSavingInsideDocuments(photoSaving);

// Debug setting
if (CGUIListItem* pSelected = m_pDebugSettingCombo->GetSelectedItem())
{
Expand Down
1 change: 1 addition & 0 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class CSettings
CGUILabel* m_pWin8Label;
CGUICheckBox* m_pWin8ColorCheckBox;
CGUICheckBox* m_pWin8MouseCheckBox;
CGUICheckBox* m_pPhotoSavingCheckbox;
CGUILabel* m_pUpdateBuildTypeLabel;
CGUIComboBox* m_pUpdateBuildTypeCombo;
CGUILabel* m_pUpdateAutoInstallLabel;
Expand Down
26 changes: 26 additions & 0 deletions Client/core/DXHook/CProxyDirect3D9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
*****************************************************************************/

#include "StdInc.h"
#include <dwmapi.h>
#include <resource.h>

extern HINSTANCE g_hModule;

HRESULT HandleCreateDeviceResult(HRESULT hResult, IDirect3D9* pDirect3D, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface);
std::vector<IDirect3D9*> ms_CreatedDirect3D9List;
Expand Down Expand Up @@ -166,6 +171,27 @@ HRESULT CProxyDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND
SetWindowTextW(hFocusWindow, MbUTF8ToUTF16("MTA: San Andreas").c_str());
#endif

// Set dark titlebar if needed
BOOL darkTitleBar = GetSystemRegistryValue((uint)HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme") == "\x0";
DwmSetWindowAttribute(hFocusWindow, DWMWA_USE_IMMERSIVE_DARK_MODE, &darkTitleBar, sizeof(darkTitleBar));

// Update icon
if (HICON icon = LoadIcon(g_hModule, MAKEINTRESOURCE(IDI_ICON1)))
{
const auto paramIcon = reinterpret_cast<LPARAM>(icon);
for (const WPARAM size : {ICON_SMALL, ICON_BIG})
{
SendMessage(hFocusWindow, WM_SETICON, size, paramIcon);
}

// Clean
DestroyIcon(icon);
}

// Redraw, we avoid possible problems with the fact that it won't replace the icon somewhere
InvalidateRect(hFocusWindow, nullptr, TRUE);
UpdateWindow(hFocusWindow);

// Detect if second call to CreateDevice
if (CreateDeviceSecondCallCheck(hResult, m_pDevice, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface))
{
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
2 changes: 1 addition & 1 deletion Client/core/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ project "Client Core"

links {
"ws2_32", "d3dx9", "Userenv", "DbgHelp", "xinput", "Imagehlp", "dxguid", "dinput8",
"strmiids", "odbc32", "odbccp32", "shlwapi", "winmm", "gdi32", "Imm32", "Psapi",
"strmiids", "odbc32", "odbccp32", "shlwapi", "winmm", "gdi32", "Imm32", "Psapi", "dwmapi",
"pthread", "libpng", "jpeg", "zlib", "tinygettext", "discord-rpc",
}

Expand Down
12 changes: 11 additions & 1 deletion Client/game_sa/CBuildingsPoolSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ CBuilding* CBuildingsPoolSA::AddBuilding(CClientBuilding* pClientBuilding, uint1
if (!HasFreeBuildingSlot())
return nullptr;

auto modelInfo = pGame->GetModelInfo(modelId);

// Change the properties group to force dynamic models to be created as buildings instead of dummies
auto prevGroup = modelInfo->GetObjectPropertiesGroup();
if (prevGroup != MODEL_PROPERTIES_GROUP_STATIC)
modelInfo->SetObjectPropertiesGroup(MODEL_PROPERTIES_GROUP_STATIC);

// Load building
SFileObjectInstance instance;
instance.modelID = modelId;
Expand All @@ -70,9 +77,12 @@ CBuilding* CBuildingsPoolSA::AddBuilding(CClientBuilding* pClientBuilding, uint1
pBuilding->m_pLod = nullptr;
pBuilding->m_iplIndex = 0;

// Restore changed properties group
if (prevGroup != MODEL_PROPERTIES_GROUP_STATIC)
modelInfo->SetObjectPropertiesGroup(prevGroup);

// Always stream model collosion
// TODO We can setup collison bounding box and use GTA streamer for it
auto modelInfo = pGame->GetModelInfo(modelId);
modelInfo->AddColRef();

// Add building in world
Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CEntitySA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ bool CEntitySA::GetBonePosition(eBone boneId, CVector& position)
return false;

const RwV3d& pos = rwBoneMatrix->pos;
position = {pos.x, pos.y, pos.z};
position = CVector(pos.x, pos.y, pos.z);
return true;
}

Expand Down
Loading

0 comments on commit 9e7cf77

Please sign in to comment.