Introduced a preference to turn the panel on/off.

This commit is contained in:
Alessandro Coli
2020-09-19 13:39:22 +02:00
parent 4975c6a0c3
commit 8d24a2a6ff
6 changed files with 64 additions and 33 deletions

View File

@@ -246,6 +246,7 @@ public enum CSubmenuPreferences implements ICDoc {
initializeMulliganRuleComboBox();
initializeAiProfilesComboBox();
initializeStackAdditionsComboBox();
initializeLandPlayedComboBox();
initializeColorIdentityCombobox();
initializeAutoYieldModeComboBox();
initializeCounterDisplayTypeComboBox();
@@ -448,6 +449,16 @@ public enum CSubmenuPreferences implements ICDoc {
panel.setComboBox(comboBox, selectedItem);
}
private void initializeLandPlayedComboBox() {
final String[] elems = {ForgeConstants.LAND_PLAYED_NOTIFICATION_NEVER, ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS,
ForgeConstants.LAND_PLAYED_NOTIFICATION_AI};
final FPref userSetting = FPref.UI_LAND_PLAYED_NOTIFICATION_POLICY;
final FComboBoxPanel<String> panel = this.view.getCbpLandPlayedComboBoxPanel();
final FComboBox<String> comboBox = createComboBox(elems, userSetting);
final String selectedItem = this.prefs.getPref(userSetting);
panel.setComboBox(comboBox, selectedItem);
}
private void initializeColorIdentityCombobox() {
final String[] elems = {ForgeConstants.DISP_CURRENT_COLORS_NEVER, ForgeConstants.DISP_CURRENT_COLORS_CHANGED,
ForgeConstants.DISP_CURRENT_COLORS_MULTICOLOR, ForgeConstants.DISP_CURRENT_COLORS_MULTI_OR_CHANGED,

View File

@@ -120,6 +120,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final FComboBoxPanel<String> cbpMulliganRule = new FComboBoxPanel<>(localizer.getMessage("cbpMulliganRule")+":");
private final FComboBoxPanel<String> cbpAiProfiles = new FComboBoxPanel<>(localizer.getMessage("cbpAiProfiles")+":");
private final FComboBoxPanel<String> cbpStackAdditions = new FComboBoxPanel<>(localizer.getMessage("cbpStackAdditions")+":");
private final FComboBoxPanel<String> cbpLandPlayed = new FComboBoxPanel<>(localizer.getMessage("cbpLandPlayed")+":");
private final FComboBoxPanel<String> cbpDisplayCurrentCardColors = new FComboBoxPanel<>(localizer.getMessage("cbpDisplayCurrentCardColors")+":");
private final FComboBoxPanel<String> cbpAutoYieldMode = new FComboBoxPanel<>(localizer.getMessage("cbpAutoYieldMode")+":");
private final FComboBoxPanel<String> cbpCounterDisplayType = new FComboBoxPanel<>(localizer.getMessage("cbpCounterDisplayType")+":");
@@ -206,6 +207,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbpStackAdditions, comboBoxConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlpStackAdditions")), descriptionConstraints);
pnlPrefs.add(cbpLandPlayed, comboBoxConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlpLandPlayed")), descriptionConstraints);
pnlPrefs.add(cbEnforceDeckLegality, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlEnforceDeckLegality")), descriptionConstraints);
@@ -685,6 +689,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbpStackAdditions;
}
public FComboBoxPanel<String> getCbpLandPlayedComboBoxPanel() {
return cbpLandPlayed;
}
public FComboBoxPanel<GameLogEntryType> getGameLogVerbosityComboBoxPanel() {
return cbpGameLogEntryType;
}

View File

@@ -1450,38 +1450,42 @@ public final class CMatchUI
}
private void createLandPopupPanel(Card land, Zone zone) {
String title = "Forge";
List<String> options = ImmutableList.of(Localizer.getInstance().getMessage("lblOK"));
MigLayout migLayout = new MigLayout("insets 15, left, gap 30, fill");
JPanel mainPanel = new JPanel(migLayout);
final Dimension parentSize = JOptionPane.getRootFrame().getSize();
Dimension maxSize = new Dimension(1400, parentSize.height - 100);
mainPanel.setMaximumSize(maxSize);
mainPanel.setOpaque(false);
int rotation = getRotation(land.getView());
FImagePanel imagePanel = new FImagePanel();
BufferedImage bufferedImage = FImageUtil.getImage(land.getCurrentState().getView());
imagePanel.setImage(bufferedImage, rotation, AutoSizeImageMode.SOURCE);
int imageWidth = 433;
int imageHeight = 600;
Dimension imagePanelDimension = new Dimension(imageWidth,imageHeight);
imagePanel.setMinimumSize(imagePanelDimension);
mainPanel.add(imagePanel, "cell 0 0, spany 3");
String landPlayedNotificationPolicy = FModel.getPreferences().getPref(FPref.UI_LAND_PLAYED_NOTIFICATION_POLICY);
Player cardController = land.getController();
String msg = cardController.toString() + " puts " + land.toString() + " into play into " + zone.toString() + ".";
boolean isAi = cardController.isAI();
if(ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS.equals(landPlayedNotificationPolicy) || (ForgeConstants.LAND_PLAYED_NOTIFICATION_AI.equals(landPlayedNotificationPolicy) && (isAi))) {
String title = "Forge";
List<String> options = ImmutableList.of(Localizer.getInstance().getMessage("lblOK"));
final FTextArea prompt1 = new FTextArea(msg);
prompt1.setFont(FSkin.getFont(21));
prompt1.setAutoSize(true);
prompt1.setMinimumSize(new Dimension(475,200));
mainPanel.add(prompt1, "cell 1 0, aligny top");
MigLayout migLayout = new MigLayout("insets 15, left, gap 30, fill");
JPanel mainPanel = new JPanel(migLayout);
final Dimension parentSize = JOptionPane.getRootFrame().getSize();
Dimension maxSize = new Dimension(1400, parentSize.height - 100);
mainPanel.setMaximumSize(maxSize);
mainPanel.setOpaque(false);
int rotation = getRotation(land.getView());
FOptionPane.showOptionDialog(null, title, null, mainPanel, options);
FImagePanel imagePanel = new FImagePanel();
BufferedImage bufferedImage = FImageUtil.getImage(land.getCurrentState().getView());
imagePanel.setImage(bufferedImage, rotation, AutoSizeImageMode.SOURCE);
int imageWidth = 433;
int imageHeight = 600;
Dimension imagePanelDimension = new Dimension(imageWidth,imageHeight);
imagePanel.setMinimumSize(imagePanelDimension);
mainPanel.add(imagePanel, "cell 0 0, spany 3");
String msg = cardController.toString() + " puts " + land.toString() + " into play into " + zone.toString() + ".";
final FTextArea prompt1 = new FTextArea(msg);
prompt1.setFont(FSkin.getFont(21));
prompt1.setAutoSize(true);
prompt1.setMinimumSize(new Dimension(475,200));
mainPanel.add(prompt1, "cell 1 0, aligny top");
FOptionPane.showOptionDialog(null, title, null, mainPanel, options);
}
}
}

View File

@@ -2584,3 +2584,5 @@ lblEnterMessageToSend=Enter message to send
lblDetectedInvalidHostAddress=Invalid host address ({0}) was detected.
#Player.java
lblChooseACompanion=Choose a companion
cbpLandPlayed=Land entering battlefield notifications
nlpLandPlayed=Choose when you want to get visual notifications for a land entering the battlefield: Never, always, or only for the lands entering a battlefield because of an action of a AI player

View File

@@ -322,6 +322,11 @@ public final class ForgeConstants {
public static final String STACK_EFFECT_NOTIFICATION_ALWAYS = "Always";
public static final String STACK_EFFECT_NOTIFICATION_AI_AND_TRIGGERED = "AI cast/activated, or triggered by any player";
// Constants for LAnd played notification policy
public static final String LAND_PLAYED_NOTIFICATION_NEVER = "Never";
public static final String LAND_PLAYED_NOTIFICATION_ALWAYS = "Always";
public static final String LAND_PLAYED_NOTIFICATION_AI = "Lands entering a battlefield because of an action of a AI player";
// Set boolean constant for landscape mode for gdx port
public static final boolean isGdxPortLandscape = FileUtil.doesFileExist(ASSETS_DIR + "switch_orientation.ini");

View File

@@ -121,6 +121,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
UI_CLOSE_ACTION ("NONE"),
UI_MANA_LOST_PROMPT ("false"), // Prompt on losing mana when passing priority
UI_STACK_EFFECT_NOTIFICATION_POLICY ("Never"),
UI_LAND_PLAYED_NOTIFICATION_POLICY ("Never"),
UI_PAUSE_WHILE_MINIMIZED("false"),
UI_TOKENS_IN_SEPARATE_ROW("false"), // Display tokens in their own battlefield row.
UI_DISPLAY_CURRENT_COLORS(ForgeConstants.DISP_CURRENT_COLORS_NEVER),