Added nice about page.
This commit is contained in:
parent
6da3127427
commit
53122afcf5
|
@ -3,6 +3,7 @@ package nl.andrewlalis.blockbookbinder.view;
|
||||||
import nl.andrewlalis.blockbookbinder.control.ImportAction;
|
import nl.andrewlalis.blockbookbinder.control.ImportAction;
|
||||||
import nl.andrewlalis.blockbookbinder.model.Book;
|
import nl.andrewlalis.blockbookbinder.model.Book;
|
||||||
import nl.andrewlalis.blockbookbinder.util.ApplicationProperties;
|
import nl.andrewlalis.blockbookbinder.util.ApplicationProperties;
|
||||||
|
import nl.andrewlalis.blockbookbinder.view.about.AboutDialog;
|
||||||
import nl.andrewlalis.blockbookbinder.view.export.ExportToBookDialog;
|
import nl.andrewlalis.blockbookbinder.view.export.ExportToBookDialog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -13,7 +14,6 @@ import java.net.URL;
|
||||||
* The main window of the application.
|
* The main window of the application.
|
||||||
*/
|
*/
|
||||||
public class MainFrame extends JFrame {
|
public class MainFrame extends JFrame {
|
||||||
private Action importAction;
|
|
||||||
|
|
||||||
public void setupAndShow() {
|
public void setupAndShow() {
|
||||||
final int width = Integer.parseInt(ApplicationProperties.getProp("frame.default_width"));
|
final int width = Integer.parseInt(ApplicationProperties.getProp("frame.default_width"));
|
||||||
|
@ -26,7 +26,6 @@ public class MainFrame extends JFrame {
|
||||||
this.setIconImage(new ImageIcon(iconUrl).getImage());
|
this.setIconImage(new ImageIcon(iconUrl).getImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initActions();
|
|
||||||
this.setContentPane(this.buildContentPane());
|
this.setContentPane(this.buildContentPane());
|
||||||
this.setJMenuBar(this.buildMenuBar());
|
this.setJMenuBar(this.buildMenuBar());
|
||||||
|
|
||||||
|
@ -35,19 +34,21 @@ public class MainFrame extends JFrame {
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initActions() {
|
|
||||||
this.importAction = new ImportAction("Import");
|
|
||||||
}
|
|
||||||
|
|
||||||
private JMenuBar buildMenuBar() {
|
private JMenuBar buildMenuBar() {
|
||||||
JMenuBar menuBar = new JMenuBar();
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
|
||||||
JMenu fileMenu = new JMenu("File");
|
JMenu fileMenu = new JMenu("File");
|
||||||
fileMenu.add(new JMenuItem(this.importAction));
|
JMenuItem exitItem = new JMenuItem("Exit");
|
||||||
|
exitItem.addActionListener(e -> this.dispose());
|
||||||
|
fileMenu.add(exitItem);
|
||||||
menuBar.add(fileMenu);
|
menuBar.add(fileMenu);
|
||||||
|
|
||||||
JMenu helpMenu = new JMenu("Help");
|
JMenu helpMenu = new JMenu("Help");
|
||||||
JMenuItem aboutItem = new JMenuItem("About");
|
JMenuItem aboutItem = new JMenuItem("About");
|
||||||
|
aboutItem.addActionListener(e -> {
|
||||||
|
AboutDialog dialog = new AboutDialog(this);
|
||||||
|
dialog.setupAndShow();
|
||||||
|
});
|
||||||
helpMenu.add(aboutItem);
|
helpMenu.add(aboutItem);
|
||||||
menuBar.add(helpMenu);
|
menuBar.add(helpMenu);
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,6 @@ import nl.andrewlalis.blockbookbinder.control.ConvertToBookActionListener;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A panel dedicated to displaying an interacting with a raw source of text for
|
* A panel dedicated to displaying an interacting with a raw source of text for
|
||||||
|
@ -32,9 +28,6 @@ public class SourceTextPanel extends JPanel {
|
||||||
|
|
||||||
JPanel rightPanelButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel rightPanelButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
this.add(rightPanelButtonPanel, BorderLayout.SOUTH);
|
this.add(rightPanelButtonPanel, BorderLayout.SOUTH);
|
||||||
JButton importButton = new JButton("Import");
|
|
||||||
importButton.setActionCommand("importSource");
|
|
||||||
rightPanelButtonPanel.add(importButton);
|
|
||||||
|
|
||||||
JButton convertButton = new JButton("Convert to Book");
|
JButton convertButton = new JButton("Convert to Book");
|
||||||
convertButton.addActionListener(new ConvertToBookActionListener(this, bookPreviewPanel));
|
convertButton.addActionListener(new ConvertToBookActionListener(this, bookPreviewPanel));
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package nl.andrewlalis.blockbookbinder.view.about;
|
||||||
|
|
||||||
|
import nl.andrewlalis.blockbookbinder.util.ApplicationProperties;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.HyperlinkEvent;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple dialog whose main purpose is rendering an HTML document.
|
||||||
|
*/
|
||||||
|
public class AboutDialog extends JDialog {
|
||||||
|
public AboutDialog(Frame owner) {
|
||||||
|
super(owner, "About", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupAndShow() {
|
||||||
|
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
this.setPreferredSize(new Dimension(
|
||||||
|
ApplicationProperties.getIntProp("about_dialog.min_width"),
|
||||||
|
ApplicationProperties.getIntProp("about_dialog.min_height")
|
||||||
|
));
|
||||||
|
JTextPane textPane = new JTextPane();
|
||||||
|
textPane.setEditable(false);
|
||||||
|
textPane.setContentType("text/html");
|
||||||
|
textPane.setText(this.getAboutHtml());
|
||||||
|
textPane.addHyperlinkListener(e -> {
|
||||||
|
try {
|
||||||
|
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||||
|
Desktop.getDesktop().browse(e.getURL().toURI());
|
||||||
|
}
|
||||||
|
} catch (URISyntaxException | IOException uriSyntaxException) {
|
||||||
|
uriSyntaxException.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
JScrollPane scrollPane = new JScrollPane(
|
||||||
|
textPane,
|
||||||
|
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
|
||||||
|
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
|
||||||
|
);
|
||||||
|
this.setContentPane(scrollPane);
|
||||||
|
this.pack();
|
||||||
|
this.setLocationRelativeTo(this.getOwner());
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getAboutHtml() {
|
||||||
|
InputStream is = this.getClass().getClassLoader().getResourceAsStream(
|
||||||
|
ApplicationProperties.getProp("about_dialog.source")
|
||||||
|
);
|
||||||
|
if (is == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return new BufferedReader(new InputStreamReader(is)).lines()
|
||||||
|
.parallel().collect(Collectors.joining("\n"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,7 +44,7 @@ public class ExportToBookDialog extends JDialog {
|
||||||
ApplicationProperties.getIntProp("export_dialog.min_height")
|
ApplicationProperties.getIntProp("export_dialog.min_height")
|
||||||
));
|
));
|
||||||
this.pack();
|
this.pack();
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(this.getOwner());
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,10 @@ export_dialog.min_height=300
|
||||||
export_dialog.beep_sound=sound/andrew_beep.wav
|
export_dialog.beep_sound=sound/andrew_beep.wav
|
||||||
export_dialog.beginning_export=sound/beginning_export.wav
|
export_dialog.beginning_export=sound/beginning_export.wav
|
||||||
|
|
||||||
|
about_dialog.min_width=600
|
||||||
|
about_dialog.min_height=800
|
||||||
|
about_dialog.source=html/about.html
|
||||||
|
|
||||||
# Settings for Minecraft book interaction.
|
# Settings for Minecraft book interaction.
|
||||||
book.max_pages=100
|
book.max_pages=100
|
||||||
book.page_max_lines=14
|
book.page_max_lines=14
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>About</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>About BlockBookBinder</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The <em>BlockBookBinder</em> is a simple application that gives you the power to write books faster than ever before! All you need to do is copy and paste some text into the <em>Source</em> panel on the right-hand side of the application, and click <strong>Convert to Book</strong>. Your text will be transformed so that it can fit onto written books in Minecraft, and you can preview the book in the <em>Book Preview</em> panel on the left-hand side of the application, using the navigation buttons below.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><em>
|
||||||
|
Note that your text might benefit from the <strong>Clean</strong> functionality, where extra new-line and other unnecessary whitespace characters are removed so that the text can be better compressed into Minecraft's limited format.
|
||||||
|
</em></p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Once you've prepared a book and you want to actually copy it into Minecraft, click on <strong>Export to Book</strong>. This will open up a popup with a few different buttons:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><strong>Auto-paste</strong>: When checked, the program will automatically press CTRL+V and click your mouse to insert pages into the book, so that you don't need to do anything. If you select this, don't forget to move your mouse so that it's hovering over the <em>next page</em> button in Minecraft, otherwise auto-pasting won't work properly.</li>
|
||||||
|
<li><strong>First Page & Last Page</strong>: These inputs allow you to select the range of pages to export. Because Minecraft written books are limited to <strong>100</strong> pages only, this range cannot exceed that amount. Both the first and last page are included in the range.</li>
|
||||||
|
<li><strong>Auto-Paste Delay</strong>: The amount of time, in seconds, to wait between the various actions required for auto-pasting. If your server is experiencing a lot of lag, consider bumping this up to at least 1 second. The default value should be fine for most cases, though.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
After setting any options that you want to, go ahead and press <strong>Start</strong>, and navigate back to your Minecraft window. You should hear ten <em>beep</em> sounds before exporting begins. If you selected auto-paste, you must make sure your mouse is hovering over the <em>next page</em> button in your written book before the ten seconds are up.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Once those first ten seconds pass, the first page will be loaded into your clipboard, and if auto-paste is enabled, automatically pasted into the book in your game. If auto-paste is not enabled, you'll need to manually paste each page, and then turn to the next page. You can see your progress in the popup, along with any important status updates as exporting progresses.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
When all pages have been exported, you'll be prompted with a little popup, after which the export popup closes and you have the option to export again, or simply close the application if you're done.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This program was written by Andrew Lalis. The source code is available on GitHub <a target="_blank" href="https://github.com/andrewlalis/BlockBookBinder">here</a>. It is copyrighted with the MIT license, which means you can do whatever you want with it, so long as you keep the included copyright notice in any copies or modifications of the program.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue