Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onClientBrowserConsoleMessage event #3676

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", NULL, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr instead of NULL

Copy link
Contributor Author

@gownosatana gownosatana Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey tracerds, can I ask you to stop making random comments on random pull requests? here it would be absolutely radicoolous to change null to nullptr when ALL of events use null. this is public repo and not your private project where you change anything because you prefer nullptr over null. thanks 🙏👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey tracerds, can I ask you to stop making random comments on random pull requests? here it would be absolutely radicoolous to change null to nullptr when ALL of events use null. this is public repo and not your private project where you change anything because you prefer nullptr over null. thanks 🙏👍

That the older code in this file makes use of NULL is irrelevant. You are introducing new code and should therefore use the proper modern methods. In this case nullptr over NULL. It's a valid comment from Tracer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You come here edit code thats been created by the community.
Its not my preference. There are standards. Read them BEFORE creating a PR.
If you dont like the way it is, dont contribute.
If you want to contribute, follow the guidelines.
Dont resolve conversations when you dont change anything.
Just because in your opinion you can do whatever you want doesnt give you the right to do so. Either follow the guidelines or dont contribute

Copy link
Contributor

@FileEX FileEX Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change NULL to nullptr for onClientBrowserConsoleMessage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't change anything, it's like this everywhere, you can open pull request to refactor mta code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't change anything, it's like this everywhere, you can open pull request to refactor mta code

It changes everything. Why should someone open a pull request just to clean after you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't change anything, it's like this everywhere, you can open pull request to refactor mta code

In accordance with the guidelines and current C++ conventions, you should use nullptr instead of NULL, as everyone else does in this repository. No one is going to clean up after you because you're too lazy to make the changes required by the coding standards. We follow the principle that when creating new code, we adhere to the latest guidelines and avoid creating more mess than there already is. If you don't follow the coding guidelines, your PR simply won't be considered, and no one will likely want to merge it. It's your choice whether to spend a minute making this change or risk having all the time you invested in this PR go to waste


// 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 SString& strMessage, const SString& strSource, int line, short level)
{
CLuaArguments Arguments;
Arguments.PushString(strMessage);
Arguments.PushString(strSource);
Arguments.PushNumber(line);
Arguments.PushNumber(level);
CallEvent("onClientBrowserConsoleMessage", Arguments, false);
Comment on lines +310 to +315
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above, everywhere is used like this, it's not problem that needs to be fixed to get merged, if you really want to change things like this just create refactor pull request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New PRs shouldn't introduce code that requires a refactor later to meet current standards. Could go even deeper, hungarian notation shouldn't be used anymore.

}

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 SString& strMessage, const SString& strSource, int line, short level);

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 SString& strMessage, const SString& strSource, int line, short level) = 0;
};