From 8ceda2b07b714d1e28751c4bf0541abe3c7df542 Mon Sep 17 00:00:00 2001 From: drdev Date: Sat, 28 Dec 2013 20:57:34 +0000 Subject: [PATCH] Use skinned dialog for new quest dialogs --- .../controllers/CEditorQuestCardShop.java | 6 +- .../home/gauntlet/CSubmenuGauntletBuild.java | 20 ++---- .../home/gauntlet/QuickGauntletLister.java | 13 +--- .../gui/home/quest/CSubmenuQuestData.java | 71 ++++++++++--------- .../java/forge/gui/toolbox/FOptionPane.java | 13 +++- 5 files changed, 59 insertions(+), 64 deletions(-) diff --git a/forge-gui/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java b/forge-gui/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java index a2cbe5e96d4..0a9b75f403b 100644 --- a/forge-gui/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java +++ b/forge-gui/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java @@ -26,8 +26,6 @@ import java.util.Map; import java.util.Map.Entry; import javax.swing.JLabel; -import javax.swing.JOptionPane; - import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Function; @@ -348,11 +346,11 @@ public final class CEditorQuestCardShop extends ACEditorBase c : dckStartPool.getMain()) { sets.add(c.getKey().getEdition()); } - if (dckStartPool.has(DeckSection.Sideboard)) + if (dckStartPool.has(DeckSection.Sideboard)) { for (Entry c : dckStartPool.get(DeckSection.Sideboard)) { sets.add(c.getKey().getEdition()); } + } fmtPrizes = new GameFormat("From deck", sets, null); } - } else { + } + else { switch(prizedPoolType) { - case Complete: - fmtPrizes = null; - break; - case CustomFormat: - if (customPrizeFormatCodes.isEmpty()) { - - int answer = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), "You have defined custom format as containing no sets.\nThis will choose all editions without restriction as prized.\n\nContinue?"); - if (JOptionPane.YES_OPTION != answer) { - return; - } + case Complete: + fmtPrizes = null; + break; + case CustomFormat: + if (customPrizeFormatCodes.isEmpty()) { + if (!FOptionPane.showConfirmDialog("You have defined custom format as containing no sets.\nThis will choose all editions without restriction as prized.\n\nContinue?")) { + return; } - fmtPrizes = customPrizeFormatCodes.isEmpty() ? null : new GameFormat("Custom Prizes", customPrizeFormatCodes, null); // chosen sets and no banend cards - break; - case Rotating: - fmtPrizes = view.getPrizedRotatingFormat(); - break; - default: - throw new RuntimeException("Should not get this result"); + } + fmtPrizes = customPrizeFormatCodes.isEmpty() ? null : new GameFormat("Custom Prizes", customPrizeFormatCodes, null); // chosen sets and no banend cards + break; + case Rotating: + fmtPrizes = view.getPrizedRotatingFormat(); + break; + default: + throw new RuntimeException("Should not get this result"); } } // } else { @@ -250,14 +245,22 @@ public enum CSubmenuQuestData implements ICDoc { // } final StartingPoolPreferences userPrefs = new StartingPoolPreferences(view.randomizeColorDistribution(), view.getPreferredColor()); - final Object o = JOptionPane.showInputDialog(JOptionPane.getRootFrame(), "Poets will remember your quest as:", "Quest Name", JOptionPane.OK_CANCEL_OPTION); - if (o == null) { return; } + String questName; + while (true) { + questName = FOptionPane.showInputDialog("Poets will remember your quest as:", "Quest Name"); + if (questName == null) { return; } - final String questName = SSubmenuQuestUtil.cleanString(o.toString()); + questName = SSubmenuQuestUtil.cleanString(questName); - if (getAllQuests().get(questName) != null || questName.equals("")) { - FOptionPane.showMessageDialog("Please pick another quest name, a quest already has that name."); - return; + if (questName.isEmpty()) { + FOptionPane.showMessageDialog("Please specify a quest name."); + continue; + } + if (getAllQuests().get(questName + ".dat") != null) { + FOptionPane.showMessageDialog("A quest already exists with that name. Please pick another quest name."); + continue; + } + break; } QuestController qc = Singletons.getModel().getQuest(); diff --git a/forge-gui/src/main/java/forge/gui/toolbox/FOptionPane.java b/forge-gui/src/main/java/forge/gui/toolbox/FOptionPane.java index 5c2dd02ca8e..81374fac1c0 100644 --- a/forge-gui/src/main/java/forge/gui/toolbox/FOptionPane.java +++ b/forge-gui/src/main/java/forge/gui/toolbox/FOptionPane.java @@ -37,6 +37,10 @@ public class FOptionPane extends FDialog { showOptionDialog(message, title, icon, new String[] {"OK"}, 0); } + public static boolean showConfirmDialog(String message) { + return showConfirmDialog(message, "Forge"); + } + public static boolean showConfirmDialog(String message, String title) { return showConfirmDialog(message, title, "Yes", "No", true); } @@ -55,8 +59,7 @@ public class FOptionPane extends FDialog { return (reply == 0); } - public static int showOptionDialog(String message, String title, SkinImage icon, String[] options, int defaultOption) { - + public static int showOptionDialog(String message, String title, SkinImage icon, String[] options, int defaultOption) { final FOptionPane optionPane = new FOptionPane(message, title, icon, null, options, defaultOption); optionPane.setVisible(true); int dialogResult = optionPane.result; @@ -64,6 +67,10 @@ public class FOptionPane extends FDialog { return dialogResult; } + public static String showInputDialog(String message, String title) { + return showInputDialog(message, title, null, "", null); + } + public static String showInputDialog(String message, String title, SkinImage icon) { return showInputDialog(message, title, icon, "", null); } @@ -144,7 +151,7 @@ public class FOptionPane extends FDialog { prompt.setAutoSize(true); Dimension parentSize = JOptionPane.getRootFrame().getSize(); prompt.setMaximumSize(new Dimension(parentSize.width / 2, parentSize.height - 100)); - this.add(prompt, "x " + x + ", ay top, wrap, gaptop 7, gapbottom " + gapBottom); + this.add(prompt, "x " + x + ", ay top, wrap, gaptop " + (icon == null ? 0 : 7) + ", gapbottom " + gapBottom); x = padding; } if (comp != null) {