Skip to content

Commit 33d10b5

Browse files
Update comments, add page numbers to page breaks
1 parent f135f41 commit 33d10b5

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
1313
apply plugin: 'eclipse'
1414
apply plugin: 'maven-publish'
1515

16-
version = '2.1.4'
16+
version = '2.1.5'
1717
group = 'wafflestomper' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
1818
archivesBaseName = '1.16.1-Ghostwriter'
1919

src/main/java/wafflestomper/ghostwriter/BookUtilities.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import java.util.List;
1111

1212
public class BookUtilities {
13-
public static final int BOOK_TEXT_WIDTH = 116;
13+
public static final int BOOK_TEXT_WIDTH = 116; // TODO: I think the text width might be 114 pixels now
1414
public static final char SPLIT_CHAR = '\u1337';
1515
private static final Minecraft mc = Minecraft.getInstance();
1616

@@ -335,10 +335,13 @@ public static List<String> splitStringIntoLines(String str){
335335
return out;
336336
}
337337

338-
338+
339339
/**
340-
* Splits a monolithic string into a list of strings, each representing one
341-
* book page.
340+
* Splits a monolithic string into a list of strings, each representing one book page.
341+
*
342+
* Note that while the single player version will allow an almost unlimited number of characters
343+
* on the same line, Spigot, (and likely the vanilla server) will only allow 256. This, combined with extra format
344+
* characters being inserted was causing pages to be split in new and strange places
342345
*/
343346
public static List<String> stringToPages(String str){
344347
String wrapped = wrapFormattedStringToWidth(str, BOOK_TEXT_WIDTH);
@@ -417,6 +420,7 @@ public static List<String> stringWithPageBreaksToPages(String str, String pageBr
417420
/**
418421
* Converts the new JSON strings with their escaped quotation marks back into regular old strings
419422
* Hopefully this is just temporary.
423+
* EditBookScreen seems to work with normal strings, but ReadBookScreen is converting the pages to JSON
420424
*/
421425
public static String deJSONify(String jsonIn){
422426
try{

src/main/java/wafflestomper/ghostwriter/FileHandler.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ else if (line.toLowerCase().startsWith("author:") && book.author.isEmpty()){
350350
}
351351

352352

353+
// TODO: Add comments with page numbers
353354
public boolean saveBookToGHBFile(String title, String author, List<String> pages, File savePath){
354355
printer.gamePrint(Printer.GRAY + "Saving book to file...");
355356
List<String> toWrite = new ArrayList<>();
@@ -363,18 +364,17 @@ public boolean saveBookToGHBFile(String title, String author, List<String> pages
363364
while (pageAsString.startsWith("\"") && pageAsString.endsWith("\"")){
364365
pageAsString = pageAsString.substring(1, pageAsString.length()-1);
365366
}
366-
// Strip
367-
//convert all escaped newline characters to real newline characters
367+
// Convert all escaped newline characters to real newline characters
368368
pageAsString = pageAsString.replaceAll("\\\\n", "\\\n");
369-
//Split the string into 116 pixel maximum lines
369+
// Split the string into 116 pixel maximum lines
370370
List<String> currPage = BookUtilities.splitStringIntoLines(pageAsString);
371371
// Replace newline characters with double hashes and add the double hashes to the end of each line
372372
for (String line : currPage){
373373
toWrite.add(line.replaceAll("\\n", "##") + "##");
374374
}
375-
//Add pagebreaks
375+
// Add pagebreaks with line numbers
376376
if (i < pages.size()-1){
377-
toWrite.add(">>>>");
377+
toWrite.add(GHB_PAGE_BREAK + " // Page " + (i+2));
378378
}
379379
}
380380
if (writeFile(toWrite, savePath)){

src/main/java/wafflestomper/ghostwriter/GhostwriterEditBookScreen.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public class GhostwriterEditBookScreen extends EditBookScreen {
201201

202202
private Clipboard clipboard;
203203

204-
private File autoReloadFile; // Auto Reload is active when this is not nullprivate Clipboard autoReloadBookClipboard;
204+
private File autoReloadFile; // Auto Reload is active when this is not null
205205
private long autoReloadLastModified = 0;
206206
private long autoReloadLastCheck = 0;
207207
private Clipboard autoReloadClipboard;

src/main/java/wafflestomper/ghostwriter/GhostwriterFileBrowserScreen.java

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import java.io.File;
1616
import java.util.List;
1717

18+
// TODO: Focus on the filename field with the name (and not extension) highlighted to make saving with a custom name
19+
// faster
20+
1821
public class GhostwriterFileBrowserScreen extends Screen{
1922

2023
private FileSelectionList fileSelectionList;

update.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"homepage": "https://github.com/waffle-stomper/Ghostwriter/releases",
33
"promos":{
4-
"1.16.1-recommended": "2.1.4",
4+
"1.16.1-recommended": "2.1.5",
55
"1.15.2-recommended": "2.0.6",
66
"1.15.1-recommended": "2.0.5",
77
"1.14.4-recommended": "2.0.4",
@@ -13,6 +13,7 @@
1313
"1.10-recommended": "1.8.5"
1414
},
1515
"1.16.1":{
16+
"2.1.5": "Fix title bug when signing loaded book\nRemove redundant format chars when loading a book (thanks Maester Lodish)\nAdd page numbers to ghb files",
1617
"2.1.4": "Fix crash when removing pages\nReported by Maester Lodish",
1718
"2.1.3": "Code cleanup",
1819
"2.1.2": "Convert all space indentation to tabs",

0 commit comments

Comments
 (0)