From 2f64af09bb36c3d0caa4bd21e3b325e30b1785ec Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Sun, 6 Oct 2024 13:39:53 +0200 Subject: [PATCH] #3676 --- Client/mods/deathmatch/logic/CClientGame.cpp | 1 + Client/mods/deathmatch/logic/CClientWebBrowser.cpp | 10 ++++++++++ Client/mods/deathmatch/logic/CClientWebBrowser.h | 1 + Client/sdk/core/CWebBrowserEventsInterface.h | 1 + 4 files changed, 13 insertions(+) diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index bc20947eac1..70d5992e86b 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -2778,6 +2778,7 @@ void CClientGame::AddBuiltInEvents() m_Events.AddEvent("onClientBrowserTooltip", "text", NULL, false); m_Events.AddEvent("onClientBrowserInputFocusChanged", "gainedfocus", NULL, false); m_Events.AddEvent("onClientBrowserResourceBlocked", "url, domain, reason", NULL, false); + m_Events.AddEvent("onClientBrowserConsoleMessage", "message, source, line, level", nullptr, false); // Misc events m_Events.AddEvent("onClientFileDownloadComplete", "fileName, success", NULL, false); diff --git a/Client/mods/deathmatch/logic/CClientWebBrowser.cpp b/Client/mods/deathmatch/logic/CClientWebBrowser.cpp index cf54f463e75..5284382d96a 100644 --- a/Client/mods/deathmatch/logic/CClientWebBrowser.cpp +++ b/Client/mods/deathmatch/logic/CClientWebBrowser.cpp @@ -305,6 +305,16 @@ void CClientWebBrowser::Events_OnAjaxRequest(CAjaxResourceHandlerInterface* pHan pHandler->SetResponse(result); } +void CClientWebBrowser::Events_OnConsoleMessage(const std::string& message, const std::string& source, int line, std::int16_t level) +{ + CLuaArguments arguments; + arguments.PushString(message); + arguments.PushString(source); + arguments.PushNumber(line); + arguments.PushNumber(level); + CallEvent("onClientBrowserConsoleMessage", arguments, false); +} + bool CClientWebBrowser::AddAjaxHandler(const SString& strURL, ajax_callback_t& handler) { if (!m_pWebView->RegisterAjaxHandler(strURL)) diff --git a/Client/mods/deathmatch/logic/CClientWebBrowser.h b/Client/mods/deathmatch/logic/CClientWebBrowser.h index 09de6ce0afc..9838d2a5330 100644 --- a/Client/mods/deathmatch/logic/CClientWebBrowser.h +++ b/Client/mods/deathmatch/logic/CClientWebBrowser.h @@ -84,6 +84,7 @@ class CClientWebBrowser : public CClientTexture, public CWebBrowserEventsInterfa bool Events_OnResourceFileCheck(const SString& strURL, CBuffer& outFileData) override; void Events_OnResourceBlocked(const SString& strURL, const SString& strDomain, unsigned char reason) override; void Events_OnAjaxRequest(CAjaxResourceHandlerInterface* pHandler, const SString& strURL) override; + void Events_OnConsoleMessage(const std::string& message, const std::string& source, int line, std::int16_t level) override; private: CWebViewInterface* m_pWebView; diff --git a/Client/sdk/core/CWebBrowserEventsInterface.h b/Client/sdk/core/CWebBrowserEventsInterface.h index 1db426df894..4479b5a050b 100644 --- a/Client/sdk/core/CWebBrowserEventsInterface.h +++ b/Client/sdk/core/CWebBrowserEventsInterface.h @@ -28,4 +28,5 @@ class CWebBrowserEventsInterface virtual bool Events_OnResourceFileCheck(const SString& strURL, CBuffer& outFileData) = 0; virtual void Events_OnResourceBlocked(const SString& strURL, const SString& strDomain, unsigned char reason) = 0; virtual void Events_OnAjaxRequest(CAjaxResourceHandlerInterface* pHandler, const SString& strURL) = 0; + virtual void Events_OnConsoleMessage(const std::string& message, const std::string& source, int line, std::int16_t level) = 0; };