Skip to content

Commit b3fdc19

Browse files
authored
Merge pull request #5864 from kwvanderlinde/maintenance/5723-link-to-discord-in-help-menu
Add Discord link to the help menu
2 parents 4dd2597 + bf20786 commit b3fdc19

25 files changed

+54
-215
lines changed

src/main/java/net/rptools/maptool/client/AppActions.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,23 +3227,20 @@ protected final void executeAction() {
32273227

32283228
/** This class provides an action that displays a url from I18N */
32293229
public static class OpenUrlAction extends TranslatedClientAction {
3230+
private final String url;
32303231

3231-
public OpenUrlAction(String key) {
3232+
public OpenUrlAction(String key, String url, Icons icon) {
32323233
super(key);
3234+
this.url = url;
32333235

3234-
// The constructor method will load the "key", "key.accel", and "key.description".
3235-
// The value of "key" will be used as the menu text, the accelerator is not
3236-
// used,
3237-
// and the description will be the destination URL. Only the Help menu uses
3238-
// these objects and
3239-
// only the Help menu expects that field to be set...
3236+
// Show the URL as hover text.
3237+
putValue(Action.SHORT_DESCRIPTION, url);
3238+
putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(icon));
32403239
}
32413240

32423241
@Override
32433242
protected void executeAction() {
3244-
if (getValue(Action.SHORT_DESCRIPTION) != null) {
3245-
MapTool.showDocument((String) getValue(Action.SHORT_DESCRIPTION));
3246-
}
3243+
MapTool.showDocument(url);
32473244
}
32483245
}
32493246

src/main/java/net/rptools/maptool/client/ui/AppMenuBar.java

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,7 @@ protected JToggleButton createMinimizeButton(
356356
}
357357

358358
/**
359-
* Builds the help menu. This menu contains a block of special url items. These items are
360-
* populated from {@link I18N#getMatchingKeys}.
359+
* Builds the help menu. This menu contains a block of special url items.
361360
*
362361
* @return the help menu
363362
*/
@@ -367,42 +366,45 @@ protected JMenu createHelpMenu() {
367366
menu.add(new JMenuItem(AppActions.RESTORE_DEFAULT_IMAGES));
368367
menu.addSeparator();
369368

370-
// @formatter:off
371-
/*
372-
* This next line will retrieve all properties that match the regex, such as:
373-
* action.helpurl.01=http://rptools.net/?page=maptool
374-
* action.helpurl.02=http://forums.rptools.net/
375-
* The items are not returned from the method in any kind of order so they are alphabetized here so that their
376-
* display in the menu is predictable.
377-
*/
378-
// @formatter:on
379-
List<String> helpItems = I18N.getMatchingKeys("^action[.]helpurl[.]\\d+$");
380-
if (!helpItems.isEmpty()) {
381-
String[] helpArray = helpItems.toArray(new String[0]);
382-
Arrays.sort(helpArray);
383-
for (String key : helpArray) {
384-
OpenUrlAction temp = new AppActions.OpenUrlAction(key);
385-
switch (key) {
386-
case "action.helpurl.01" ->
387-
temp.putValue(
388-
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_DOCUMENTATION));
389-
case "action.helpurl.02" ->
390-
temp.putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_TUTORIALS));
391-
case "action.helpurl.03" ->
392-
temp.putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_FORUMS));
393-
case "action.helpurl.04" ->
394-
temp.putValue(
395-
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_NETWORK_SETUP));
396-
case "action.helpurl.05" ->
397-
temp.putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_SCRIPTING));
398-
case "action.helpurl.06" ->
399-
temp.putValue(
400-
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_FRAMEWORKS));
401-
}
402-
menu.add(new JMenuItem(temp));
403-
}
404-
menu.addSeparator();
405-
}
369+
menu.add(
370+
new JMenuItem(
371+
new OpenUrlAction(
372+
"action.helpurl.discord", "https://rptools.net/discord", Icons.MENU_DISCORD)));
373+
menu.add(
374+
new JMenuItem(
375+
new OpenUrlAction(
376+
"action.helpurl.01",
377+
"https://www.rptools.net/toolbox/maptool/",
378+
Icons.MENU_DOCUMENTATION)));
379+
menu.add(
380+
new JMenuItem(
381+
new OpenUrlAction(
382+
"action.helpurl.02", "https://www.rptools.net/tutorials/", Icons.MENU_TUTORIALS)));
383+
menu.add(
384+
new JMenuItem(
385+
new OpenUrlAction(
386+
"action.helpurl.03", "https://forums.rptools.net/", Icons.MENU_FORUMS)));
387+
menu.add(
388+
new JMenuItem(
389+
new OpenUrlAction(
390+
"action.helpurl.04",
391+
"http://forums.rptools.net/viewtopic.php?f=22&t=3370",
392+
Icons.MENU_NETWORK_SETUP)));
393+
menu.add(
394+
new JMenuItem(
395+
new OpenUrlAction(
396+
"action.helpurl.05",
397+
"https://wiki.rptools.info/index.php/Main_Page",
398+
Icons.MENU_SCRIPTING)));
399+
menu.add(
400+
new JMenuItem(
401+
new OpenUrlAction(
402+
"action.helpurl.06",
403+
"https://wiki.rptools.info/index.php/Frameworks",
404+
Icons.MENU_FRAMEWORKS)));
405+
406+
menu.addSeparator();
407+
406408
menu.add(new JMenuItem(AppActions.GATHER_DEBUG_INFO));
407409

