Quest mode: Booster format choice saved in preferences.

This commit is contained in:
Doublestrike
2012-02-04 04:17:50 +00:00
parent e9892be831
commit d269758d9c
3 changed files with 27 additions and 4 deletions

View File

@@ -331,12 +331,18 @@ public class ListChooser<T> {
return this.jList;
}
/** @return boolean */
public synchronized boolean show() {
return this.show(0);
}
/**
* Shows the dialog and returns after the dialog was closed.
*
* @param index0 index to select when shown
* @return a boolean.
*/
public synchronized boolean show() {
public synchronized boolean show(int index0) {
if (this.called) {
throw new IllegalStateException("Already shown");
}
@@ -346,7 +352,9 @@ public class ListChooser<T> {
if (this.minChoices != 0) {
this.d.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
this.jList.setSelectedIndex(0);
this.jList.setSelectedIndex(index0);
this.d.addWindowFocusListener(new WindowFocusListener() {
@Override
public void windowGainedFocus(final WindowEvent e) {

View File

@@ -27,6 +27,7 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import forge.SetUtils;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.Quest;
@@ -52,6 +53,7 @@ public class QuestPreferences implements Serializable {
BOOSTER_COMMONS ("11"), /** */
BOOSTER_UNCOMMONS ("3"), /** */
BOOSTER_RARES ("1"), /** */
BOOSTER_FORMAT ("Standard"), /** */
PENALTY_LOSS ("15"), /** */
CURRENT_QUEST ("DEFAULT"), /** */

View File

@@ -531,10 +531,23 @@ public class QuestWinLoseHandler extends ControlWinLose {
*
*/
private void awardBooster() {
final List<GameFormat> formats = SetUtils.getFormats();
final ListChooser<GameFormat> ch = new ListChooser<GameFormat>("Choose bonus booster format", 1,
SetUtils.getFormats());
ch.show();
formats);
int index = 0;
for (int i = 0; i < formats.size(); i++) {
if (formats.get(i).toString().equals(this.model.qPrefs.getPreference(QPref.BOOSTER_FORMAT))) {
index = i;
break;
}
}
ch.show(index);
final GameFormat selected = ch.getSelectedValue();
this.model.qPrefs.setPreference(QPref.BOOSTER_FORMAT, selected.toString());
this.model.qPrefs.save();
final List<CardPrinted> cardsWon = this.model.qData.getCards().addCards(selected.getFilterPrinted());