Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/utils/localization…
Browse files Browse the repository at this point in the history
…/generate-images/axios-1.6.1
  • Loading branch information
Dutchman101 authored Jan 7, 2024
2 parents ea1f0b7 + 22d844d commit 18b1ae1
Show file tree
Hide file tree
Showing 303 changed files with 18,255 additions and 14,844 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Create build artifacts
run: utils\premake5 compose_files

- uses: actions/upload-artifact@master
- uses: actions/upload-artifact@v3
with:
name: InstallFiles
path: InstallFiles/
Expand Down
2 changes: 1 addition & 1 deletion Client/ceflauncher_DLL/CCefApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CCefApp : public CefApp, public CefRenderProcessHandler
if (!node)
return;

if (node->GetType() == CefDOMNode::Type::DOM_NODE_TYPE_ELEMENT && !node->GetFormControlElementType().empty())
if (node->GetType() == CefDOMNode::Type::DOM_NODE_TYPE_ELEMENT && node->GetFormControlElementType() != CefDOMNode::FormControlType::DOM_FORM_CONTROL_TYPE_UNSUPPORTED)
{
auto message = CefProcessMessage::Create("InputFocus");
message->GetArgumentList()->SetBool(0, true);
Expand Down
4 changes: 3 additions & 1 deletion Client/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ void CClientVariables::LoadDefaults()
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("always_show_transferbox", false); // Should the transfer box always be visible for downloads? (and ignore scripted control)
DEFAULT("allow_discord_rpc", true); // Enable Discord Rich Presence
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)

