Skip to content

Commit

Permalink
Add onClientBrowserConsoleMessage event - #3676 follow up (#3773)
Browse files Browse the repository at this point in the history
  • Loading branch information
TracerDS authored Dec 21, 2024
1 parent c0376c9 commit d296a65
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2784,6 +2784,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);
Expand Down
10 changes: 10 additions & 0 deletions Client/mods/deathmatch/logic/CClientWebBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientWebBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Client/sdk/core/CWebBrowserEventsInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit d296a65

Please sign in to comment.