-
Notifications
You must be signed in to change notification settings - Fork 855
GUI: Change deck selection to combobox #14131
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
base: master
Are you sure you want to change the base?
GUI: Change deck selection to combobox #14131
Conversation
Also remember a history of the last 5 used decks to make deck selection faster.
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.
Must be fine but require some improves:
- Make shared code and add same for new tourney and join dialogs;
- Test use cases with new app install without recent files (you can remove some settings by regedit, see here);
- Increase popup rows count from 5 to 10 and show it all in combobox (if it has scrollbar then find and change property like setMaximumRowCount);
- Make sure GUI works fine with very long paths (it's allow to see and select without errors, freeze or GUI blocking);
- Add screenshots to the started topic with new GUI elements;
| try { | ||
| String selection = cbPlayerDeck.getSelectedItem().toString(); | ||
| MagePreferences.putRecentDeckFile(selection); | ||
| } catch (NullPointerException ex) { /* Ignore */ } |
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.
it's better to check cbPlayerDeck.getSelectedItem() for null instead catch error
also addActionListener will catch any events so make sure it's will raise 1 event instead multiple times each button/char edit, clicks or other user manipulations;
Use cases example:
- Autoload deck file name on open dialog (it's already in old code but maybe broken in last releases -- in normal use cases GUI must load last used deck and insert it to the player deck);
- Choose deck by file explorer;
- Enter copied deck name by ctrl+v;
- Same 1-3 features for tournament dialog;
- Same 1-3 features for table join dialog;
| fcSelectDeck.addChoosableFileFilter(new DeckFileFilter("dck", "XMage's deck files (*.dck)")); | ||
| this.txtPlayerDeck.setText(""); | ||
| this.txtPlayerName.setText(ClientDefaultSettings.computerName); | ||
| cbPlayerDeck.setEditable(true);; |
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 are .form files for some GUI dialogs (old netbean 8 ide, see wiki docs -- it used to auto-generate some java code). So it also must be changed too. If don't have it then it's not critical -- I'll modify it later after merge.
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 cannot get Netbeans 8 to run on my Linux machine; thank you!
Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java
Outdated
Show resolved
Hide resolved
Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java
Outdated
Show resolved
Hide resolved
Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java
Outdated
Show resolved
Hide resolved
Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java
Outdated
Show resolved
Hide resolved
Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java
Outdated
Show resolved
Hide resolved
|
dialog.cbCardRenderImageFallback.setSelectedItem(MageFrame.getPreferences().get(KEY_CARD_RENDERING_IMAGE_MODE, CardRenderMode.MTGO.toString())); |
Yes, it will be fine to use last recent file's dir instead old way directory |
- Support resizing the JoinTable dialog - Fix re-loading the list of recent decks - Add tooltips that show the full path - Add a context menu to clear the list of recent decks
|
I added screenshots of the feature. To make the combobox fully show the filenames I did the following:
Also a context menu to clear the list got added. |
|
I have not yet added the feature to the NewTournamentDialog as I am not sure where shared code should be added :( |
|
You can store shared code in new Mage.Client/src/main/java/mage/client/util/RecentFilesUtil.java or like that (work with recent lists, add, remove, load to combobox, etc — just use combobox param in all methods and work with it). |
Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java
Outdated
Show resolved
Hide resolved
Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java
Outdated
Show resolved
Hide resolved
|
I got something wrong… the NewTournamentTable does not really need anything but the last directory logic from the new recent decklist feature. So I am not 100% happy with having the new I've added just the “Clear list” item to the list and removed the right-click menu. I've tested it a lot and it works very nice! |
|
Another question: Why don't we just remove the form file(s)? Especially for simple panels/dialogs like this, there is no real need for them; those can just be built in code. |
|
Ok… I changed this (again):
What I would like to do:
|
It's good and must be final destination for all GUI dialogs (there are left only few dialogs like preferences and tables), but it's very hard. NetBean's form files uses xml and generate code with |
Sorry, I did not really understand: Form files should stay or get removed? |
b58a2fd to
0862be5
Compare
|
Forgot to mention the form removal PR: johannes-wolf#1 |
| } | ||
| }); | ||
|
|
||
| setLayout(new GridBagLayout()); |
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.
Please, replace GridBag layout by another one like BorderLayout. gridbag is the most hardest to setup and support layout in whole swing collection -- it's better do not use it at all.
See example with game panel:
https://github.com/magefree/mage/blob/4941e2f19334ae6d9880350b94ec0919c84d3456/Mage.Client/src/main/java/mage/client/game/GamePanel.java#L256C9-L272C73
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've changed to BorderLayout. But I don't share the opinion that GridBag is hard to setup/read. BorderLayout is very strange as it seems to be meant for very simple use-cases and therefore needs all this JPanel nesting that GridBag does not need.
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.
If you are ok with removing the form file, I will merge that PR into this one and also change the layout to BorderLayout. Let me know :) (The PR also improves layout, as space is used more efficiently.)
|
@johannes-wolf what's your current tools for code edition (normal code, GUI)? |
I've installed IntelliJ for Java but use Emacs for everything else. |




Idea: Have a list of recently used decks when joining/creating a table instead of having to select the file each time you want to change the deck.
Change the filename edit in the$n$ decks used. Selecting a deck file using the file dialog directly adds it to the list of recent decks; changing the selection moves the selected item to the front of the recent list.
NewPlayerPanelto aComboBoxthat remembers the lastThere are multiple ways of accessing preferences and it is not really clear to me, which one is the correct/modern one. @JayDi85
I have not touched the tournament dialog, but if this change gets accepted I would like to also
use the same mechanism there.
The deck editor could also use the path/directory of the recent deck as current path for
the file chooser. What do you think?
For a separate PR: A button to clear preferences (such as this one) in the preferences panel would
be a good addition, I guess.
Here are some screenshots:




