Skip to content

Commit d296a65

Browse files
authored
Add onClientBrowserConsoleMessage event - #3676 follow up (#3773)
1 parent c0376c9 commit d296a65

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,6 +2784,7 @@ void CClientGame::AddBuiltInEvents()
27842784
m_Events.AddEvent("onClientBrowserTooltip", "text", NULL, false);
27852785
m_Events.AddEvent("onClientBrowserInputFocusChanged", "gainedfocus", NULL, false);
27862786
m_Events.AddEvent("onClientBrowserResourceBlocked", "url, domain, reason", NULL, false);
2787+
m_Events.AddEvent("onClientBrowserConsoleMessage", "message, source, line, level", nullptr, false);
27872788

27882789
// Misc events
27892790
m_Events.AddEvent("onClientFileDownloadComplete", "fileName, success", NULL, false);

Client/mods/deathmatch/logic/CClientWebBrowser.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ void CClientWebBrowser::Events_OnAjaxRequest(CAjaxResourceHandlerInterface* pHan
305305
pHandler->SetResponse(result);
306306
}
307307

308+
void CClientWebBrowser::Events_OnConsoleMessage(const std::string& message, const std::string& source, int line, std::int16_t level)
309+
{
310+
CLuaArguments arguments;
311+
arguments.PushString(message);
312+
arguments.PushString(source);
313+
arguments.PushNumber(line);
314+
arguments.PushNumber(level);
315+
CallEvent("onClientBrowserConsoleMessage", arguments, false);
316+
}
317+
308318
bool CClientWebBrowser::AddAjaxHandler(const SString& strURL, ajax_callback_t& handler)
309319
{
310320
if (!m_pWebView->RegisterAjaxHandler(strURL))

Client/mods/deathmatch/logic/CClientWebBrowser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class CClientWebBrowser : public CClientTexture, public CWebBrowserEventsInterfa
8484
bool Events_OnResourceFileCheck(const SString& strURL, CBuffer& outFileData) override;
8585
void Events_OnResourceBlocked(const SString& strURL, const SString& strDomain, unsigned char reason) override;
8686
void Events_OnAjaxRequest(CAjaxResourceHandlerInterface* pHandler, const SString& strURL) override;
87+
void Events_OnConsoleMessage(const std::string& message, const std::string& source, int line, std::int16_t level) override;
8788

8889
private:
8990
CWebViewInterface* m_pWebView;

Client/sdk/core/CWebBrowserEventsInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ class CWebBrowserEventsInterface
2828
virtual bool Events_OnResourceFileCheck(const SString& strURL, CBuffer& outFileData) = 0;
2929
virtual void Events_OnResourceBlocked(const SString& strURL, const SString& strDomain, unsigned char reason) = 0;
3030
virtual void Events_OnAjaxRequest(CAjaxResourceHandlerInterface* pHandler, const SString& strURL) = 0;
31+
virtual void Events_OnConsoleMessage(const std::string& message, const std::string& source, int line, std::int16_t level) = 0;
3132
};

0 commit comments

Comments
 (0)