Skip to content

Commit 0315e64

Browse files
Update comments and notes
1 parent aff10da commit 0315e64

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

notes.txt

+2
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,5 @@ Please double-check anything you find here to make sure it's still relevant.
140140
number of characters on each line
141141

142142
- Under some conditions you can write up to 15 lines, but as of 1.16.1 the ReadBookScreen will only display 14 lines
143+
144+
- Lines used to be 116 pixels wide but now seem to be 114 (as of 1.16.1)

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

+5-11
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ private static int sizeStringToWidth(String par1Str, int par2)
247247
/**
248248
* Inserts splitchar into a string to wrap it within the specified width.
249249
*/
250+
// TODO: Why does this insert SPLIT_CHAR instead of returning an array of line start positions or an array of
251+
// line strings? Maybe it's worth doing something like the new vanilla code?
250252
private static String wrapFormattedStringToWidth(String strIn, int maxWidth){
251253
int maxCharsInWidth = sizeStringToWidth(strIn, maxWidth);
252254

@@ -266,17 +268,9 @@ private static String wrapFormattedStringToWidth(String strIn, int maxWidth){
266268
}
267269

268270

269-
270-
271-
272-
273-
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
274-
275-
276-
277271
/**
278272
* Removes trailing newline characters then splits the string into a list
279-
* of 116 pixel wide strings (since that's the width of a book).
273+
* of book width strings
280274
* Note: this won't split it up into pages. If you want to do that too,
281275
* you should use stringToPages()
282276
* Note 2: this preserves trailing whitespace (unlike FontRenderer.listFormattedStringToWidth())
@@ -301,7 +295,7 @@ public static List<String> splitStringIntoLines(String str){
301295
* Splits a monolithic string into a list of strings, each representing one book page.
302296
*
303297
* Note that while the single player version will allow an almost unlimited number of characters
304-
* on the same line, Spigot, (and likely the vanilla server) will only allow 256. This, combined with extra format
298+
* on the same page, Spigot, (and likely the vanilla server) will only allow 256. This, combined with extra format
305299
* characters being inserted was causing pages to be split in new and strange places
306300
*/
307301
public static List<String> stringToPages(String str){
@@ -348,7 +342,7 @@ else if (charCount == 256){
348342

349343
/**
350344
* Splits a monolithic string into a list of strings, each representing one
351-
* book page. New pages are started after 13 lines, 256 character, or the page break symbol (whichever is first)
345+
* book page. New pages are started after 13 lines, 256 characters, or the page break symbol (whichever is first)
352346
* @param str Input string
353347
* @param pageBreakString The symbol that denotes a page break (this will be removed during conversion)
354348
* @return ArrayList of Strings representing pages

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public boolean saveBookToGHBFile(String title, String author, List<String> pages
338338
}
339339
// Convert all escaped newline characters to real newline characters
340340
pageAsString = pageAsString.replaceAll("\\\\n", "\\\n");
341-
// Split the string into 116 pixel maximum lines
341+
// Split the string into book width lines
342342
List<String> currPage = BookUtilities.splitStringIntoLines(pageAsString);
343343
// Replace newline characters with double hashes and add the double hashes to the end of each line
344344
for (String line : currPage){

0 commit comments

Comments
 (0)