diff --git a/src/minicraft/item/BookItem.java b/src/minicraft/item/BookItem.java index e2c52c1bd..21f9dc1f5 100644 --- a/src/minicraft/item/BookItem.java +++ b/src/minicraft/item/BookItem.java @@ -17,19 +17,22 @@ public class BookItem extends Item { protected static ArrayList getAllInstances() { ArrayList items = new ArrayList(); items.add(new BookItem("Book", Color.get(-1, 200, 531, 430), null)); - items.add(new BookItem("Antidious", Color.get(-1, 100, 300, 500), BookData.antVenomBook)); + items.add(new BookItem("Antidious", Color.get(-1, 100, 300, 500), BookData.antVenomBook, true)); return items; } protected String book; // TODO this is not saved yet; it could be, for editable books. + private final boolean hasTitlePage; - private BookItem(String title, int color, String book) { + private BookItem(String title, int color, String book) { this(title, color, book, false); } + private BookItem(String title, int color, String book, boolean hasTitlePage) { super(title, new Sprite(14, 4, color)); this.book = book; + this.hasTitlePage = hasTitlePage; } public boolean interactOn(Tile tile, Level level, int xt, int yt, Player player, Direction attackDir) { - Game.setMenu(new BookDisplay(book)); + Game.setMenu(new BookDisplay(book, hasTitlePage)); return true; } @@ -37,6 +40,6 @@ public boolean interactOn(Tile tile, Level level, int xt, int yt, Player player, public boolean interactsWithWorld() { return false; } public BookItem clone() { - return new BookItem(getName(), sprite.color, book); + return new BookItem(getName(), sprite.color, book, hasTitlePage); } } diff --git a/src/minicraft/screen/BookDisplay.java b/src/minicraft/screen/BookDisplay.java index cfc570715..be07662f9 100644 --- a/src/minicraft/screen/BookDisplay.java +++ b/src/minicraft/screen/BookDisplay.java @@ -28,9 +28,9 @@ public class BookDisplay extends Display { private final boolean showPageCount; private final int pageOffset; - public BookDisplay(String book) { this(book, true); } - public BookDisplay(String book, boolean hasTitle) { this(book, hasTitle, !hasTitle); } - public BookDisplay(String book, boolean hasTitle, boolean hideCountIfOnePage) { + public BookDisplay(String book) { this(book, false); } + public BookDisplay(String book, boolean hasTitle) {// this(book, hasTitle, !hasTitle); } + //public BookDisplay(String book, boolean hasTitle, boolean hideCountIfOnePage) { page = 0; if(book == null) { book = defaultBook; @@ -51,7 +51,7 @@ public BookDisplay(String book, boolean hasTitle, boolean hideCountIfOnePage) { lines = pages.toArray(new String[pages.size()][]); - showPageCount = !hideCountIfOnePage || lines.length != 1; + showPageCount = hasTitle || lines.length != 1; pageOffset = showPageCount ? 1 : 0; Menu.Builder builder = new Menu.Builder(true, spacing, RelPos.CENTER) @@ -59,7 +59,7 @@ public BookDisplay(String book, boolean hasTitle, boolean hideCountIfOnePage) { Menu pageCount = builder // the small rect for the title .setPositioning(new Point(Screen.w/2, 0), RelPos.BOTTOM) - .setEntries(StringEntry.useLines(Color.BLACK, "Page", hasTitle?"Title":"1")) + .setEntries(StringEntry.useLines(Color.BLACK, "Page", hasTitle?"Title":"1/"+lines.length)) .setSelection(1) .createMenu(); @@ -81,7 +81,7 @@ private void turnPage(int dir) { if(page+dir >= 0 && page+dir < lines.length) { menus[page+pageOffset].shouldRender = false; page += dir; - if(showPageCount) menus[0].updateSelectedEntry(new StringEntry(page==0 && hasTitle?"Title":(page+1)+"", Color.BLACK)); + if(showPageCount) menus[0].updateSelectedEntry(new StringEntry(page==0 && hasTitle?"Title":(page+1)+"/"+lines.length, Color.BLACK)); menus[page+pageOffset].shouldRender = true; } }