mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
* GUI: fixed random/richman tourney settings that allows to freeze the client (#8224);
This commit is contained in:
parent
0bcf0320d0
commit
00ebef654f
2 changed files with 23 additions and 20 deletions
|
@ -680,8 +680,13 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
// CHECKS
|
// CHECKS
|
||||||
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||||
if (tournamentType.isRandom() || tournamentType.isRichMan()) {
|
if (tournamentType.isRandom() || tournamentType.isRichMan()) {
|
||||||
if (tOptions.getLimitedOptions().getSetCodes().isEmpty()) {
|
if (tOptions.getLimitedOptions().getSetCodes().size() < tournamentType.getNumBoosters()) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Warning, you must select packs for the pool", "Warning", JOptionPane.WARNING_MESSAGE);
|
JOptionPane.showMessageDialog(
|
||||||
|
MageFrame.getDesktop(),
|
||||||
|
String.format("Warning, you must select %d packs for the pool", tournamentType.getNumBoosters()),
|
||||||
|
"Warning",
|
||||||
|
JOptionPane.WARNING_MESSAGE
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1013,7 +1018,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
private void createRandomPacks() {
|
private void createRandomPacks() {
|
||||||
if (pnlRandomPacks.getComponentCount() == 0) {
|
if (pnlRandomPacks.getComponentCount() == 0) {
|
||||||
if (randomPackSelector == null) {
|
if (randomPackSelector == null) {
|
||||||
randomPackSelector = new RandomPacksSelectorDialog(isRandom, isRichMan);
|
randomPackSelector = new RandomPacksSelectorDialog();
|
||||||
randomPackSelector.setLocationRelativeTo(this);
|
randomPackSelector.setLocationRelativeTo(this);
|
||||||
}
|
}
|
||||||
txtRandomPacks = new JTextArea();
|
txtRandomPacks = new JTextArea();
|
||||||
|
@ -1039,8 +1044,8 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showRandomPackSelectorDialog() {
|
private void showRandomPackSelectorDialog() {
|
||||||
randomPackSelector.setType(isRandom, isRichMan);
|
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||||
randomPackSelector.showDialog();
|
randomPackSelector.showDialog(isRandom, isRichMan, tournamentType.getNumBoosters());
|
||||||
this.txtRandomPacks.setText(String.join(";", randomPackSelector.getSelectedPacks()));
|
this.txtRandomPacks.setText(String.join(";", randomPackSelector.getSelectedPacks()));
|
||||||
this.pack();
|
this.pack();
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
|
|
|
@ -18,31 +18,31 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
||||||
* Creates new form RandomPacksSelectorDialog
|
* Creates new form RandomPacksSelectorDialog
|
||||||
*/
|
*/
|
||||||
private boolean boxesCreated;
|
private boolean boxesCreated;
|
||||||
private boolean isRandomDraft;
|
private int needSetsAmount;
|
||||||
private boolean isRichManDraft;
|
|
||||||
private String title = "";
|
|
||||||
public static final String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
public static final String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
||||||
|
|
||||||
public RandomPacksSelectorDialog(boolean isRandomDraft, boolean isRichManDraft) {
|
public RandomPacksSelectorDialog() {
|
||||||
initComponents();
|
initComponents();
|
||||||
setType(isRandomDraft, isRichManDraft);
|
|
||||||
this.pnlApply.setToolTipText(randomDraftDescription);
|
this.pnlApply.setToolTipText(randomDraftDescription);
|
||||||
this.pnlSelect.setToolTipText(randomDraftDescription);
|
this.pnlSelect.setToolTipText(randomDraftDescription);
|
||||||
boxesCreated = false;
|
boxesCreated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(boolean isRandomDraft, boolean isRichManDraft) {
|
private void setType(boolean isRandomDraft, boolean isRichManDraft, int needSetsAmount) {
|
||||||
this.isRandomDraft = isRandomDraft;
|
this.needSetsAmount = needSetsAmount;
|
||||||
this.isRichManDraft = isRichManDraft;
|
String title = "";
|
||||||
if (this.isRandomDraft) {
|
if (isRandomDraft) {
|
||||||
title = "Random Booster Draft Packs Selector";
|
title = "Random Booster Draft Packs Selector";
|
||||||
} else if (this.isRichManDraft) {
|
} else if (isRichManDraft) {
|
||||||
title = "Rich Man Booster Draft Packs Selector";
|
title = "Rich Man Booster Draft Packs Selector";
|
||||||
|
} else {
|
||||||
|
title = "Booster Draft Packs Selector";
|
||||||
}
|
}
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDialog() {
|
public void showDialog(boolean isRandomDraft, boolean isRichManDraft, int needSetsAmount) {
|
||||||
|
setType(isRandomDraft, isRichManDraft, needSetsAmount);
|
||||||
createCheckboxes();
|
createCheckboxes();
|
||||||
pnlPacks.setVisible(true);
|
pnlPacks.setVisible(true);
|
||||||
pnlPacks.revalidate();
|
pnlPacks.revalidate();
|
||||||
|
@ -204,10 +204,8 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
||||||
}//GEN-LAST:event_formWindowClosing
|
}//GEN-LAST:event_formWindowClosing
|
||||||
|
|
||||||
public void doApply() {
|
public void doApply() {
|
||||||
if (getSelectedPacks().size() < 2 && isRandomDraft) {
|
if (getSelectedPacks().size() < needSetsAmount) {
|
||||||
JOptionPane.showMessageDialog(this, "At least 2 sets must be selected", "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(this, String.format("At least %d sets must be selected", needSetsAmount), "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
} else if (getSelectedPacks().isEmpty() && isRichManDraft) {
|
|
||||||
JOptionPane.showMessageDialog(this, "At least 1 set must be selected", "Error", JOptionPane.ERROR_MESSAGE);
|
|
||||||
} else {
|
} else {
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue