*Converted QuestWinLose.awardBooster() from raw ListChooser access to GuiChoose methods. (Fixes end of Quest games crash)

This commit is contained in:
Hellfish
2013-04-06 07:21:06 +00:00
parent 5ef8762b00
commit 2c438afdb4
2 changed files with 14 additions and 7 deletions

View File

@@ -88,15 +88,19 @@ public class GuiChoose {
}
public static <T> List<T> noneOrMany(final String message, final Collection<T> choices) {
return GuiChoose.getChoices(message, 0, choices.size(), choices);
return GuiChoose.getChoices(message, 0, choices.size(), choices, null);
}
// returned Object will never be null
public static <T> List<T> getChoices(final String message, final int min, final int max, final T[] choices) {
return getChoices(message, min, max, Arrays.asList(choices));
return getChoices(message, min, max, Arrays.asList(choices), null);
}
public static <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices) {
return getChoices(message, min, max, choices, null);
}
public static <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices) {
public static <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices,final T selected) {
if (null == choices || choices.isEmpty()) {
if (0 == min) {
return new ArrayList<T>();
@@ -124,7 +128,12 @@ public class GuiChoose {
}
}
});
c.show();
if(selected != null)
c.show(selected);
else
c.show();
GuiUtils.clearPanelSelections();
return c.getSelectedValues();
}

View File

@@ -560,10 +560,8 @@ public class QuestWinLose extends ControlWinLose {
}
Collections.sort(formats);
final ListChooser<GameFormat> ch = new ListChooser<GameFormat>("Choose bonus booster format", 1, 1, formats);
ch.show(pref);
final GameFormat selected = ch.getSelectedValue();
final GameFormat selected = GuiChoose.getChoices("Choose bonus booster format", 1, 1, formats, pref).get(0); //ch.getSelectedValue();
Singletons.getModel().getQuestPreferences().setPref(QPref.BOOSTER_FORMAT, selected.toString());
cardsWon = qData.getCards().addCards(selected.getFilterPrinted());