if (!Exists("locale"))
Expand Down
10 changes: 3 additions & 7 deletions Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1994,16 +1994,12 @@ void CCore::OnDeviceRestore()
//
void CCore::OnPreFxRender()
{
// Don't do nothing if nothing won't be drawn

if (CGraphics::GetSingleton().HasPrimitive3DPreGUIQueueItems())
CGraphics::GetSingleton().DrawPrimitive3DPreGUIQueue();

if (!CGraphics::GetSingleton().HasLine3DPreGUIQueueItems())
return;
if (!CGraphics::GetSingleton().HasLine3DPreGUIQueueItems() && !CGraphics::GetSingleton().HasPrimitive3DPreGUIQueueItems())
return;

CGraphics::GetSingleton().EnteringMTARenderZone();

CGraphics::GetSingleton().DrawPrimitive3DPreGUIQueue();
CGraphics::GetSingleton().DrawLine3DPreGUIQueue();

CGraphics::GetSingleton().LeavingMTARenderZone();
Expand Down
53 changes: 30 additions & 23 deletions Client/core/CDiscordRichPresence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ CDiscordRichPresence::~CDiscordRichPresence()

void CDiscordRichPresence::InitializeDiscord()
{
std::lock_guard<std::mutex> lock(m_threadSafetyMutex);
DiscordEventHandlers handlers;
memset(&handlers, 0, sizeof(handlers));

Expand All @@ -51,9 +52,6 @@ void CDiscordRichPresence::InitializeDiscord()

void CDiscordRichPresence::ShutdownDiscord()
{
if (!m_bDiscordRPCEnabled)
return;

Discord_ClearPresence();
Discord_Shutdown();

Expand All @@ -62,9 +60,6 @@ void CDiscordRichPresence::ShutdownDiscord()

void CDiscordRichPresence::RestartDiscord()
{
if (!m_bDiscordRPCEnabled)
return;

ShutdownDiscord();
InitializeDiscord();
}
Expand Down Expand Up @@ -99,12 +94,19 @@ void CDiscordRichPresence::SetDefaultData()

void CDiscordRichPresence::UpdatePresence()
{
if (!m_bDiscordRPCEnabled)
return;

// run callbacks
Discord_RunCallbacks();

if (!m_bConnected)
return;

if (!m_bUpdateRichPresence)
return;


std::lock_guard<std::mutex> lock(m_threadSafetyMutex);
DiscordRichPresence discordPresence;
memset(&discordPresence, 0, sizeof(discordPresence));

Expand All @@ -121,7 +123,7 @@ void CDiscordRichPresence::UpdatePresence()
discordPresence.endTimestamp = m_uiDiscordAppEnd;
discordPresence.instance = 0;

DiscordButton buttons[2];
DiscordButton buttons[2]{0};
if (m_aButtons)
{
buttons[0].label = std::get<0>(*m_aButtons).first.c_str();
Expand Down Expand Up @@ -264,16 +266,6 @@ bool CDiscordRichPresence::SetDiscordRPCEnabled(bool bEnabled)
return true;
}

bool CDiscordRichPresence::IsDiscordRPCEnabled() const
{
return m_bDiscordRPCEnabled;
}

bool CDiscordRichPresence::IsDiscordCustomDetailsDisallowed() const
{
return m_bDisallowCustomDetails;
}

void CDiscordRichPresence::SetPresencePartySize(int iSize, int iMax, bool bCustom)
{
if (bCustom)
Expand All @@ -288,6 +280,20 @@ void CDiscordRichPresence::SetPresencePartySize(int iSize, int iMax, bool bCusto
}
}

void CDiscordRichPresence::SetDiscordUserID(const std::string& strUserID)
{
if (CVARS_GET_VALUE<bool>("discord_rpc_share_data"))
m_strDiscordUserID = strUserID;
}

std::string CDiscordRichPresence::GetDiscordUserID() const
{
if (CVARS_GET_VALUE<bool>("discord_rpc_share_data"))
return m_strDiscordUserID;

return {};
};

#ifdef DISCORD_DISABLE_IO_THREAD
void CDiscordRichPresence::UpdatePresenceConnection()
{
Expand All @@ -298,23 +304,24 @@ void CDiscordRichPresence::UpdatePresenceConnection()
void CDiscordRichPresence::HandleDiscordReady(const DiscordUser* pDiscordUser)
{
if (const auto discord = g_pCore->GetDiscord(); discord && discord->IsDiscordRPCEnabled())
{
discord->SetDiscordClientConnected(true);
discord->SetDiscordUserID(pDiscordUser->userId);
}
}

void CDiscordRichPresence::HandleDiscordDisconnected(int iErrorCode, const char* szMessage)
{
WriteDebugEvent(SString("[DISCORD] Disconnected %s (error #%d)", szMessage, iErrorCode));

if (const auto discord = g_pCore->GetDiscord(); discord)
{
discord->SetDiscordUserID("");
discord->SetDiscordClientConnected(false);
}
}

void CDiscordRichPresence::HandleDiscordError(int iErrorCode, const char* szMessage)
{
WriteDebugEvent(SString("[DISCORD] Error: %s (error #%d)", szMessage, iErrorCode));
}

bool CDiscordRichPresence::IsDiscordClientConnected() const
{
return m_bConnected;
}
27 changes: 16 additions & 11 deletions Client/core/CDiscordRichPresence.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,40 @@ class CDiscordRichPresence : public CDiscordInterface
void ShutdownDiscord();
void RestartDiscord();
void SetDefaultData();

void UpdatePresence();
#ifdef DISCORD_DISABLE_IO_THREAD
void UpdatePresenceConnection();
#endif

void SetPresenceStartTimestamp(const unsigned long ulStart);
void SetPresenceEndTimestamp(const unsigned long ulEnd);
void SetAsset(const char* szAsset, const char* szAssetText, bool bIsLarge);
void SetAssetLargeData(const char* szAsset, const char* szAssetText);
void SetAssetSmallData(const char* szAsset, const char* szAssetText);
void SetDiscordClientConnected(bool bConnected) { m_bConnected = bConnected; };
void SetPresencePartySize(int iSize, int iMax, bool bCustom);
void SetDiscordUserID(const std::string& strUserID);

bool ResetDiscordData();
bool SetPresenceState(const char* szState, bool bCustom);
bool SetPresenceDetails(const char* szDetails, bool bCustom);
bool SetPresenceButtons(unsigned short int iIndex, const char* szName, const char* szUrl);
void SetPresencePartySize(int iSize, int iMax, bool bCustom);
bool SetDiscordRPCEnabled(bool bEnabled);
bool IsDiscordCustomDetailsDisallowed() const;
bool IsDiscordRPCEnabled() const;
bool SetApplicationID(const char* resourceName, const char* szAppID);
void SetDiscordClientConnected(bool bConnected) { m_bConnected = bConnected; };
bool IsDiscordClientConnected() const;
bool IsDiscordCustomDetailsDisallowed() const { return m_bDisallowCustomDetails; };
bool IsDiscordRPCEnabled() const { return m_bDiscordRPCEnabled; };
bool IsDiscordClientConnected() const { return m_bConnected; };

std::string GetDiscordResourceName() const { return m_strDiscordCustomResourceName; };
std::string GetDiscordUserID() const;

// handlers
// static handlers
static void HandleDiscordReady(const struct DiscordUser* pDiscordUser);
static void HandleDiscordDisconnected(int iErrorCode, const char* szMessage);
static void HandleDiscordError(int iErrorCode, const char* szMessage);

#ifdef DISCORD_DISABLE_IO_THREAD
void UpdatePresenceConnection();
#endif

private:
std::string m_strDiscordUserID;
std::string m_strDiscordAppId;
std::string m_strDiscordAppAsset;
std::string m_strDiscordAppAssetText;
Expand All @@ -69,6 +72,8 @@ class CDiscordRichPresence : public CDiscordInterface

std::optional<std::tuple<std::pair<std::string, std::string>, std::pair<std::string, std::string>>> m_aButtons;

std::mutex m_threadSafetyMutex;

unsigned long m_uiDiscordAppStart;
unsigned long m_uiDiscordAppEnd;

Expand Down
14 changes: 13 additions & 1 deletion Client/core/CMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ CMainMenu::CMainMenu(CGUI* pManager)
discord->SetPresenceState(_("Main menu"), false);
discord->SetPresenceStartTimestamp(0);
}

// Store the pointer to the graphics subsystem
m_pGraphics = CGraphics::GetSingletonPtr();

Expand Down Expand Up @@ -683,6 +682,19 @@ void CMainMenu::Update()
}
#endif

if (WaitForMenu == 299)
{
if (!g_pCore->GetCVars()->GetValue("discord_rpc_share_data_firsttime", false)
&& g_pCore->GetCVars()->GetValue("allow_discord_rpc", false)
&& !g_pCore->GetCVars()->GetValue("discord_rpc_share_data", false))
{
m_Settings.ShowRichPresenceShareDataQuestionBox();
CVARS_SET("discord_rpc_share_data_firsttime", true);
}
else
CVARS_SET("discord_rpc_share_data_firsttime", true);
}

if (WaitForMenu < 300)
WaitForMenu++;
}
Expand Down
30 changes: 29 additions & 1 deletion Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4515,10 +4515,38 @@ bool CSettings::OnAllowExternalSoundsClick(CGUIElement* pElement)
//
bool CSettings::OnAllowDiscordRPC(CGUIElement* pElement)
{
g_pCore->GetDiscord()->SetDiscordRPCEnabled(m_pCheckBoxAllowDiscordRPC->GetSelected());
bool isEnabled = m_pCheckBoxAllowDiscordRPC->GetSelected();
g_pCore->GetDiscord()->SetDiscordRPCEnabled(isEnabled);

if (isEnabled)
ShowRichPresenceShareDataQuestionBox(); // show question box

return true;
}

static void ShowRichPresenceShareDataCallback(void* ptr, unsigned int uiButton)
{
CCore::GetSingleton().GetLocalGUI()->GetMainMenu()->GetQuestionWindow()->Reset();

CVARS_SET("discord_rpc_share_data", static_cast<bool>(uiButton));
}

void CSettings::ShowRichPresenceShareDataQuestionBox() const
{
SStringX strMessage(
_("It seems that you have the Rich Presence connection option enabled."
"\nDo you want to allow servers to share their data?"
"\n\nThis includes yours unique ID identifier."));
CQuestionBox* pQuestionBox = CCore::GetSingleton().GetLocalGUI()->GetMainMenu()->GetQuestionWindow();
pQuestionBox->Reset();
pQuestionBox->SetTitle(_("CONSENT TO ALLOW DATA SHARING"));
pQuestionBox->SetMessage(strMessage);
pQuestionBox->SetButton(0, _("No"));
pQuestionBox->SetButton(1, _("Yes"));
pQuestionBox->SetCallback(ShowRichPresenceShareDataCallback);
pQuestionBox->Show();
}

//
// CustomizedSAFiles
//
Expand Down
1 change: 1 addition & 0 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class CSettings
bool IsActive();

void SetSelectedIndex(unsigned int uiIndex);
void ShowRichPresenceShareDataQuestionBox() const;

protected:
const static int SecKeyNum = 3; // Number of secondary keys
Expand Down
13 changes: 2 additions & 11 deletions Client/game_sa/CCameraSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

extern CGameSA* pGame;

unsigned long CCameraSA::FUNC_RwFrameGetLTM;
static bool bCameraClipObjects;
static bool bCameraClipVehicles;

Expand Down Expand Up @@ -358,16 +357,8 @@ float CCameraSA::GetCameraRotation()

RwMatrix* CCameraSA::GetLTM()
{
DWORD frame = *(DWORD*)(((DWORD)GetInterface()->m_pRwCamera) + 4);
DWORD dwReturn;
_asm
{
push frame
call FUNC_RwFrameGetLTM
add esp, 4
mov dwReturn, eax
}
return (RwMatrix*)dwReturn;
// RwFrameGetLTM
return ((RwMatrix*(_cdecl*)(void*))0x7F0990)(GetInterface()->m_pRwCamera->object.object.parent);
}

CEntity* CCameraSA::GetTargetEntity()
Expand Down
5 changes: 1 addition & 4 deletions Client/game_sa/CCameraSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class CCameraSAInterface
float m_fAttachedCamAngle; // for giving the attached camera a tilt.

// RenderWare camera pointer
DWORD* m_pRwCamera; // was RwCamera *
RwCamera* m_pRwCamera;
/// stuff for cut scenes
CEntitySAInterface* pTargetEntity;
CEntitySAInterface* pAttachedEntity;
Expand Down Expand Up @@ -426,7 +426,4 @@ class CCameraSA : public CCamera
void RestoreLastGoodState();
void SetShakeForce(float fShakeForce);
float GetShakeForce();

private:
static unsigned long FUNC_RwFrameGetLTM;
};
Loading

0 comments on commit 18b1ae1

Please sign in to comment.