diff --git a/src/main/java/nl/andrewlalis/blockbookbinder/control/export/BookExporter.java b/src/main/java/nl/andrewlalis/blockbookbinder/control/export/BookExporter.java index 1444376..0143e8d 100644 --- a/src/main/java/nl/andrewlalis/blockbookbinder/control/export/BookExporter.java +++ b/src/main/java/nl/andrewlalis/blockbookbinder/control/export/BookExporter.java @@ -26,7 +26,7 @@ import java.util.logging.Logger; * into one's clipboard and pasting the pages. */ public class BookExporter implements Runnable { - private final static int START_DELAY = 10; + private final static int START_DELAY = 5; private final static int CLIPBOARD_RETRY_DELAY_MS = 100; private final Book book; @@ -48,8 +48,8 @@ public class BookExporter implements Runnable { // Some sound clips to play as user feedback. private final Clip beepClip; - private final Clip beginningExportClip; - private final Clip finishClip; +// private final Clip beginningExportClip; +// private final Clip finishClip; public BookExporter(ExportToBookDialog dialog, ExportStatusPanel exportStatusPanel, Book book, boolean autoPaste, int autoPasteDelay) { this.dialog = dialog; @@ -58,8 +58,8 @@ public class BookExporter implements Runnable { this.autoPaste = autoPaste; this.autoPasteDelay = autoPasteDelay; this.beepClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.beep_sound")); - this.beginningExportClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.beginning_export")); - this.finishClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.finish_sound")); +// this.beginningExportClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.beginning_export")); +// this.finishClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.finish_sound")); this.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); this.exporterKeyListener = new ExporterKeyListener(this); if (this.autoPaste) { // Only initialize the robot if we'll need it. @@ -97,7 +97,7 @@ public class BookExporter implements Runnable { this.initStatusPanel(); this.updateStatusLabel("Exporting."); this.initNativeListener(); - this.playAudioClip(this.beginningExportClip); +// this.playAudioClip(this.beginningExportClip); } this.exportPageToClipboard(nextPageToExport); if (this.autoPaste) { @@ -109,7 +109,7 @@ public class BookExporter implements Runnable { this.updateStatusProgressBar(nextPageToExport); // If we've reached the end of the book, stop the exporter. if (nextPageToExport >= this.book.getPageCount()) { - this.playAudioClip(this.finishClip); +// this.playAudioClip(this.finishClip); this.addStatusMessage("Export finished: " + this.book.getPageCount() + " pages exported."); if (!this.autoPaste) { this.stopNativeListener(); diff --git a/src/main/java/nl/andrewlalis/blockbookbinder/view/book/BookPreviewPanel.java b/src/main/java/nl/andrewlalis/blockbookbinder/view/book/BookPreviewPanel.java index 4165afb..7597f6a 100644 --- a/src/main/java/nl/andrewlalis/blockbookbinder/view/book/BookPreviewPanel.java +++ b/src/main/java/nl/andrewlalis/blockbookbinder/view/book/BookPreviewPanel.java @@ -27,6 +27,9 @@ public class BookPreviewPanel extends JPanel { private final JButton firstPageButton; private final JButton lastPageButton; + private final SpinnerNumberModel currentPageNumberModel; + private boolean ignoreCurrentPageChange = false; + public BookPreviewPanel() { super(new BorderLayout()); @@ -51,10 +54,12 @@ public class BookPreviewPanel extends JPanel { this.add(previewPageScrollPane, BorderLayout.CENTER); JPanel previewButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + currentPageNumberModel = new SpinnerNumberModel(0, 0, 0, 1); this.firstPageButton = new JButton(); this.firstPageButton.setIcon(IconLoader.load("images/page_first.png", 16, 16)); this.firstPageButton.addActionListener(e -> { this.currentPage = 0; + updateCurrentPageModel(); displayCurrentPage(); }); @@ -63,6 +68,7 @@ public class BookPreviewPanel extends JPanel { this.previousPageButton.addActionListener(e -> { if (currentPage > 0) { currentPage--; + updateCurrentPageModel(); displayCurrentPage(); } }); @@ -72,6 +78,7 @@ public class BookPreviewPanel extends JPanel { this.nextPageButton.addActionListener(e -> { if (currentPage < book.getPageCount() - 1) { currentPage++; + updateCurrentPageModel(); displayCurrentPage(); } }); @@ -79,11 +86,21 @@ public class BookPreviewPanel extends JPanel { this.lastPageButton.setIcon(IconLoader.load("images/page_last.png", 16, 16)); this.lastPageButton.addActionListener(e -> { this.currentPage = Math.max(this.book.getPageCount() - 1, 0); + updateCurrentPageModel(); displayCurrentPage(); }); + JSpinner currentPageSpinner = new JSpinner(currentPageNumberModel); + currentPageSpinner.addChangeListener(e -> { + if (!ignoreCurrentPageChange) { + this.currentPage = (int) currentPageNumberModel.getValue() - 1; + displayCurrentPage(); + } + }); + previewButtonPanel.add(this.firstPageButton); previewButtonPanel.add(this.previousPageButton); + previewButtonPanel.add(currentPageSpinner); previewButtonPanel.add(this.nextPageButton); previewButtonPanel.add(this.lastPageButton); this.add(previewButtonPanel, BorderLayout.SOUTH); @@ -102,10 +119,27 @@ public class BookPreviewPanel extends JPanel { public void setBook(Book book) { this.book = book; + ignoreCurrentPageChange = true; + if (book.getPageCount() == 0) { + currentPageNumberModel.setMinimum(0); + currentPageNumberModel.setMaximum(0); + currentPageNumberModel.setValue(0); + } else { + currentPageNumberModel.setMinimum(1); + currentPageNumberModel.setMaximum(book.getPageCount()); + currentPageNumberModel.setValue(1); + } + ignoreCurrentPageChange = false; this.currentPage = 0; this.displayCurrentPage(); } + public void updateCurrentPageModel() { + ignoreCurrentPageChange = true; + currentPageNumberModel.setValue(currentPage + 1); + ignoreCurrentPageChange = false; + } + public void setCurrentPage(int page) { this.currentPage = page; this.displayCurrentPage(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 87e1343..d942ba5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,8 +16,8 @@ about_dialog.min_height=800 about_dialog.source=html/about.html # Settings for Minecraft book interaction. -book.max_pages=100 -book.page_max_lines=14 -book.page_max_width=113 -book.page_max_chars=255 +book.max_pages=50 +book.page_max_lines=11 +book.page_max_width=107 +book.page_max_chars=205 book.default_char_width=5