-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Extend menu handler & item callbacks (bug 6002) #371
base: master
Are you sure you want to change the base?
Conversation
I would also mark menu_item_getinfo as deprecated so people become aware of this feature. |
I thought about the same but if we did that there won't be any way to get item's info outside of menu handler/item callback. |
I don't know if it is possible, but I would add a warning message to the deprecated tag saying : "Usage of menu_item_getinfo is deprecated inside menu handlers and menu callbacks, ignore this if you're not using it in that way". I don't know what would be worse, if having to ignore a warning every time the function is used outside a handler/callback (few cases for doing so), or having people use outdated code from other plugins or old guides because they're not aware of the changes. |
I definitely say no to the deprecation. It is neither a broken nor an obsolete native, and the deprecation warning would be awkward in addition to being technically wrong. As a general comment I do think that this PR makes the callback prototype a bit too crazy, for not too much benefit. I'd probably choose pass at most the info string if I felt like changing this at all, and I think it even would be fine to stay as-is. Should we decide put all that stuff in there the info string should probably come first so that the other parameters (which are rarely used in my experience) can be omitted. |
I agree it's a little bit messy but the point of this PR is to not need call |
I doubt menu_item_getinfo gets any use outside the menu handlers, and there would be no point using it if the function definition gets updated to include the new parameters. How does this not leave menu_item_getinfo obsolete ? Also I would not like the parameter order to be different across the function definition and menu_item_getinfo, you can always do the _ _ dance to only get the parameters that you need. |
After some thinking I come with other idea that will simplify the callback a bit and give us ability to pass different types of data as item info not just string. Since AMXX introduced datapacks, so we can take advantage of them. I've already done some work on it. New natives:
Callback prototype: Deprecations: |
In You shouldn't have removed/added whitespaces to newmenus.inc to stylize code nor fixed typos and left it for another PR as it bloats the diff making it harder to review changes. Let it slide now anyway, but keep that in mind.
I do fail to find any use case for |
amxmodx/newmenus.cpp
Outdated
|
||
menuitem *pItem = pMenu->AddItem(name, cmd, access); | ||
menuitem *pItem = pMenu->AddItem(name, cmd, params[4], params[5]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an unnecessary unused value left over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I must have missed that.
ccd4e45
to
86ca75f
Compare
Summary
Both of them have special parameter named |
It's definitively much better and saner than what you proposed initially. 👍 (did not review yet) I'm not sure to like the |
Looks like you need to rebase. |
Done |
What do you think about merging this into master? |
Merge master into menu_handler
Ok, now we can move one with this. |
lol 3 years later, what happen with this pr ? |
still nothing :( |
This feature was requested by connorr here.
We can directly get item info like access, info etc. without calling
menu_item_getinfo
.