408410
if (!OsDetection.MAC_OS_X) {

src/main/java/net/rptools/maptool/client/ui/startserverdialog/StartServerDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public StartServerDialog() {
6969
// We don't have a good, server-side way of testing anymore.
7070
boolean ok = MapTool.confirm("msg.info.server.networkingHelp");
7171
if (ok) {
72-
MapTool.showDocument(I18N.getString("msg.info.server.forumNFAQ_URL"));
72+
MapTool.showDocument("https://forums.rptools.net/viewtopic.php?f=22&t=3370");
7373
}
7474
})
7575
.addButton(

src/main/java/net/rptools/maptool/client/ui/theme/Icons.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public enum Icons {
8989
GRID_SQUARE,
9090
INITIATIVE_CURRENT_INDICATOR,
9191
MAPTOOL,
92+
MENU_DISCORD,
9293
MENU_DOCUMENTATION,
9394
MENU_FORUMS,
9495
MENU_FRAMEWORKS,

src/main/java/net/rptools/maptool/client/ui/theme/RessourceManager.java

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import com.formdev.flatlaf.extras.FlatSVGIcon;
1818
import java.awt.image.BufferedImage;
1919
import java.io.IOException;
20-
import java.nio.file.Files;
21-
import java.nio.file.Path;
2220
import java.util.HashMap;
2321
import java.util.TreeSet;
2422
import javax.swing.*;
@@ -129,6 +127,7 @@ public class RessourceManager {
129127
put(Icons.GRID_SQUARE, IMAGE_DIR + "gridSquare.png");
130128
put(Icons.INITIATIVE_CURRENT_INDICATOR, IMAGE_DIR + "currentIndicator.png");
131129
put(Icons.MAPTOOL, IMAGE_DIR + "maptool_icon.png");
130+
put(Icons.MENU_DISCORD, IMAGE_DIR + "discord.svg");
132131
put(Icons.MENU_DOCUMENTATION, IMAGE_DIR + "book_open.png");
133132
put(Icons.MENU_FORUMS, IMAGE_DIR + "marker.png");
134133
put(Icons.MENU_FRAMEWORKS, IMAGE_DIR + "minilogo.png");
@@ -363,6 +362,7 @@ public class RessourceManager {
363362
put(Icons.GRID_NONE, ROD_ICONS + "cross.svg");
364363
put(Icons.GRID_SQUARE, ROD_ICONS + "gridSquare.svg");
365364
put(Icons.MAPTOOL, ROD_ICONS + "maptool_icon.svg");
365+
put(Icons.MENU_DISCORD, ROD_ICONS + "menu/Discord.svg");
366366
put(Icons.MENU_DOCUMENTATION, ROD_ICONS + "menu/Documentation.svg");
367367
put(Icons.MENU_FORUMS, ROD_ICONS + "menu/Forums.svg");
368368
put(Icons.MENU_FRAMEWORKS, ROD_ICONS + "menu/Frameworks.svg");
@@ -619,42 +619,4 @@ private static void checkMissingIcons(
619619
System.out.println(key + " classic: " + classicIcons.get(key));
620620
}
621621
}
622-
623-
public static void checkMissingFiles() {
624-
String basedir = "C:\\Users\\tkunze\\Source\\maptool\\src\\main\\resources\\";
625-
for (String value : images.values()) {
626-
if (value == null) {
627-
continue;
628-
}
629-
630-
var source = Path.of(basedir, value);
631-
var target = Path.of(basedir, IMAGE_DIR, "images", source.getFileName().toString());
632-
633-
if (Files.notExists(source)) {
634-
System.out.println(value + " is missing!");
635-
}
636-
}
637-
for (String value : classicIcons.values()) {
638-
if (value == null) {
639-
continue;
640-
}
641-
642-
var source = Path.of(basedir, value);
643-
644-
if (Files.notExists(source)) {
645-
System.out.println(value + " is missing!");
646-
}
647-
}
648-
for (String value : rodIcons.values()) {
649-
if (value == null) {
650-
continue;
651-
}
652-
653-
var source = Path.of(basedir, value);
654-
655-
if (Files.notExists(source)) {
656-
System.out.println(value + " is missing!");
657-
}
658-
}
659-
}
660622
}
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

src/main/resources/net/rptools/maptool/language/i18n.properties

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,18 +1499,13 @@ action.gridLineWight = Grid &Line Weight
14991499
# action.url.##.description which contains the url to load when the action is
15001500
# executed. The last key is action.url.##.icon which contains the image embedded
15011501
# inside the MapTool JAR file which appears on the menu item.
1502+
action.helpurl.discord = Discord
15021503
action.helpurl.01 = Documentation
1503-
action.helpurl.01.description = https://www.rptools.net/toolbox/maptool/
15041504
action.helpurl.02 = Tutorials
1505-
action.helpurl.02.description = https://www.rptools.net/tutorials/
15061505
action.helpurl.03 = Forums
1507-
action.helpurl.03.description = http://forums.rptools.net/
15081506
action.helpurl.04 = Networking Setup (forum thread)
1509-
action.helpurl.04.description = http://forums.rptools.net/viewtopic.php?f=22&t=3370
15101507
action.helpurl.05 = Macro Scripting
1511-
action.helpurl.05.description=https://wiki.rptools.info/index.php/Main_Page
15121508
action.helpurl.06 = Frameworks
1513-
action.helpurl.06.description = https\://wiki.rptools.info/index.php/Frameworks
15141509
action.toggleLandingMap = &Landing map
15151510
action.toggleLandingMap.description = Make this map the first one that players see when they connect.
15161511
action.hideMap = &Player Visible
@@ -2530,7 +2525,6 @@ msg.info.restoreLayout = Restore layout
25302525
msg.info.restoreLayout.description = Restore the MapTool user interface to the default layout.
25312526
msg.info.screenshotSaved = Saved screenshot.
25322527
msg.info.screenshotSaving = Saving screenshot...
2533-
msg.info.server.forumNFAQ_URL = http://forums.rptools.net/viewtopic.php?f=22&t=3370
25342528
msg.info.server.networkingHelp = <html>Hosting a MapTool server involves proper network setup.<br>Do you want to visit the forum post that describes this process?
25352529
msg.info.showTransferWindow = Show Transfer Window
25362530
msg.info.showTransferWindow.description = Open a window showing the pending asset transfers.

src/main/resources/net/rptools/maptool/language/i18n_cs_CZ.properties

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,17 +1289,11 @@ action.gridLineWight = Grid &Line Weight
12891289
# executed. The last key is action.url.##.icon which contains the image embedded
12901290
# inside the MapTool JAR file which appears on the menu item.
12911291
action.helpurl.01 = Documentation
1292-
action.helpurl.01.description = https\://www.rptools.net/toolbox/maptool/
12931292
action.helpurl.02 = Tutorials
1294-
action.helpurl.02.description = https\://www.rptools.net/tutorials/
12951293
action.helpurl.03 = Forums
1296-
action.helpurl.03.description = http\://forums.rptools.net/
12971294
action.helpurl.04 = Networking Setup (forum thread)
1298-
action.helpurl.04.description = http\://forums.rptools.net/viewtopic.php?f\=22&t\=3370
12991295
action.helpurl.05 = Macro Scripting
1300-
action.helpurl.05.description=https\://wiki.rptools.info/index.php/Main_Page
13011296
action.helpurl.06 = Frameworks
1302-
action.helpurl.06.description = https\://wiki.rptools.info/index.php/Frameworks
13031297
action.toggleLandingMap = &Landing map
13041298
action.toggleLandingMap.description = Make this map the first one that players see when they connect.
13051299
action.hideMap = &Player Visible
@@ -2289,7 +2283,6 @@ msg.info.restoreLayout = Restore layout
22892283
msg.info.restoreLayout.description = Restore the MapTool user interface to the default layout.
22902284
msg.info.screenshotSaved = Saved screenshot.
22912285
msg.info.screenshotSaving = Saving screenshot...
2292-
msg.info.server.forumNFAQ_URL = http\://forums.rptools.net/viewtopic.php?f\=22&t\=3370
22932286
msg.info.server.networkingHelp = <html>Hosting a MapTool server involves proper network setup.<br>Do you want to visit the forum post that describes this process?
22942287
msg.info.showTransferWindow = Show Transfer Window
22952288
msg.info.showTransferWindow.description = Open a window showing the pending asset transfers.

src/main/resources/net/rptools/maptool/language/i18n_da_DK.properties

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,17 +1289,11 @@ action.gridLineWight = Grid &Line Weight
12891289
# executed. The last key is action.url.##.icon which contains the image embedded
12901290
# inside the MapTool JAR file which appears on the menu item.
12911291
action.helpurl.01 = Dokumentation
1292-
action.helpurl.01.description = https\://www.rptools.net/toolbox/maptool/
12931292
action.helpurl.02 = Vejledninger
1294-
action.helpurl.02.description = https\://www.rptools.net/tutorials/
12951293
action.helpurl.03 = Fora
1296-
action.helpurl.03.description = http\://forums.rptools.net/
12971294
action.helpurl.04 = Networking Setup (forum thread)
1298-
action.helpurl.04.description = http\://forums.rptools.net/viewtopic.php?f\=22&t\=3370
12991295
action.helpurl.05 = Makro scripting
1300-
action.helpurl.05.description=https\://wiki.rptools.info/index.php/Main_Page
13011296
action.helpurl.06 = Rammeværktøjer
1302-
action.helpurl.06.description = https\://wiki.rptools.info/index.php/Frameworks
13031297
action.toggleLandingMap = &Landing map
13041298
action.toggleLandingMap.description = Make this map the first one that players see when they connect.
13051299
action.hideMap = S&piller synlig
@@ -2289,7 +2283,6 @@ msg.info.restoreLayout = Gendan layout
22892283
msg.info.restoreLayout.description = Restore the MapTool user interface to the default layout.
22902284
msg.info.screenshotSaved = Gemte skærmbillede.
22912285
msg.info.screenshotSaving = Gemmer skærmbillede...
2292-
msg.info.server.forumNFAQ_URL = http\://forums.rptools.net/viewtopic.php?f\=22&t\=3370
22932286
msg.info.server.networkingHelp = <html>Hosting a MapTool server involves proper network setup.<br>Do you want to visit the forum post that describes this process?
22942287
msg.info.showTransferWindow = Vis overførselsvindue
22952288
msg.info.showTransferWindow.description = Open a window showing the pending asset transfers.

0 commit comments

Comments
 (0)