mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Use skinned dialog for new quest dialogs
This commit is contained in:
@@ -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<InventoryItem, Deck
|
||||
}
|
||||
|
||||
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.",
|
||||
one ? "Deck" : String.format("%d copies of deck", qty),
|
||||
deck.getName(), one ? "was" : "were", one ? "Its" : "Their"),
|
||||
"Thanks for purchasing!", JOptionPane.INFORMATION_MESSAGE);
|
||||
"Thanks for purchasing!", FOptionPane.INFORMATION_ICON);
|
||||
}
|
||||
else {
|
||||
continue; //don't remove item from Catalog if any other type
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
@@ -17,6 +16,7 @@ import forge.deck.Deck;
|
||||
import forge.gauntlet.GauntletData;
|
||||
import forge.gauntlet.GauntletIO;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.toolbox.FOptionPane;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
/**
|
||||
@@ -175,35 +175,29 @@ public enum CSubmenuGauntletBuild implements ICDoc {
|
||||
|
||||
// Warn if no name
|
||||
if (name.equals(GauntletIO.TXF_PROMPT) || name.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
|
||||
FOptionPane.showMessageDialog(
|
||||
"Please name your gauntlet using the 'Gauntlet Name' box.",
|
||||
"Save Error!",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
FOptionPane.ERROR_ICON);
|
||||
return false;
|
||||
}
|
||||
|
||||
final File f = new File(NewConstants.GAUNTLET_DIR.userPrefLoc + name + ".dat");
|
||||
// Confirm if overwrite
|
||||
if (f.exists()) {
|
||||
final int m = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(),
|
||||
if (!FOptionPane.showConfirmDialog(
|
||||
"There is already a gauntlet named '" + name + "'.\n"
|
||||
+ "All progress and data will be overwritten. Continue?",
|
||||
"Overwrite Gauntlet?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
"Overwrite Gauntlet?")) { return false; }
|
||||
|
||||
if (m == JOptionPane.NO_OPTION) { return false; }
|
||||
gd = GauntletIO.loadGauntlet(f);
|
||||
}
|
||||
// Confirm if a new gauntlet will be created
|
||||
else {
|
||||
final int m = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(),
|
||||
if (!FOptionPane.showConfirmDialog(
|
||||
"This will create a new gauntlet named '" + name + "'. Continue?",
|
||||
"Create Gauntlet?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
"Create Gauntlet?")) { return false; }
|
||||
|
||||
if (m == JOptionPane.NO_OPTION) { return false; }
|
||||
gd = new GauntletData();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package forge.gui.home.gauntlet;
|
||||
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
@@ -12,7 +10,6 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
@@ -21,6 +18,7 @@ import forge.Command;
|
||||
import forge.gauntlet.GauntletData;
|
||||
import forge.gauntlet.GauntletIO;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
import forge.gui.toolbox.FOptionPane;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.gui.toolbox.FSkin.SkinIcon;
|
||||
|
||||
@@ -264,14 +262,9 @@ public class QuickGauntletLister extends JPanel {
|
||||
private void deleteFile(RowPanel r0) {
|
||||
final GauntletData gd = r0.getGauntletData();
|
||||
|
||||
final int n = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(),
|
||||
if (!FOptionPane.showConfirmDialog(
|
||||
"Are you sure you want to delete \"" + gd.getName()
|
||||
+ "\" ?", "Delete Gauntlet", JOptionPane.YES_NO_OPTION);
|
||||
|
||||
if (n == JOptionPane.NO_OPTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
+ "\" ?", "Delete Gauntlet")) { return; }
|
||||
|
||||
GauntletIO.getGauntletFile(gd).delete();
|
||||
if (cmdRowDelete != null) { cmdRowDelete.run(); }
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import forge.Command;
|
||||
@@ -163,16 +162,14 @@ public enum CSubmenuQuestData implements ICDoc {
|
||||
GameFormat worldFormat = (startWorld == null ? null : startWorld.getFormat());
|
||||
|
||||
if (worldFormat == null) {
|
||||
switch(view.getStartingPoolType()) {
|
||||
switch(view.getStartingPoolType()) {
|
||||
case Rotating:
|
||||
fmtStartPool = view.getRotatingFormat();
|
||||
break;
|
||||
|
||||
case CustomFormat:
|
||||
if (customFormatCodes.isEmpty()) {
|
||||
|
||||
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) {
|
||||
if (!FOptionPane.showConfirmDialog("You have defined a custom format that doesn't contain any sets.\nThis will start a game without restriction.\n\nContinue?")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -184,8 +181,7 @@ public enum CSubmenuQuestData implements ICDoc {
|
||||
case Cube:
|
||||
dckStartPool = view.getSelectedDeck();
|
||||
if (null == dckStartPool) {
|
||||
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "You have not selected a deck to start", "Cannot start a quest", JOptionPane.ERROR_MESSAGE);
|
||||
FOptionPane.showMessageDialog("You have not selected a deck to start.", "Cannot start a quest", FOptionPane.ERROR_ICON);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -198,13 +194,12 @@ public enum CSubmenuQuestData implements ICDoc {
|
||||
default:
|
||||
// leave everything as nulls
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
fmtStartPool = worldFormat;
|
||||
}
|
||||
|
||||
|
||||
GameFormat fmtPrizes = null;
|
||||
|
||||
// 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()) {
|
||||
sets.add(c.getKey().getEdition());
|
||||
}
|
||||
if (dckStartPool.has(DeckSection.Sideboard))
|
||||
if (dckStartPool.has(DeckSection.Sideboard)) {
|
||||
for (Entry<PaperCard, Integer> 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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -56,7 +60,6 @@ public class FOptionPane extends FDialog {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user