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

Selection menu enhancement - Added abstract SelectionMenu and ScrollSelection #76

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

JohnnyJayJay
Copy link
Contributor

@JohnnyJayJay JohnnyJayJay commented Oct 11, 2018

Pull Request

Pull Request Checklist

Please follow the following steps before opening this PR.

PRs that do not complete the checklist will be subject to denial for
missing information.

Pull Request Information

Check and fill in the blanks for all that apply:

  • My PR fixes a bug, error, or other issue with the library's codebase.
  • My PR is for the menu module of the JDA-Utilities library.
  • My PR creates a new module for the JDA-Utilities library: ______.

Description

This PR re-structures the SelectionDialog.
There is a new abstract class called SelectionMenu that allows easier implementations for menus with selections. The code for SelectionMenu is mainly taken from the former SelectionDialog, as every SelectionMenu basically works like it.

When making new extensions of SelectionMenu, the only difference should be the Builder and the render(int) method, which is declared abstract in SelectionMenu. It is also possible to overwrite the new method getNewSelection(Message, String, int) for other possible reactions. Configuring the reactions is not up to the user yet, however you have to pass a List of Strings (the unicode emojis) to the SelectionMenu constructor to set the reactions that are available. Currently, this is done internally.

In this PR, a new SelectionMenu is already included: the ScrollSelection.
The ScrollSelection is similar to SelectionDialog, but it only shows the currently selected entry. Also, the content of the embed description is configurable with a format String.

I also added a new method for all SelectionMenu Builders, setChoices(List<String>).

The contents of Kantenkugel's recent PR are also included and function correctly.

All of this is fully mergeable with the current master branch. Existing code will still work, too.
, with one exception: The public static final Strings in SelectionDialog are gone, they are now in SelectionMenu. They can still be added again and immediately deprecated to avoid any inconvenience.
Update: Added them again for convenience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants