From 0e634069b2efcb7e068b9e18f31cf1c4538ea5cd Mon Sep 17 00:00:00 2001 From: vinceh121 Date: Tue, 3 Oct 2023 02:14:11 +0200 Subject: [PATCH] feat: about dialog --- .../wanderer/launcher/AboutDialog.java | 39 +++++++++++++++++++ .../InstallationInformationDialog.java | 4 +- .../wanderer/launcher/LauncherFrame.java | 4 ++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 launcher/src/me/vinceh121/wanderer/launcher/AboutDialog.java diff --git a/launcher/src/me/vinceh121/wanderer/launcher/AboutDialog.java b/launcher/src/me/vinceh121/wanderer/launcher/AboutDialog.java new file mode 100644 index 0000000..0836f5e --- /dev/null +++ b/launcher/src/me/vinceh121/wanderer/launcher/AboutDialog.java @@ -0,0 +1,39 @@ +package me.vinceh121.wanderer.launcher; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URISyntaxException; + +import javax.swing.JDialog; +import javax.swing.JEditorPane; +import javax.swing.event.HyperlinkEvent.EventType; + +public class AboutDialog extends JDialog { + private static final long serialVersionUID = 1L; + + public AboutDialog() { + this.setTitle("About Wanderer"); + + final JEditorPane txt = new JEditorPane(); + txt.setEditable(false); + txt.addHyperlinkListener(e -> { + try { + if (e.getEventType() == EventType.ACTIVATED) { + Desktop.getDesktop().browse(e.getURL().toURI()); + } + } catch (IOException | URISyntaxException e1) { + e1.printStackTrace(); + } + }); + txt.setContentType("text/html"); + txt.setText( + "

Wanderer

" + "

A reimplementation of the 2002 video game Project Nomads by Radon Labs

" + + "

Source code

" + + "

Licensed under the GNU AGPL V3

"); + + this.add(txt); + + this.pack(); + this.setLocationRelativeTo(null); + } +} diff --git a/launcher/src/me/vinceh121/wanderer/launcher/InstallationInformationDialog.java b/launcher/src/me/vinceh121/wanderer/launcher/InstallationInformationDialog.java index 975d249..3a762d5 100644 --- a/launcher/src/me/vinceh121/wanderer/launcher/InstallationInformationDialog.java +++ b/launcher/src/me/vinceh121/wanderer/launcher/InstallationInformationDialog.java @@ -50,7 +50,7 @@ public InstallationInformationDialog() throws StreamReadException, DatabindExcep final JLabel lblVoiceLang = new JLabel("Voice languages"); lblVoiceLang.setFont(lblVoiceLang.getFont().deriveFont(Font.BOLD, 16)); this.add(lblVoiceLang); - + for (final Locale a : available) { final JCheckBox chkbx = new JCheckBox(); chkbx.setEnabled(false); @@ -60,6 +60,8 @@ public InstallationInformationDialog() throws StreamReadException, DatabindExcep this.add(chkbx); } + this.setTitle("Installation languages"); this.pack(); + this.setLocationRelativeTo(null); } } diff --git a/launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java b/launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java index ce9d56a..3013be9 100644 --- a/launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java +++ b/launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java @@ -58,6 +58,10 @@ public void windowClosing(final WindowEvent e) { } }); mnHelp.add(mntInstallDetails); + + JMenuItem mntAbout = new JMenuItem("About"); + mntAbout.addActionListener(e -> new AboutDialog().setVisible(true)); + mnHelp.add(mntAbout); } private void onClose() {