Prevent glitchy dialog on Linux

Transition more message/confirm dialogs to skinned look
This commit is contained in:
drdev
2013-12-27 05:59:29 +00:00
parent 0d28620ee3
commit ddaffcf7a5
23 changed files with 136 additions and 114 deletions

View File

@@ -8,6 +8,10 @@ Forge Beta: 12-##-2013 ver 1.5.8
Release Notes
-------------
- Improved dialog appearance -
Many message and confirmation dialogs now use skinned look with rounded border dialog on top of overlay
- Deck Editor usability improvements -
You can now mark a card as a favorite in the Catalog by clicking the star icon in the first column. This will default the card to sort ahead of non-favorite cards if you sort on that first column (which is now the Forge default).
You can now add or remove cards from a deck using +/- buttons that appear on either side of the quantity for each card.

View File

@@ -31,7 +31,6 @@ import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
@@ -69,7 +68,7 @@ import forge.gui.match.controllers.CStack;
import forge.gui.match.views.VAntes;
import forge.gui.match.views.VField;
import forge.gui.menus.ForgeMenu;
import forge.gui.menus.MenuUtil;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FSkin;
import forge.net.FServer;
import forge.properties.ForgePreferences;
@@ -122,20 +121,17 @@ public enum FControl implements KeyEventDispatcher {
public void windowClosing(final WindowEvent e) {
switch (closeAction) {
case NONE: //prompt user for close action if not previously specified
Object[] options = {"Close Screen", "Exit Forge", "Cancel"};
int reply = JOptionPane.showOptionDialog(
JOptionPane.getRootFrame(),
"Forge now supports navigation tabs which allow closing and switching between different screens with ease.\n"
+ "As a result, you no longer need to use the X button in the upper right to close the current screen and go back.\n"
+ "\n"
+ "Please select what you want to happen when clicking the X button in the upper right. This choice will be used\n"
String[] options = {"Close Screen", "Exit Forge", "Cancel"};
int reply = FOptionPane.showOptionDialog(
"Forge now supports navigation tabs which allow closing and switching between different screens with ease. "
+ "As a result, you no longer need to use the X button in the upper right to close the current screen and go back."
+ "\n\n"
+ "Please select what you want to happen when clicking the X button in the upper right. This choice will be used "
+ "going forward and you will not see this message again. You can change this behavior at any time in Preferences.",
"Select Your Close Action",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
FOptionPane.INFORMATION_ICON,
options,
options[2]);
2);
switch (reply) {
case 0: //Close Screen
setCloseAction(CloseAction.CLOSE_SCREEN);
@@ -181,7 +177,7 @@ public enum FControl implements KeyEventDispatcher {
if (this.game != null) {
userPrompt = "A game is currently active. " + userPrompt;
}
if (!MenuUtil.getUserConfirmation(userPrompt, "Exit Forge", this.game == null)) { //default Yes if no game active
if (!FOptionPane.showConfirmDialog(userPrompt, "Exit Forge", this.game == null)) { //default Yes if no game active
return false;
}
if (!CDeckEditorUI.SINGLETON_INSTANCE.canSwitchAway(true)) {
@@ -429,7 +425,7 @@ public enum FControl implements KeyEventDispatcher {
if (this.game != null) {
this.setCurrentScreen(FScreen.MATCH_SCREEN);
SOverlayUtils.hideOverlay();
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Cannot start a new game while another game is already in progress.");
FOptionPane.showMessageDialog("Cannot start a new game while another game is already in progress.");
return; //TODO: See if it's possible to run multiple games at once without crashing
}
setPlayerName(match.getPlayers());

View File

@@ -24,14 +24,13 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;
import javax.swing.JOptionPane;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import forge.deck.Deck;
import forge.deck.DeckGroup;
import forge.gui.toolbox.FOptionPane;
import forge.properties.NewConstants;
import forge.util.FileSection;
import forge.util.FileUtil;
@@ -149,8 +148,7 @@ public class OldDeckParser {
this.draft.add(d);
} else {
final String msg = String.format("Draft '%s' lacked some decks.%n%nShould it be deleted?");
mayDelete = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), msg, "Draft loading error",
JOptionPane.YES_NO_OPTION);
mayDelete = FOptionPane.showConfirmDialog(msg, "Draft loading error");
}
if (mayDelete) {
@@ -180,13 +178,13 @@ public class OldDeckParser {
try {
this.cube.add(Deck.fromSections(sections));
importedOk = true;
} catch (final NoSuchElementException ex) {
}
catch (final NoSuchElementException ex) {
if (!allowDeleteUnsupportedConstructed) {
final String msg = String
.format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
name, ex.getMessage());
allowDeleteUnsupportedConstructed = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(
JOptionPane.getRootFrame(), msg, "Problem converting decks", JOptionPane.YES_NO_OPTION);
allowDeleteUnsupportedConstructed = FOptionPane.showConfirmDialog(msg, "Problem converting decks");
}
}
if (importedOk || allowDeleteUnsupportedConstructed) {
@@ -205,8 +203,7 @@ public class OldDeckParser {
final String msg = String
.format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
name, ex.getMessage());
allowDeleteUnsupportedConstructed = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(
null, msg, "Problem converting decks", JOptionPane.YES_NO_OPTION);
allowDeleteUnsupportedConstructed = FOptionPane.showConfirmDialog(msg, "Problem converting decks");
}
}
if (importedOk || allowDeleteUnsupportedConstructed) {
@@ -258,9 +255,7 @@ public class OldDeckParser {
}
sb.append(System.getProperty("line.separator"));
sb.append("May Forge delete these decks?");
final int response = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), sb.toString(),
"Some of your sealed decks are orphaned", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
if (FOptionPane.showConfirmDialog(sb.toString(), "Some of your sealed decks are orphaned")) {
for (final Pair<DeckGroup, MutablePair<File, File>> s : sealedDecks.values()) {
if (s.getRight().getLeft() != null) {
s.getRight().getLeft().delete();

View File

@@ -54,6 +54,7 @@ import forge.FThreads;
import forge.gui.WrapLayout;
import forge.gui.toolbox.FHyperlink;
import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FOptionPane;
import forge.model.BuildInfo;
/**
@@ -272,10 +273,10 @@ public class BugReporter {
// browse to url
Desktop.getDesktop().browse(new URI(url));
} catch (Exception ex) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
"Sorry, a problem occurred while opening the forum in your default browser.",
"A problem occured", JOptionPane.ERROR_MESSAGE);
}
catch (Exception ex) {
FOptionPane.showMessageDialog("Sorry, a problem occurred while opening the forum in your default browser.",
"A problem occurred", FOptionPane.ERROR_ICON);
}
}
}
@@ -315,10 +316,10 @@ public class BugReporter {
final BufferedWriter bw = new BufferedWriter(new FileWriter(f));
bw.write(this.area.getText());
bw.close();
} catch (final IOException ex) {
JOptionPane.showMessageDialog(area.getTopLevelAncestor(),
"There was an error during saving. Sorry!\n" + ex,
"Error saving file", JOptionPane.ERROR_MESSAGE);
}
catch (final IOException ex) {
FOptionPane.showMessageDialog("There was an error during saving. Sorry!\n" + ex,
"Error saving file", FOptionPane.ERROR_ICON);
}
}
}

View File

@@ -3,7 +3,6 @@ package forge.gui;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import org.apache.commons.lang3.StringUtils;
@@ -11,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
import forge.FThreads;
import forge.game.card.Card;
import forge.gui.match.CMatchUI;
import forge.gui.toolbox.FOptionPane;
/**
* Holds player interactions using standard windows
@@ -39,17 +39,16 @@ public class GuiDialog {
final String title = c == null ? "Question" : c.getName() + " - Ability";
String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
String[] opts = options == null ? defaultConfirmOptions : options;
int answer = JOptionPane.showOptionDialog(JOptionPane.getRootFrame(), questionToUse, title,
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
opts, opts[defaultIsYes ? 0 : 1]);
return answer == JOptionPane.YES_OPTION;
int answer = FOptionPane.showOptionDialog(questionToUse, title, FOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1);
return answer == 0;
}};
FutureTask<Boolean> future = new FutureTask<Boolean>(confirmTask);
FThreads.invokeInEdtAndWait(future);
try {
return future.get().booleanValue();
} catch (Exception e) { // should be no exception here
}
catch (Exception e) { // should be no exception here
e.printStackTrace();
}
return false;
@@ -64,15 +63,14 @@ public class GuiDialog {
* a {@link java.lang.String} object.
*/
public static void message(final String message) {
message(message, UIManager.getString("OptionPane.messageDialogTitle"));
message(message, UIManager.getString("OptionPane.messageDialogTitle"));
}
public static void message(final String message, final String title) {
FThreads.invokeInEdtAndWait(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), message, title, JOptionPane.PLAIN_MESSAGE);
FOptionPane.showMessageDialog(message, title, null);
}
});
}

View File

@@ -31,8 +31,6 @@ import java.util.Map;
import java.util.Map.Entry;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import com.google.common.base.Predicates;
import com.google.common.collect.Lists;
@@ -47,6 +45,7 @@ import forge.game.card.CardPredicates;
import forge.game.card.CounterType;
import forge.game.phase.PhaseType;
import forge.gui.player.HumanPlay;
import forge.gui.toolbox.FOptionPane;
import forge.game.player.Player;
import forge.game.spellability.AbilityManaPart;
import forge.game.spellability.SpellAbility;
@@ -127,10 +126,12 @@ public final class GuiDisplayUtil {
}
in.close();
} catch (final FileNotFoundException fnfe) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "File not found: " + fc.getSelectedFile().getAbsolutePath());
} catch (final Exception e) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Error loading battle setup file!");
}
catch (final FileNotFoundException fnfe) {
FOptionPane.showErrorMessageDialog("File not found: " + fc.getSelectedFile().getAbsolutePath());
}
catch (final Exception e) {
FOptionPane.showErrorMessageDialog("Error loading battle setup file!");
return;
}

View File

@@ -62,6 +62,7 @@ import forge.gui.toolbox.FButton;
import forge.gui.toolbox.FCheckBox;
import forge.gui.toolbox.FComboBoxWrapper;
import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FOverlay;
import forge.gui.toolbox.FPanel;
import forge.gui.toolbox.FScrollPane;
@@ -149,8 +150,9 @@ public class ImportDialog {
if (JFileChooser.APPROVE_OPTION == _fileChooser.showOpenDialog(JOptionPane.getRootFrame())) {
File f = _fileChooser.getSelectedFile();
if (!f.canRead()) {
JOptionPane.showMessageDialog(txfSrc, "Cannot access selected directory (Permission denied).");
} else {
FOptionPane.showErrorMessageDialog("Cannot access selected directory (Permission denied).");
}
else {
txfSrc.setText(f.getAbsolutePath());
}
}
@@ -620,11 +622,11 @@ public class ImportDialog {
sb.append("will come up again the next time you start Forge in order to migrate the remaining files<br>");
sb.append("unless you move or delete them manually.</html>");
Object[] options = { "Whoops, let me fix that!", "Continue with the import, I know what I'm doing." };
int chosen = JOptionPane.showOptionDialog(_operationLog, sb.toString(), "Migration warning",
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
String[] options = { "Whoops, let me fix that!", "Continue with the import, I know what I'm doing." };
int chosen = FOptionPane.showOptionDialog(sb.toString(), "Migration warning",
FOptionPane.WARNING_ICON, options, 0);
if (1 != chosen) {
if (chosen != 1) {
// i.e. option 0 was chosen or the dialog was otherwise closed
return;
}

View File

@@ -24,6 +24,7 @@ import forge.deck.generation.DeckGenerator3Color;
import forge.deck.generation.DeckGenerator5Color;
import forge.deck.generation.DeckGeneratorBase;
import forge.deck.generation.DeckGeneratorMonoColor;
import forge.gui.toolbox.FOptionPane;
import forge.item.PaperCard;
import forge.properties.ForgePreferences.FPref;
import forge.quest.QuestController;
@@ -267,8 +268,7 @@ public class DeckgenUtil {
msg.append("Copy Decklist to Clipboard?");
// Output
final int rcMsg = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), msg, "Decklist", JOptionPane.OK_CANCEL_OPTION);
if (rcMsg == JOptionPane.OK_OPTION) {
if (FOptionPane.showConfirmDialog(msg.toString(), "Decklist", "OK", "Cancel")) {
final StringSelection ss = new StringSelection(deckList.toString());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
}
@@ -285,16 +285,16 @@ public class DeckgenUtil {
boolean result = true;
if (colors0.size() == 4) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
FOptionPane.showMessageDialog(
"Sorry, four color generated decks aren't supported yet."
+ "\n\rPlease use 2, 3, or 5 colors for this deck.",
"Generate deck: 4 colors", JOptionPane.ERROR_MESSAGE);
"Generate deck: 4 colors", FOptionPane.ERROR_ICON);
result = false;
}
else if (colors0.size() > 5) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
FOptionPane.showMessageDialog(
"Generate deck: maximum five colors!",
"Generate deck: too many colors", JOptionPane.ERROR_MESSAGE);
"Generate deck: too many colors", FOptionPane.ERROR_ICON);
result = false;
}
return result;

View File

@@ -26,7 +26,6 @@ import java.util.Calendar;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
@@ -47,6 +46,7 @@ import forge.gui.toolbox.FCheckBox;
import forge.gui.toolbox.FComboBoxWrapper;
import forge.gui.toolbox.FHtmlViewer;
import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FScrollPane;
import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.FTextArea;
@@ -158,9 +158,7 @@ public class DeckImport<TItem extends InventoryItem, TModel extends DeckBase> ex
@Override
public void actionPerformed(final ActionEvent e) {
final String warning = "This will replace contents of your currently open deck with whatever you are importing. Proceed?";
final int answer = JOptionPane.showConfirmDialog(DeckImport.this, warning, "Replacing old deck",
JOptionPane.YES_NO_OPTION);
if (JOptionPane.NO_OPTION == answer) {
if (!FOptionPane.showConfirmDialog(warning, "Replacing old deck")) {
return;
}
final Deck toSet = DeckImport.this.buildDeck();

View File

@@ -9,6 +9,7 @@ import forge.deck.DeckBase;
import forge.gui.deckeditor.controllers.DeckController;
import forge.gui.deckeditor.views.VCurrentDeck;
import forge.gui.framework.FScreen;
import forge.gui.toolbox.FOptionPane;
/**
* Handles editor preferences saving and loading.
@@ -43,10 +44,8 @@ public class SEditorIO {
// Warn if no name
if (name == null || name.isEmpty()) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
"Please name your deck using the 'Title' box.",
"Save Error!",
JOptionPane.ERROR_MESSAGE);
FOptionPane.showMessageDialog("Please name your deck using the 'Title' box.",
"Save Error!", FOptionPane.ERROR_ICON);
return false;
}
// Confirm if overwrite
@@ -86,15 +85,12 @@ public class SEditorIO {
public static boolean confirmSaveChanges(FScreen screen) {
if (!((DeckController<DeckBase>) CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController().getDeckController()).isSaved()) {
Singletons.getControl().ensureScreenActive(screen); //ensure Deck Editor is active before showing dialog
final int choice = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(),
"Save changes to current deck?",
"Save Changes?",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
final int choice = FOptionPane.showOptionDialog("Save changes to current deck?", "Save Changes?",
FOptionPane.QUESTION_ICON, new String[] {"Save", "Don't Save", "Cancel"}, 0);
if (choice == JOptionPane.CANCEL_OPTION) { return false; }
if (choice == 2) { return false; }
if (choice == JOptionPane.YES_OPTION && !saveDeck()) { return false; }
if (choice == 0 && !saveDeck()) { return false; }
}
return true;

View File

@@ -48,6 +48,7 @@ import forge.gui.framework.DragCell;
import forge.gui.framework.FScreen;
import forge.gui.home.quest.CSubmenuQuestDecks;
import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.itemmanager.SpellShopManager;
import forge.gui.toolbox.itemmanager.SItemManagerUtil;
@@ -308,8 +309,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
final int value = this.getCardValue(item);
if (value > this.questData.getAssets().getCredits()) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
"Not enough credits to purchase " + (qty == 1 ? "" : qty + " copies of ") + item.getName() + ".");
FOptionPane.showMessageDialog("Not enough credits to purchase " + (qty == 1 ? "" : qty + " copies of ") + item.getName() + ".");
continue;
}

View File

@@ -2,8 +2,6 @@ package forge.gui.framework;
import java.io.File;
import javax.swing.JOptionPane;
import forge.Singletons;
import forge.gui.bazaar.CBazaarUI;
import forge.gui.bazaar.VBazaarUI;
@@ -13,6 +11,7 @@ import forge.gui.home.CHomeUI;
import forge.gui.home.VHomeUI;
import forge.gui.match.CMatchUI;
import forge.gui.match.VMatchUI;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.FSkin.SkinImage;
import forge.gui.workshop.CWorkshopUI;
@@ -202,7 +201,7 @@ public enum FScreen {
}
catch (final Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Failed to delete layout file.");
FOptionPane.showErrorMessageDialog("Failed to delete layout file.");
}
return false;
}

View File

@@ -19,6 +19,7 @@ import forge.deck.Deck;
import forge.deck.DeckSection;
import forge.game.GameFormat;
import forge.gui.framework.ICDoc;
import forge.gui.toolbox.FOptionPane;
import forge.item.PaperCard;
import forge.properties.NewConstants;
import forge.quest.QuestController;
@@ -255,7 +256,7 @@ public enum CSubmenuQuestData implements ICDoc {
final String questName = SSubmenuQuestUtil.cleanString(o.toString());
if (getAllQuests().get(questName) != null || questName.equals("")) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Please pick another quest name, a quest already has that name.");
FOptionPane.showMessageDialog("Please pick another quest name, a quest already has that name.");
return;
}

View File

@@ -13,9 +13,11 @@ import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import net.miginfocom.swing.MigLayout;
import forge.Command;
import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FSkin;
import forge.properties.NewConstants;
import forge.quest.data.QuestData;
@@ -310,7 +312,7 @@ public class QuestFileLister extends JPanel {
}
if (exists || questName.equals("")) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Please pick another quest name, a quest already has that name.");
FOptionPane.showMessageDialog("Please pick another quest name, a quest already has that name.");
return;
}
else {

View File

@@ -20,6 +20,7 @@ import forge.gui.deckchooser.DecksComboBox.DeckType;
import forge.gui.framework.ICDoc;
import forge.gui.menus.IMenuProvider;
import forge.gui.menus.MenuUtil;
import forge.gui.toolbox.FOptionPane;
import forge.net.FServer;
import forge.net.Lobby;
import forge.properties.ForgePreferences.FPref;
@@ -100,7 +101,7 @@ public enum CSubmenuConstructed implements ICDoc, IMenuProvider {
private void startGame(final GameType gameType) {
for(int i=0;i<view.getNumPlayers();i++) {
if (view.getDeckChooser(i).getPlayer() == null) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Please specify a deck for each player first.");
FOptionPane.showMessageDialog("Please specify a deck for each player first.");
return;
}
}

View File

@@ -24,6 +24,7 @@ import forge.gui.framework.ICDoc;
import forge.gui.toolbox.FComboBox;
import forge.gui.toolbox.FComboBoxPanel;
import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FOptionPane;
import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref;
@@ -183,7 +184,7 @@ public enum CSubmenuPreferences implements ICDoc {
int reply = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), userPrompt, "Reset Deck Editor Layout", JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.YES_OPTION) {
if (FScreen.DECK_EDITOR_CONSTRUCTED.deleteLayoutFile()) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Deck Editor layout has been reset.");
FOptionPane.showMessageDialog("Deck Editor layout has been reset.");
}
}
}
@@ -196,7 +197,7 @@ public enum CSubmenuPreferences implements ICDoc {
int reply = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), userPrompt, "Reset Workshop Layout", JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.YES_OPTION) {
if (FScreen.WORKSHOP_SCREEN.deleteLayoutFile()) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Workshop layout has been reset.");
FOptionPane.showMessageDialog("Workshop layout has been reset.");
}
}
}
@@ -210,7 +211,7 @@ public enum CSubmenuPreferences implements ICDoc {
int reply = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), userPrompt, "Reset Match Screen Layout", JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.YES_OPTION) {
if (FScreen.MATCH_SCREEN.deleteLayoutFile()) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Match Screen layout has been reset.");
FOptionPane.showMessageDialog("Match Screen layout has been reset.");
}
}
}

View File

@@ -5,6 +5,7 @@ import javax.swing.JOptionPane;
import org.apache.commons.lang3.StringUtils;
import forge.Singletons;
import forge.gui.toolbox.FOptionPane;
import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref;
@@ -34,9 +35,7 @@ public final class GamePlayerUtil {
}
private static void showThankYouPrompt(String playerName) {
JOptionPane.showMessageDialog(
JOptionPane.getRootFrame(),
"Thank you, " + playerName + ". " +
FOptionPane.showMessageDialog("Thank you, " + playerName + ". " +
"You will not be prompted again but you can change\nyour name at any time using the \"Player Name\" setting in Preferences.\n\n");
}

View File

@@ -65,7 +65,7 @@ import forge.gui.match.views.VHand;
import forge.gui.match.views.VPlayers;
import forge.gui.match.views.VStack;
import forge.gui.menus.IMenuProvider;
import forge.gui.menus.MenuUtil;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FOverlay;
import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.FSkin.SkinImage;
@@ -497,7 +497,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
String userPrompt =
"This will end the current game and you will not be able to resume.\n\n" +
"Concede anyway?";
if (MenuUtil.getUserConfirmation(userPrompt, "Concede Game?", false)) {
if (FOptionPane.showConfirmDialog(userPrompt, "Concede Game?", false)) {
Singletons.getControl().stopGame();
}
}

View File

@@ -7,7 +7,6 @@ import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import forge.Singletons;
import forge.gui.toolbox.FOptionPane;
import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.FSkin.SkinProp;
import forge.gui.toolbox.imaging.ImageUtil;
@@ -21,7 +20,8 @@ public final class MenuUtil {
public static void openUrlInBrowser(String url) {
try {
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
} catch (IOException e) {
}
catch (IOException e) {
// Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace();
}
@@ -35,15 +35,10 @@ public final class MenuUtil {
return KeyStroke.getKeyStroke(key, DEFAULT_MenuShortcutKeyMask);
}
public static boolean getUserConfirmation(String prompt, String dialogTitle, boolean defaultYes) {
String[] options = {"Yes", "No"};
int reply = FOptionPane.showOptionDialog(prompt, dialogTitle, FSkin.getIcon(FSkin.InterfaceIcons.ICO_QUESTION), options, defaultYes ? 0 : 1);
return (reply == 0);
}
public static void setMenuProvider(IMenuProvider provider) {
Singletons.getControl().getForgeMenu().setProvider(provider);
}
public static void setMenuHint(final JMenuItem menu, final String hint) {
menu.setToolTipText(hint);
}

View File

@@ -20,7 +20,40 @@ import forge.view.FDialog;
*/
@SuppressWarnings("serial")
public class FOptionPane extends FDialog {
private int result;
public static final SkinImage QUESTION_ICON = FSkin.getIcon(FSkin.InterfaceIcons.ICO_QUESTION);
public static final SkinImage INFORMATION_ICON = FSkin.getIcon(FSkin.InterfaceIcons.ICO_INFORMATION);
public static final SkinImage WARNING_ICON = FSkin.getIcon(FSkin.InterfaceIcons.ICO_WARNING);
public static final SkinImage ERROR_ICON = FSkin.getIcon(FSkin.InterfaceIcons.ICO_ERROR);
public static void showMessageDialog(String message) {
showMessageDialog(message, "Forge", INFORMATION_ICON);
}
public static void showErrorMessageDialog(String message) {
showMessageDialog(message, "Forge", ERROR_ICON);
}
public static void showMessageDialog(String message, String title, SkinImage icon) {
showOptionDialog(message, title, icon, new String[] {"OK"}, 0);
}
public static boolean showConfirmDialog(String message, String title) {
return showConfirmDialog(message, title, "Yes", "No", true);
}
public static boolean showConfirmDialog(String message, String title, boolean defaultYes) {
return showConfirmDialog(message, title, "Yes", "No", defaultYes);
}
public static boolean showConfirmDialog(String message, String title, String yesButtonText, String noButtonText) {
return showConfirmDialog(message, title, yesButtonText, noButtonText, true);
}
public static boolean showConfirmDialog(String message, String title, String yesButtonText, String noButtonText, boolean defaultYes) {
String[] options = {yesButtonText, noButtonText};
int reply = FOptionPane.showOptionDialog(message, title, QUESTION_ICON, options, defaultYes ? 0 : 1);
return (reply == 0);
}
public static int showOptionDialog(String message, String title, SkinImage icon, String[] options, int defaultOption) {
FTextArea txtMessage = new FTextArea(message);
@@ -30,13 +63,14 @@ public class FOptionPane extends FDialog {
txtMessage.setMaximumSize(new Dimension(parentSize.width / 2, parentSize.height - 100));
FOptionPane optionPane = new FOptionPane(title, icon, txtMessage, options, defaultOption);
optionPane.result = options.length - 1; //default result to final option in case dialog closed
optionPane.setVisible(true);
int dialogResult = optionPane.result;
optionPane.dispose();
return dialogResult;
}
private int result = -1; //default result to -1, indicating dialog closed without choosing option
private FOptionPane(String title, SkinImage icon, JComponent comp, String[] options, int defaultOption) {
this.setTitle(title);

View File

@@ -1487,7 +1487,7 @@ public enum FSkin {
public enum InterfaceIcons implements SkinProp {
ICO_QUESTION (new int[] {560, 800, 32, 32}),
ICO_INFO (new int[] {592, 800, 32, 32}),
ICO_INFORMATION (new int[] {592, 800, 32, 32}),
ICO_WARNING (new int[] {560, 832, 32, 32}),
ICO_ERROR (new int[] {592, 832, 32, 32}),
ICO_DELETE (new int[] {640, 480, 20, 20}),

View File

@@ -23,12 +23,11 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.swing.JOptionPane;
import org.apache.commons.lang3.StringUtils;
import forge.CardStorageReader;
import forge.card.CardRules;
import forge.gui.toolbox.FOptionPane;
public final class CardScriptInfo {
private String text;
@@ -61,8 +60,9 @@ public final class CardScriptInfo {
this.text = text0;
return true;
} catch (final Exception ex) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Problem writing file - " + this.file + " : " + ex);
}
catch (final Exception ex) {
FOptionPane.showErrorMessageDialog("Problem writing file - " + this.file + " : " + ex);
return false;
}
}

View File

@@ -11,7 +11,6 @@ import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.PopupMenu;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.GraphicsDevice.WindowTranslucency;
import java.awt.event.ComponentAdapter;
@@ -100,7 +99,7 @@ public class FDialog extends JDialog implements ITitleBarOwner, KeyEventDispatch
//draw rounded border
final Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //TODO: Re-enable anti-aliasing when it won't break on Linux
skin.setGraphicsColor(g2d, borderColor);
if (isSetShapeSupported) {
g2d.drawRoundRect(0, 0, this.getWidth() - 1, this.getHeight() - 1, cornerDiameter, cornerDiameter);