mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Introduced 2 quest preferences for the multiplier and the number of wild
opponents
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package forge.screens.home.quest;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
@@ -7,6 +9,7 @@ import com.google.common.primitives.Ints;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.data.QuestPreferences;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.screens.home.quest.VSubmenuQuestPrefs.PrefInput;
|
||||
import forge.util.Localizer;
|
||||
|
||||
@@ -50,16 +53,29 @@ public enum CSubmenuQuestPrefs implements ICDoc {
|
||||
public static void validateAndSave(final PrefInput i0) {
|
||||
if (i0.getText().equals(i0.getPreviousText())) { return; }
|
||||
final QuestPreferences prefs = FModel.getQuestPreferences();
|
||||
|
||||
final Integer val = Ints.tryParse(i0.getText());
|
||||
resetErrors();
|
||||
|
||||
String validationError = null;
|
||||
final Localizer localizer = Localizer.getInstance();
|
||||
final String validationError = val == null ? localizer.getMessage("lblEnteraNumber") : prefs.validatePreference(i0.getQPref(), val.intValue());
|
||||
resetErrors();
|
||||
|
||||
if(QPref.UNLOCK_DISTANCE_MULTIPLIER.equals(i0.getQPref())
|
||||
|| QPref.WILD_OPPONENTS_MULTIPLIER.equals(i0.getQPref())) {
|
||||
Double val = null;
|
||||
try {
|
||||
val = new Double(i0.getText());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
validationError = val == null ? localizer.getMessage("lblEnteraDecimal") : null;
|
||||
} else {
|
||||
final Integer val = Ints.tryParse(i0.getText());
|
||||
validationError = val == null ? localizer.getMessage("lblEnteraNumber") : prefs.validatePreference(i0.getQPref(), val.intValue());
|
||||
}
|
||||
|
||||
if (validationError != null) {
|
||||
showError(i0, validationError);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
prefs.setPref(i0.getQPref(), i0.getText());
|
||||
prefs.save();
|
||||
i0.setPreviousText(i0.getText());
|
||||
|
||||
@@ -292,6 +292,10 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
|
||||
pnlDifficulty.add(new PrefInput(QPref.PENALTY_LOSS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
||||
pnlDifficulty.add(new FLabel.Builder().text(localizer.getMessage("lblMoreDuelChoices")).fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
|
||||
pnlDifficulty.add(new PrefInput(QPref.MORE_DUEL_CHOICES, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
||||
pnlDifficulty.add(new FLabel.Builder().text(localizer.getMessage("lblWildOpponentMultiplier")).fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
|
||||
pnlDifficulty.add(new PrefInput(QPref.WILD_OPPONENTS_MULTIPLIER, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
||||
pnlDifficulty.add(new FLabel.Builder().text(localizer.getMessage("lblWildOpponentNumber")).fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
|
||||
pnlDifficulty.add(new PrefInput(QPref.WILD_OPPONENTS_NUMBER, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
||||
}
|
||||
private void populateBooster() {
|
||||
pnlBooster.setOpaque(false);
|
||||
|
||||
Reference in New Issue
Block a user