mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Quest mode: Booster format choice saved in preferences.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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"), /** */
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user