mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Load and save setting of deck generator.
This commit is contained in:
parent
4b15dafda3
commit
825277bad9
3 changed files with 24 additions and 3 deletions
|
|
@ -28,6 +28,7 @@ import mage.cards.repository.CardRepository;
|
|||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.gui.ColorsChooser;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -35,6 +36,7 @@ import mage.constants.ColoredManaSymbol;
|
|||
import mage.constants.Rarity;
|
||||
import mage.interfaces.rate.RateCallback;
|
||||
import mage.utils.DeckBuilder;
|
||||
import mage.view.TournamentTypeView;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -93,9 +95,13 @@ public class DeckGenerator {
|
|||
cbSets.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jPanel.add(text3);
|
||||
jPanel.add(cbSets);
|
||||
|
||||
p0.add(jPanel);
|
||||
|
||||
String prefSet = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_DECK_GENERATOR_SET, null);
|
||||
if (prefSet != null) {
|
||||
cbSets.setSelectedItem(prefSet);
|
||||
}
|
||||
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
JPanel jPanel2 = new JPanel();
|
||||
JLabel textDeckSize = new JLabel("Deck size:");
|
||||
|
|
@ -106,9 +112,13 @@ public class DeckGenerator {
|
|||
cbDeckSize.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jPanel2.add(textDeckSize);
|
||||
jPanel2.add(cbDeckSize);
|
||||
|
||||
p0.add(jPanel2);
|
||||
|
||||
String prefSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_DECK_GENERATOR_DECK_SIZE, "60");
|
||||
if (prefSet != null) {
|
||||
cbDeckSize.setSelectedItem(prefSize);
|
||||
}
|
||||
|
||||
final JButton btnGenerate = new JButton("Ok");
|
||||
btnGenerate.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
|
|
@ -135,6 +145,11 @@ public class DeckGenerator {
|
|||
dlg.dispose();
|
||||
|
||||
if (selectedColors != null) {
|
||||
// save values to prefs
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_DECK_GENERATOR_DECK_SIZE, cbDeckSize.getSelectedItem().toString());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_DECK_GENERATOR_SET, cbSets.getSelectedItem().toString());
|
||||
|
||||
// build deck
|
||||
buildDeck();
|
||||
try {
|
||||
File tmp = File.createTempFile("tempDeck" + UUID.randomUUID().toString(), ".dck");
|
||||
|
|
|
|||
|
|
@ -435,6 +435,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||
if (numbPlayers < tournamentType.getMinPlayers() || numbPlayers > tournamentType.getMaxPlayers()) {
|
||||
numbPlayers = tournamentType.getMinPlayers();
|
||||
createPlayers(numbPlayers - 1);
|
||||
}
|
||||
this.spnNumPlayers.setModel(new SpinnerNumberModel(numbPlayers, tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
|
||||
this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers());
|
||||
|
|
@ -446,6 +447,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
this.pnlPacks.setVisible(false);
|
||||
}
|
||||
this.pnlDraftOptions.setVisible(tournamentType.isDraft());
|
||||
|
||||
}
|
||||
|
||||
private void createPacks(int numPacks) {
|
||||
|
|
@ -617,7 +619,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, tOptions.getTournamentType());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS, Integer.toString(tOptions.getMatchOptions().getFreeMulligans()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS, Integer.toString(tOptions.getMatchOptions().getWinsNeeded()));
|
||||
if (tOptions.getTournamentType().equals("Sealed Elimination")) {
|
||||
if (tOptions.getTournamentType().equals("Sealed Elimination")) {
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED, tOptions.getLimitedOptions().getSetCodes().toString());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_SEALED, Integer.toString(tOptions.getPlayerTypes().size()));
|
||||
} else if (tOptions.getTournamentType().equals("Elimination Booster Draft")) {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public static final String KEY_NEW_TOURNAMENT_DRAFT_TIMING = "newTournamentDraftTiming";
|
||||
public static final String KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS = "newTournamentAllowSpectators";
|
||||
|
||||
// pref setting for deck generator
|
||||
public static final String KEY_NEW_DECK_GENERATOR_DECK_SIZE = "newDeckGeneratorDeckSize";
|
||||
public static final String KEY_NEW_DECK_GENERATOR_SET = "newDeckGeneratorSet";
|
||||
|
||||
// used to save and restore the settings for the cardArea (draft, sideboarding, deck builder)
|
||||
public static final String KEY_DRAFT_VIEW = "draftView";
|
||||
public static final String KEY_DRAFT_PILES_TOGGLE = "draftPilesToggle";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue