Added 1.12.2 version with some changes.
This commit is contained in:
		
							parent
							
								
									deb10b1099
								
							
						
					
					
						commit
						67915ffdf1
					
				| 
						 | 
					@ -26,7 +26,7 @@ import java.util.logging.Logger;
 | 
				
			||||||
 * into one's clipboard and pasting the pages.
 | 
					 * into one's clipboard and pasting the pages.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class BookExporter implements Runnable {
 | 
					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 static int CLIPBOARD_RETRY_DELAY_MS = 100;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private final Book book;
 | 
						private final Book book;
 | 
				
			||||||
| 
						 | 
					@ -48,8 +48,8 @@ public class BookExporter implements Runnable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Some sound clips to play as user feedback.
 | 
						// Some sound clips to play as user feedback.
 | 
				
			||||||
	private final Clip beepClip;
 | 
						private final Clip beepClip;
 | 
				
			||||||
	private final Clip beginningExportClip;
 | 
					//	private final Clip beginningExportClip;
 | 
				
			||||||
	private final Clip finishClip;
 | 
					//	private final Clip finishClip;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public BookExporter(ExportToBookDialog dialog, ExportStatusPanel exportStatusPanel, Book book, boolean autoPaste, int autoPasteDelay) {
 | 
						public BookExporter(ExportToBookDialog dialog, ExportStatusPanel exportStatusPanel, Book book, boolean autoPaste, int autoPasteDelay) {
 | 
				
			||||||
		this.dialog = dialog;
 | 
							this.dialog = dialog;
 | 
				
			||||||
| 
						 | 
					@ -58,8 +58,8 @@ public class BookExporter implements Runnable {
 | 
				
			||||||
		this.autoPaste = autoPaste;
 | 
							this.autoPaste = autoPaste;
 | 
				
			||||||
		this.autoPasteDelay = autoPasteDelay;
 | 
							this.autoPasteDelay = autoPasteDelay;
 | 
				
			||||||
		this.beepClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.beep_sound"));
 | 
							this.beepClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.beep_sound"));
 | 
				
			||||||
		this.beginningExportClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.beginning_export"));
 | 
					//		this.beginningExportClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.beginning_export"));
 | 
				
			||||||
		this.finishClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.finish_sound"));
 | 
					//		this.finishClip = this.loadAudioClip(ApplicationProperties.getProp("export_dialog.finish_sound"));
 | 
				
			||||||
		this.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
 | 
							this.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
 | 
				
			||||||
		this.exporterKeyListener = new ExporterKeyListener(this);
 | 
							this.exporterKeyListener = new ExporterKeyListener(this);
 | 
				
			||||||
		if (this.autoPaste) { // Only initialize the robot if we'll need it.
 | 
							if (this.autoPaste) { // Only initialize the robot if we'll need it.
 | 
				
			||||||
| 
						 | 
					@ -97,7 +97,7 @@ public class BookExporter implements Runnable {
 | 
				
			||||||
					this.initStatusPanel();
 | 
										this.initStatusPanel();
 | 
				
			||||||
					this.updateStatusLabel("Exporting.");
 | 
										this.updateStatusLabel("Exporting.");
 | 
				
			||||||
					this.initNativeListener();
 | 
										this.initNativeListener();
 | 
				
			||||||
					this.playAudioClip(this.beginningExportClip);
 | 
					//					this.playAudioClip(this.beginningExportClip);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				this.exportPageToClipboard(nextPageToExport);
 | 
									this.exportPageToClipboard(nextPageToExport);
 | 
				
			||||||
				if (this.autoPaste) {
 | 
									if (this.autoPaste) {
 | 
				
			||||||
| 
						 | 
					@ -109,7 +109,7 @@ public class BookExporter implements Runnable {
 | 
				
			||||||
				this.updateStatusProgressBar(nextPageToExport);
 | 
									this.updateStatusProgressBar(nextPageToExport);
 | 
				
			||||||
				// If we've reached the end of the book, stop the exporter.
 | 
									// If we've reached the end of the book, stop the exporter.
 | 
				
			||||||
				if (nextPageToExport >= this.book.getPageCount()) {
 | 
									if (nextPageToExport >= this.book.getPageCount()) {
 | 
				
			||||||
					this.playAudioClip(this.finishClip);
 | 
					//					this.playAudioClip(this.finishClip);
 | 
				
			||||||
					this.addStatusMessage("Export finished: " + this.book.getPageCount() + " pages exported.");
 | 
										this.addStatusMessage("Export finished: " + this.book.getPageCount() + " pages exported.");
 | 
				
			||||||
					if (!this.autoPaste) {
 | 
										if (!this.autoPaste) {
 | 
				
			||||||
						this.stopNativeListener();
 | 
											this.stopNativeListener();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,6 +27,9 @@ public class BookPreviewPanel extends JPanel {
 | 
				
			||||||
	private final JButton firstPageButton;
 | 
						private final JButton firstPageButton;
 | 
				
			||||||
	private final JButton lastPageButton;
 | 
						private final JButton lastPageButton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private final SpinnerNumberModel currentPageNumberModel;
 | 
				
			||||||
 | 
						private boolean ignoreCurrentPageChange = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public BookPreviewPanel() {
 | 
						public BookPreviewPanel() {
 | 
				
			||||||
		super(new BorderLayout());
 | 
							super(new BorderLayout());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,10 +54,12 @@ public class BookPreviewPanel extends JPanel {
 | 
				
			||||||
		this.add(previewPageScrollPane, BorderLayout.CENTER);
 | 
							this.add(previewPageScrollPane, BorderLayout.CENTER);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		JPanel previewButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
 | 
							JPanel previewButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
 | 
				
			||||||
 | 
							currentPageNumberModel = new SpinnerNumberModel(0, 0, 0, 1);
 | 
				
			||||||
		this.firstPageButton = new JButton();
 | 
							this.firstPageButton = new JButton();
 | 
				
			||||||
		this.firstPageButton.setIcon(IconLoader.load("images/page_first.png", 16, 16));
 | 
							this.firstPageButton.setIcon(IconLoader.load("images/page_first.png", 16, 16));
 | 
				
			||||||
		this.firstPageButton.addActionListener(e -> {
 | 
							this.firstPageButton.addActionListener(e -> {
 | 
				
			||||||
			this.currentPage = 0;
 | 
								this.currentPage = 0;
 | 
				
			||||||
 | 
								updateCurrentPageModel();
 | 
				
			||||||
			displayCurrentPage();
 | 
								displayCurrentPage();
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,6 +68,7 @@ public class BookPreviewPanel extends JPanel {
 | 
				
			||||||
		this.previousPageButton.addActionListener(e -> {
 | 
							this.previousPageButton.addActionListener(e -> {
 | 
				
			||||||
			if (currentPage > 0) {
 | 
								if (currentPage > 0) {
 | 
				
			||||||
				currentPage--;
 | 
									currentPage--;
 | 
				
			||||||
 | 
									updateCurrentPageModel();
 | 
				
			||||||
				displayCurrentPage();
 | 
									displayCurrentPage();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
| 
						 | 
					@ -72,6 +78,7 @@ public class BookPreviewPanel extends JPanel {
 | 
				
			||||||
		this.nextPageButton.addActionListener(e -> {
 | 
							this.nextPageButton.addActionListener(e -> {
 | 
				
			||||||
			if (currentPage < book.getPageCount() - 1) {
 | 
								if (currentPage < book.getPageCount() - 1) {
 | 
				
			||||||
				currentPage++;
 | 
									currentPage++;
 | 
				
			||||||
 | 
									updateCurrentPageModel();
 | 
				
			||||||
				displayCurrentPage();
 | 
									displayCurrentPage();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
| 
						 | 
					@ -79,11 +86,21 @@ public class BookPreviewPanel extends JPanel {
 | 
				
			||||||
		this.lastPageButton.setIcon(IconLoader.load("images/page_last.png", 16, 16));
 | 
							this.lastPageButton.setIcon(IconLoader.load("images/page_last.png", 16, 16));
 | 
				
			||||||
		this.lastPageButton.addActionListener(e -> {
 | 
							this.lastPageButton.addActionListener(e -> {
 | 
				
			||||||
			this.currentPage = Math.max(this.book.getPageCount() - 1, 0);
 | 
								this.currentPage = Math.max(this.book.getPageCount() - 1, 0);
 | 
				
			||||||
 | 
								updateCurrentPageModel();
 | 
				
			||||||
			displayCurrentPage();
 | 
								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.firstPageButton);
 | 
				
			||||||
		previewButtonPanel.add(this.previousPageButton);
 | 
							previewButtonPanel.add(this.previousPageButton);
 | 
				
			||||||
 | 
							previewButtonPanel.add(currentPageSpinner);
 | 
				
			||||||
		previewButtonPanel.add(this.nextPageButton);
 | 
							previewButtonPanel.add(this.nextPageButton);
 | 
				
			||||||
		previewButtonPanel.add(this.lastPageButton);
 | 
							previewButtonPanel.add(this.lastPageButton);
 | 
				
			||||||
		this.add(previewButtonPanel, BorderLayout.SOUTH);
 | 
							this.add(previewButtonPanel, BorderLayout.SOUTH);
 | 
				
			||||||
| 
						 | 
					@ -102,10 +119,27 @@ public class BookPreviewPanel extends JPanel {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setBook(Book book) {
 | 
						public void setBook(Book book) {
 | 
				
			||||||
		this.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.currentPage = 0;
 | 
				
			||||||
		this.displayCurrentPage();
 | 
							this.displayCurrentPage();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void updateCurrentPageModel() {
 | 
				
			||||||
 | 
							ignoreCurrentPageChange = true;
 | 
				
			||||||
 | 
							currentPageNumberModel.setValue(currentPage + 1);
 | 
				
			||||||
 | 
							ignoreCurrentPageChange = false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setCurrentPage(int page) {
 | 
						public void setCurrentPage(int page) {
 | 
				
			||||||
		this.currentPage = page;
 | 
							this.currentPage = page;
 | 
				
			||||||
		this.displayCurrentPage();
 | 
							this.displayCurrentPage();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,8 +16,8 @@ about_dialog.min_height=800
 | 
				
			||||||
about_dialog.source=html/about.html
 | 
					about_dialog.source=html/about.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Settings for Minecraft book interaction.
 | 
					# Settings for Minecraft book interaction.
 | 
				
			||||||
book.max_pages=100
 | 
					book.max_pages=50
 | 
				
			||||||
book.page_max_lines=14
 | 
					book.page_max_lines=11
 | 
				
			||||||
book.page_max_width=113
 | 
					book.page_max_width=107
 | 
				
			||||||
book.page_max_chars=255
 | 
					book.page_max_chars=205
 | 
				
			||||||
book.default_char_width=5
 | 
					book.default_char_width=5
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue