From 2284721c0961983bb06faae59983044c66a6a57b Mon Sep 17 00:00:00 2001 From: jendave Date: Sun, 7 Aug 2011 01:17:24 +0000 Subject: [PATCH] "How To Play" is now part of the "Help" menu item. Fixes an issue on OSX --- res/lang/de.properties | 1 + res/lang/en.properties | 3 +- res/lang/howTo/en.properties | 2 +- src/forge/Gui_NewGame.java | 41 ++++++++++++++++++++++---- src/forge/properties/NewConstants.java | 10 +++++++ 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/res/lang/de.properties b/res/lang/de.properties index 0ab3ccc83c3..b2b2076efdd 100644 --- a/res/lang/de.properties +++ b/res/lang/de.properties @@ -119,6 +119,7 @@ NewGame/options/cardScale=Karten vergr NewGame/options/generate/title=Deckgenerator NewGame/options/generate/removeSmall=1/1 und 0/X Kreaturen entfernen NewGame/options/generate/removeArtifacts=Artefakte entfernen +NewGame/help/title=Help NewGame/gametype=Spieltyp NewGame/library=Bibliothek diff --git a/res/lang/en.properties b/res/lang/en.properties index 22ab33fc17a..e481a9505cc 100644 --- a/res/lang/en.properties +++ b/res/lang/en.properties @@ -127,7 +127,8 @@ NewGame/options/cardOverlay=Use mana and text card overlay NewGame/options/cardScale=Scale card images larger than original NewGame/options/generate/title=Generate Deck NewGame/options/generate/removeSmall=Remove 1/1 and 0/X Creatures -NewGame/options/generate/removeArtifacts=Remove Artifacts" +NewGame/options/generate/removeArtifacts=Remove Artifacts +NewGame/help/title=Help NewGame/gametype=Game Type NewGame/library=Library diff --git a/res/lang/howTo/en.properties b/res/lang/howTo/en.properties index 5fa2ad3dbe2..ca12037e84f 100644 --- a/res/lang/howTo/en.properties +++ b/res/lang/howTo/en.properties @@ -1,4 +1,4 @@ -title=(How to Play) +title=How to Play message=How to Play - (Revised: September 2009.)\n\n\n\ Introduction\n\n\ 1. This game is similar to many other trading card games. You start out with 20 life and your goal is to reduce your opponents life to zero by attacking with your creatures. The game will end when your life or the computer's life is reduced to zero. You play \"matches\" against the computer as a set of \"best two out of three\" games."\n\n\ diff --git a/src/forge/Gui_NewGame.java b/src/forge/Gui_NewGame.java index ffc5fdbf7a8..b152d325f04 100644 --- a/src/forge/Gui_NewGame.java +++ b/src/forge/Gui_NewGame.java @@ -23,15 +23,14 @@ import javax.swing.*; import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.border.TitledBorder; import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.awt.Graphics; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.*; import java.util.*; +import java.util.List; /*CHOPPIC*/ @@ -92,6 +91,7 @@ public class Gui_NewGame extends JFrame implements NewConstants, NewConstants.LA private Action CARD_STACK_ACTION = new CardStackAction(); private Action CARD_STACK_OFFSET_ACTION = new CardStackOffsetAction(); private Action ABOUT_ACTION = new AboutAction(); + private Action HOW_TO_PLAY_ACTION = new HowToPlayAction(); private Action DNLD_PRICES_ACTION = new DownloadPriceAction(); static public ForgePreferences preferences; @@ -233,11 +233,19 @@ public class Gui_NewGame extends JFrame implements NewConstants, NewConstants.LA ImageCache.scaleLargerThanOriginal = cardScale.isSelected(); } }); + + JMenu helpMenu = new JMenu(ForgeProps.getLocalized(MENU_BAR.HELP.TITLE)) ; + + Action[] helpActions = {HOW_TO_PLAY_ACTION}; + for (Action a:helpActions) { + helpMenu.add(a); + } JMenuBar bar = new JMenuBar(); bar.add(menu); bar.add(optionsMenu); - bar.add(new MenuItem_HowToPlay()); + bar.add(helpMenu); + //bar.add(new MenuItem_HowToPlay()); setJMenuBar(bar); } @@ -1165,7 +1173,30 @@ public class Gui_NewGame extends JFrame implements NewConstants, NewConstants.LA Constant.Runtime.stackOffset[0] = offsets[index]; } } - + + public static class HowToPlayAction extends AbstractAction { + + private static final long serialVersionUID = 5552000208438248428L; + + public HowToPlayAction() { + super(ForgeProps.getLocalized(LANG.HowTo.TITLE)); + } + + public void actionPerformed(ActionEvent e) { + String text = ForgeProps.getLocalized(LANG.HowTo.MESSAGE); + + JTextArea area = new JTextArea(text, 25, 40); + area.setWrapStyleWord(true); + area.setLineWrap(true); + area.setEditable(false); + area.setOpaque(false); + + + JOptionPane.showMessageDialog(null, new JScrollPane(area), ForgeProps.getLocalized(LANG.HowTo.TITLE), + JOptionPane.INFORMATION_MESSAGE); + } + } + public static class AboutAction extends AbstractAction { private static final long serialVersionUID = 5492173304463396871L; diff --git a/src/forge/properties/NewConstants.java b/src/forge/properties/NewConstants.java index 5d9ed45c06b..f8fc95aac0e 100644 --- a/src/forge/properties/NewConstants.java +++ b/src/forge/properties/NewConstants.java @@ -347,6 +347,16 @@ public interface NewConstants { public static final String REMOVE_ARTIFACTS = "%s/NewGame/options/generate/removeArtifacts"; } } + + public static interface HELP { + public static final String TITLE = "%s/NewGame/help/title"; + } + + + + + + } public static interface ERRORS {}