-
Notifications
You must be signed in to change notification settings - Fork 31
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
Adds menus tutorial to wiki #447
base: master
Are you sure you want to change the base?
Conversation
- Have simple, paged and list menu tutorial on how to make the menu.
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.
Thanks for the PR! Here are some points I've noticed while hovering the changes.
That said, I'm not sure how I feel about the examples themselves. Menus should be globalized and re-used, and these examples currently build them on-the-fly which encourages bad practices in my opinion. Perhaps we could leverage the examples that were provided on the forums which also happens to demonstrate more concepts and features:
addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst
Outdated
Show resolved
Hide resolved
addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst
Outdated
Show resolved
Hide resolved
addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst
Outdated
Show resolved
Hide resolved
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.
I have now updated the wiki tutorial based of your comments.
Thank you! Here are some minor points.
Should in wiki menu tutorial include using WeaponClassIter for making buymenu?
As example looping the weapons showing for their name and their price and it would check player can afford to buy it
I don't think wiki tutorials should showcase more than minimal examples. Both for simplicity and straightforwardness so that they don't bifurcate too much into off-topic modules or become too much games specific. Is there anything pertaining to menus such example would demonstrate that is not already by the current ones?
In any case, this sounds like a good idea for the Code examples / Cookbook section, though.
@@ -0,0 +1,117 @@ | |||
Menus |
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.
menu = PagedMenu(title='Welcome menu', description='Choose an option:', select_callback=my_select_callback) | ||
|
||
# Add options from 1 to 20 | ||
for i in range(1, 20): | ||
menu.append(PagedOption(f'{i}', i)) |
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.
This should be declared after my_select_callback
because it currently won't load and produce a NameError
. Moreover, the first line is too long and does not conform with PEP 8, which we try to follow and promote for this project.
# Add in menu options | ||
menu.append(SimpleOption(1, 'Yes', 'yes')) | ||
menu.append(SimpleOption(2, 'No', 'no')) | ||
menu.select_callback=my_menu_select_callback |
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.
Same as above; this should be declared after my_menu_select_callback
. And it should also have spaces surrounding the operator:
variable = value
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.
I have now more updated the wiki based of your comments.
I also added when selects close button, it registers it instead closing the menu
Adds at wiki a tutorial how to make menu.
Paged, Simple and List menu