Use skinned dialog for new quest dialogs

This commit is contained in:
drdev
2013-12-28 20:57:34 +00:00
parent a592a44647
commit 8ceda2b07b
5 changed files with 59 additions and 64 deletions

View File

@@ -26,8 +26,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Function; import com.google.common.base.Function;
@@ -348,11 +346,11 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
} }
boolean one = (qty == 1); boolean one = (qty == 1);
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), String.format( FOptionPane.showMessageDialog(String.format(
"%s '%s' %s added to your decklist.%n%n%s cards were also added to your pool.", "%s '%s' %s added to your decklist.%n%n%s cards were also added to your pool.",
one ? "Deck" : String.format("%d copies of deck", qty), one ? "Deck" : String.format("%d copies of deck", qty),
deck.getName(), one ? "was" : "were", one ? "Its" : "Their"), deck.getName(), one ? "was" : "were", one ? "Its" : "Their"),
"Thanks for purchasing!", JOptionPane.INFORMATION_MESSAGE); "Thanks for purchasing!", FOptionPane.INFORMATION_ICON);
} }
else { else {
continue; //don't remove item from Catalog if any other type continue; //don't remove item from Catalog if any other type

View File

@@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
@@ -17,6 +16,7 @@ import forge.deck.Deck;
import forge.gauntlet.GauntletData; import forge.gauntlet.GauntletData;
import forge.gauntlet.GauntletIO; import forge.gauntlet.GauntletIO;
import forge.gui.framework.ICDoc; import forge.gui.framework.ICDoc;
import forge.gui.toolbox.FOptionPane;
import forge.properties.NewConstants; import forge.properties.NewConstants;
/** /**
@@ -175,35 +175,29 @@ public enum CSubmenuGauntletBuild implements ICDoc {
// Warn if no name // Warn if no name
if (name.equals(GauntletIO.TXF_PROMPT) || name.isEmpty()) { if (name.equals(GauntletIO.TXF_PROMPT) || name.isEmpty()) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), FOptionPane.showMessageDialog(
"Please name your gauntlet using the 'Gauntlet Name' box.", "Please name your gauntlet using the 'Gauntlet Name' box.",
"Save Error!", "Save Error!",
JOptionPane.ERROR_MESSAGE); FOptionPane.ERROR_ICON);
return false; return false;
} }
final File f = new File(NewConstants.GAUNTLET_DIR.userPrefLoc + name + ".dat"); final File f = new File(NewConstants.GAUNTLET_DIR.userPrefLoc + name + ".dat");
// Confirm if overwrite // Confirm if overwrite
if (f.exists()) { if (f.exists()) {
final int m = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), if (!FOptionPane.showConfirmDialog(
"There is already a gauntlet named '" + name + "'.\n" "There is already a gauntlet named '" + name + "'.\n"
+ "All progress and data will be overwritten. Continue?", + "All progress and data will be overwritten. Continue?",
"Overwrite Gauntlet?", "Overwrite Gauntlet?")) { return false; }
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (m == JOptionPane.NO_OPTION) { return false; }
gd = GauntletIO.loadGauntlet(f); gd = GauntletIO.loadGauntlet(f);
} }
// Confirm if a new gauntlet will be created // Confirm if a new gauntlet will be created
else { else {
final int m = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), if (!FOptionPane.showConfirmDialog(
"This will create a new gauntlet named '" + name + "'. Continue?", "This will create a new gauntlet named '" + name + "'. Continue?",
"Create Gauntlet?", "Create Gauntlet?")) { return false; }
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (m == JOptionPane.NO_OPTION) { return false; }
gd = new GauntletData(); gd = new GauntletData();
} }

View File

@@ -1,7 +1,5 @@
package forge.gui.home.gauntlet; package forge.gui.home.gauntlet;
import java.awt.Color; import java.awt.Color;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@@ -12,7 +10,6 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
@@ -21,6 +18,7 @@ import forge.Command;
import forge.gauntlet.GauntletData; import forge.gauntlet.GauntletData;
import forge.gauntlet.GauntletIO; import forge.gauntlet.GauntletIO;
import forge.gui.toolbox.FLabel; import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FSkin; import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.FSkin.SkinIcon; import forge.gui.toolbox.FSkin.SkinIcon;
@@ -264,14 +262,9 @@ public class QuickGauntletLister extends JPanel {
private void deleteFile(RowPanel r0) { private void deleteFile(RowPanel r0) {
final GauntletData gd = r0.getGauntletData(); final GauntletData gd = r0.getGauntletData();
final int n = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), if (!FOptionPane.showConfirmDialog(
"Are you sure you want to delete \"" + gd.getName() "Are you sure you want to delete \"" + gd.getName()
+ "\" ?", "Delete Gauntlet", JOptionPane.YES_NO_OPTION); + "\" ?", "Delete Gauntlet")) { return; }
if (n == JOptionPane.NO_OPTION) {
return;
}
GauntletIO.getGauntletFile(gd).delete(); GauntletIO.getGauntletFile(gd).delete();
if (cmdRowDelete != null) { cmdRowDelete.run(); } if (cmdRowDelete != null) { cmdRowDelete.run(); }

View File

@@ -10,7 +10,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import forge.Command; import forge.Command;
@@ -163,16 +162,14 @@ public enum CSubmenuQuestData implements ICDoc {
GameFormat worldFormat = (startWorld == null ? null : startWorld.getFormat()); GameFormat worldFormat = (startWorld == null ? null : startWorld.getFormat());
if (worldFormat == null) { if (worldFormat == null) {
switch(view.getStartingPoolType()) { switch(view.getStartingPoolType()) {
case Rotating: case Rotating:
fmtStartPool = view.getRotatingFormat(); fmtStartPool = view.getRotatingFormat();
break; break;
case CustomFormat: case CustomFormat:
if (customFormatCodes.isEmpty()) { if (customFormatCodes.isEmpty()) {
if (!FOptionPane.showConfirmDialog("You have defined a custom format that doesn't contain any sets.\nThis will start a game without restriction.\n\nContinue?")) {
int answer = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), "You have defined custom format as containing no sets.\nThis will start a game without restriction.\n\nContinue?");
if (JOptionPane.YES_OPTION != answer) {
return; return;
} }
} }
@@ -184,8 +181,7 @@ public enum CSubmenuQuestData implements ICDoc {
case Cube: case Cube:
dckStartPool = view.getSelectedDeck(); dckStartPool = view.getSelectedDeck();
if (null == dckStartPool) { if (null == dckStartPool) {
FOptionPane.showMessageDialog("You have not selected a deck to start.", "Cannot start a quest", FOptionPane.ERROR_ICON);
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "You have not selected a deck to start", "Cannot start a quest", JOptionPane.ERROR_MESSAGE);
return; return;
} }
break; break;
@@ -198,13 +194,12 @@ public enum CSubmenuQuestData implements ICDoc {
default: default:
// leave everything as nulls // leave everything as nulls
break; break;
} }
} }
else { else {
fmtStartPool = worldFormat; fmtStartPool = worldFormat;
} }
GameFormat fmtPrizes = null; GameFormat fmtPrizes = null;
// The starting QuestWorld format should NOT affect what you get if you travel to a world that doesn't have one... // The starting QuestWorld format should NOT affect what you get if you travel to a world that doesn't have one...
@@ -217,32 +212,32 @@ public enum CSubmenuQuestData implements ICDoc {
for (Entry<PaperCard, Integer> c : dckStartPool.getMain()) { for (Entry<PaperCard, Integer> c : dckStartPool.getMain()) {
sets.add(c.getKey().getEdition()); sets.add(c.getKey().getEdition());
} }
if (dckStartPool.has(DeckSection.Sideboard)) if (dckStartPool.has(DeckSection.Sideboard)) {
for (Entry<PaperCard, Integer> c : dckStartPool.get(DeckSection.Sideboard)) { for (Entry<PaperCard, Integer> c : dckStartPool.get(DeckSection.Sideboard)) {
sets.add(c.getKey().getEdition()); sets.add(c.getKey().getEdition());
} }
}
fmtPrizes = new GameFormat("From deck", sets, null); fmtPrizes = new GameFormat("From deck", sets, null);
} }
} else { }
else {
switch(prizedPoolType) { switch(prizedPoolType) {
case Complete: case Complete:
fmtPrizes = null; fmtPrizes = null;
break; break;
case CustomFormat: case CustomFormat:
if (customPrizeFormatCodes.isEmpty()) { 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?")) {
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?"); return;
if (JOptionPane.YES_OPTION != answer) {
return;
}
} }
fmtPrizes = customPrizeFormatCodes.isEmpty() ? null : new GameFormat("Custom Prizes", customPrizeFormatCodes, null); // chosen sets and no banend cards }
break; fmtPrizes = customPrizeFormatCodes.isEmpty() ? null : new GameFormat("Custom Prizes", customPrizeFormatCodes, null); // chosen sets and no banend cards
case Rotating: break;
fmtPrizes = view.getPrizedRotatingFormat(); case Rotating:
break; fmtPrizes = view.getPrizedRotatingFormat();
default: break;
throw new RuntimeException("Should not get this result"); default:
throw new RuntimeException("Should not get this result");
} }
} }
// } else { // } else {
@@ -250,14 +245,22 @@ public enum CSubmenuQuestData implements ICDoc {
// } // }
final StartingPoolPreferences userPrefs = new StartingPoolPreferences(view.randomizeColorDistribution(), view.getPreferredColor()); 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); String questName;
if (o == null) { return; } 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("")) { if (questName.isEmpty()) {
FOptionPane.showMessageDialog("Please pick another quest name, a quest already has that name."); FOptionPane.showMessageDialog("Please specify a quest name.");
return; 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(); QuestController qc = Singletons.getModel().getQuest();

View File

@@ -37,6 +37,10 @@ public class FOptionPane extends FDialog {
showOptionDialog(message, title, icon, new String[] {"OK"}, 0); 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) { public static boolean showConfirmDialog(String message, String title) {
return showConfirmDialog(message, title, "Yes", "No", true); return showConfirmDialog(message, title, "Yes", "No", true);
} }
@@ -56,7 +60,6 @@ public class FOptionPane extends FDialog {
} }
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); final FOptionPane optionPane = new FOptionPane(message, title, icon, null, options, defaultOption);
optionPane.setVisible(true); optionPane.setVisible(true);
int dialogResult = optionPane.result; int dialogResult = optionPane.result;
@@ -64,6 +67,10 @@ public class FOptionPane extends FDialog {
return dialogResult; 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) { public static String showInputDialog(String message, String title, SkinImage icon) {
return showInputDialog(message, title, icon, "", null); return showInputDialog(message, title, icon, "", null);
} }
@@ -144,7 +151,7 @@ public class FOptionPane extends FDialog {
prompt.setAutoSize(true); prompt.setAutoSize(true);
Dimension parentSize = JOptionPane.getRootFrame().getSize(); Dimension parentSize = JOptionPane.getRootFrame().getSize();
prompt.setMaximumSize(new Dimension(parentSize.width / 2, parentSize.height - 100)); 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; x = padding;
} }
if (comp != null) { if (comp != null) {