mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Added "How to Play" option to Help menu which links to the cunningly hidden "res\howto.txt".
This commit is contained in:
@@ -14,9 +14,9 @@ import forge.gui.menubar.MenuUtil;
|
||||
import forge.util.FileUtil;
|
||||
|
||||
public final class HelpMenu {
|
||||
private HelpMenu() { }
|
||||
private HelpMenu() { }
|
||||
|
||||
public static JMenu getMenu() {
|
||||
public static JMenu getMenu() {
|
||||
JMenu menu = new JMenu("Help");
|
||||
menu.setMnemonic(KeyEvent.VK_H);
|
||||
menu.add(getMenu_GettingStarted());
|
||||
@@ -24,38 +24,46 @@ public final class HelpMenu {
|
||||
menu.add(getMenu_Troubleshooting());
|
||||
menu.addSeparator();
|
||||
menu.add(getMenuItem_ReleaseNotes());
|
||||
menu.add(getMenuItem_License());
|
||||
return menu;
|
||||
menu.add(getMenuItem_License());
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
private static JMenu getMenu_Troubleshooting() {
|
||||
JMenu mnu = new JMenu("Troubleshooting");
|
||||
mnu.add(getMenuItem_UrlLink("How to Provide a Useful Bug Report", "http://www.slightlymagic.net/forum/viewtopic.php?f=26&t=9621"));
|
||||
mnu.addSeparator();
|
||||
mnu.addSeparator();
|
||||
mnu.add(getMenuItem_ReadMeFile());
|
||||
return mnu;
|
||||
}
|
||||
|
||||
|
||||
private static JMenu getMenu_Articles() {
|
||||
JMenu mnu = new JMenu("Articles");
|
||||
mnu.add(getMenuItem_UrlLink("HOW-TO: Customize your Sealed Deck games with fantasy blocks", "http://www.slightlymagic.net/forum/viewtopic.php?f=26&t=8164"));
|
||||
mnu.add(getMenuItem_UrlLink("Quest Mode: Guide to Formats, Worlds, and everything", "http://www.slightlymagic.net/forum/viewtopic.php?f=26&t=9258"));
|
||||
return mnu;
|
||||
}
|
||||
|
||||
|
||||
private static JMenu getMenu_GettingStarted() {
|
||||
JMenu mnu = new JMenu("Getting Started");
|
||||
mnu.add(getMenuItem_HowToPlayFile());
|
||||
mnu.addSeparator();
|
||||
mnu.add(getMenuItem_UrlLink("Forge Wiki", "http://www.slightlymagic.net/wiki/Forge"));
|
||||
mnu.add(getMenuItem_UrlLink("What is Forge?", "http://www.slightlymagic.net/forum/viewtopic.php?f=26&t=468"));
|
||||
return mnu;
|
||||
return mnu;
|
||||
}
|
||||
|
||||
|
||||
private static JMenuItem getMenuItem_HowToPlayFile() {
|
||||
JMenuItem menuItem = new JMenuItem("How to Play");
|
||||
menuItem.addActionListener(getOpenFileAction(getFile("res\\howto.txt")));
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
private static JMenuItem getMenuItem_ReadMeFile() {
|
||||
JMenuItem menuItem = new JMenuItem("README.txt");
|
||||
menuItem.addActionListener(getOpenFileAction(getFile("README.txt")));
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
|
||||
private static JMenuItem getMenuItem_License() {
|
||||
JMenuItem menuItem = new JMenuItem("Forge License");
|
||||
menuItem.addActionListener(getOpenFileAction(getFile("LICENSE.txt")));
|
||||
@@ -69,7 +77,7 @@ public final class HelpMenu {
|
||||
}
|
||||
|
||||
private static ActionListener getOpenFileAction(final File file) {
|
||||
return new ActionListener() {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
@@ -81,15 +89,15 @@ public final class HelpMenu {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected static File getFile(String filename) {
|
||||
// !! Linux is case-sensitive so file name and extension need to match exactly !!
|
||||
File file = null;
|
||||
String filePath = FileUtil.pathCombine(System.getProperty("user.dir"), filename);
|
||||
String filePath = FileUtil.pathCombine(System.getProperty("user.dir"), filename);
|
||||
if (FileUtil.doesFileExist(filePath)) {
|
||||
file = new File(filePath);
|
||||
file = new File(filePath);
|
||||
}
|
||||
return file;
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,26 +107,26 @@ public final class HelpMenu {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
||||
String cmd = "rundll32 url.dll,FileProtocolHandler " + file.getCanonicalPath();
|
||||
Runtime.getRuntime().exec(cmd);
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
Desktop.getDesktop().open(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static JMenuItem getMenuItem_UrlLink(String caption, String url) {
|
||||
JMenuItem menuItem = new JMenuItem(caption);
|
||||
menuItem.addActionListener(getLaunchUrlAction(url));
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
|
||||
private static ActionListener getLaunchUrlAction(final String url) {
|
||||
return new ActionListener() {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MenuUtil.openUrlInBrowser(url);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user