UI for choosing the Mulligan type

This commit is contained in:
Michael Kamensky
2019-06-11 04:02:16 +00:00
parent dad052fa07
commit 08e2ba54ea
11 changed files with 126 additions and 18 deletions

View File

@@ -1,8 +1,6 @@
package forge.screens.home.settings;
import forge.GuiBase;
import forge.Singletons;
import forge.UiCommand;
import forge.*;
import forge.ai.AiProfileUtil;
import forge.control.FControl.CloseAction;
import forge.game.GameLogEntryType;
@@ -227,6 +225,7 @@ public enum CSubmenuPreferences implements ICDoc {
initializeGameLogVerbosityComboBox();
initializeCloseActionComboBox();
initializeDefaultFontSizeComboBox();
initializeMulliganRuleComboBox();
initializeAiProfilesComboBox();
initializeColorIdentityCombobox();
initializeAutoYieldModeComboBox();
@@ -355,8 +354,7 @@ public enum CSubmenuPreferences implements ICDoc {
panel.setComboBox(comboBox, Singletons.getControl().getCloseAction());
}
private void initializeDefaultLanguageComboBox() {
private void initializeDefaultLanguageComboBox() {
final String [] choices = {"en-US", "es-ES", "de-DE"};
final FPref userSetting = FPref.UI_LANGUAGE;
final FComboBoxPanel<String> panel = this.view.getCbpDefaultLanguageComboBoxPanel();
@@ -364,6 +362,21 @@ public enum CSubmenuPreferences implements ICDoc {
final String selectedItem = this.prefs.getPref(userSetting);
panel.setComboBox(comboBox, selectedItem);
}
private void initializeMulliganRuleComboBox() {
final String [] choices = MulliganDefs.getMulliganRuleNames();
final FPref userSetting = FPref.MULLIGAN_RULE;
final FComboBoxPanel<String> panel = this.view.getCbpMulliganRule();
final FComboBox<String> comboBox = createComboBox(choices, userSetting);
final String selectedItem = this.prefs.getPref(userSetting);
comboBox.addItemListener(new ItemListener() {
@Override public void itemStateChanged(final ItemEvent e) {
StaticData.instance().setMulliganRule(MulliganDefs.GetRuleByName(prefs.getPref(FPref.MULLIGAN_RULE)));
}
});
panel.setComboBox(comboBox, selectedItem);
}
private void initializeDefaultFontSizeComboBox() {
final String [] choices = {"10", "11", "12", "13", "14", "15", "16", "17", "18"};
final FPref userSetting = FPref.UI_DEFAULT_FONT_SIZE;

View File

@@ -114,6 +114,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final FComboBoxPanel<GameLogEntryType> cbpGameLogEntryType = new FComboBoxPanel<>(localizer.getMessage("cbpGameLogEntryType")+":");
private final FComboBoxPanel<CloseAction> cbpCloseAction = new FComboBoxPanel<>(localizer.getMessage("cbpCloseAction")+":");
private final FComboBoxPanel<String> cbpDefaultFontSize = new FComboBoxPanel<>(localizer.getMessage("cbpDefaultFontSize")+":");
private final FComboBoxPanel<String> cbpMulliganRule = new FComboBoxPanel<>(localizer.getMessage("cbpMulliganRule")+":");
private final FComboBoxPanel<String> cbpAiProfiles = new FComboBoxPanel<>(localizer.getMessage("cbpAiProfiles")+":");
private final FComboBoxPanel<String> cbpDisplayCurrentCardColors = new FComboBoxPanel<>(localizer.getMessage("cbpDisplayCurrentCardColors")+":");
private final FComboBoxPanel<String> cbpAutoYieldMode = new FComboBoxPanel<>(localizer.getMessage("cbpAutoYieldMode")+":");
@@ -172,6 +173,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
// Gameplay Options
pnlPrefs.add(new SectionLabel(localizer.getMessage("GamePlay")), sectionConstraints);
pnlPrefs.add(cbpMulliganRule, comboBoxConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlpMulliganRule")), descriptionConstraints);
pnlPrefs.add(cbpAiProfiles, comboBoxConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlpAiProfiles")), descriptionConstraints);
@@ -637,6 +641,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbWorkshopSyntax;
}
public FComboBoxPanel<String> getCbpMulliganRule() {
return cbpMulliganRule;
}
public FComboBoxPanel<String> getAiProfilesComboBoxPanel() {
return cbpAiProfiles;
}