Class GuideLayout

java.lang.Object
net.ixdarklord.folios.api.client.page.GuideLayout

public final class GuideLayout extends Object
Where pages are laid out: the page's size and margins, the font, and helpers for the parts most pages have (a title, and text that continues onto further pages).

A page is pageWidth() by pageHeight() pixels: 136 by 180 in a handheld book and on a screen at the Auto GUI scale, larger on a screen at a smaller GUI scale, so more fits on it. Content sits between the margins, from CONTENT_LEFT to contentRight() and CONTENT_TOP to contentBottom(). A page type lays itself out to these (and draws to its GuidePainter's), so it fills a larger page; the constants are the default page's.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    What a page asked flow(String, int, String, GuidePage.Part) for: its title, its own part and how tall it is, and its text.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Under this are the page's number and its turn buttons, with 2 pixels between them and what is on the page.
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
    How far above a page's foot its content stops: under it are the page's number and its turn buttons, 2 pixels clear.
    static final int
     
    static final int
     
    static final int
    The default page's size: a handheld book's, and a screen book's at the Auto GUI scale.
    static final int
    How many texture pixels a scene has for each page pixel it is shown over: enough for it to stay sharp on a handheld book held close and on large screens.
    static final int
    How much room a title takes, its rule under it included.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GuideLayout(GuideBook book, net.minecraft.client.gui.Font font)
     
    GuideLayout(GuideBook book, net.minecraft.client.gui.Font font, int pageWidth, int pageHeight)
    A layout for pages pageWidth by pageHeight, no smaller than the default page.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Lays a page out only as far as what it asks flow(String, int, String, GuidePage.Part) for, to set it inside another page; empty for a page that lays itself out some other way.
    void
    Closes the scenes made for this layout.
    int
     
    int
    Where content ends at the right, how wide it is, and where it ends at the foot (above the number and turn buttons).
    int
     
    flow(@Nullable String title, int reserved, @Nullable String text, @Nullable GuidePage.Part part)
    A page with an optional title, a part of its own reserved pixels tall under it, and text under that; text that doesn't fit runs on over as many more pages as it needs.
    net.minecraft.client.gui.Font
     
    int
     
    int
    The page's width and height, in its own pixels.
    int
    scaled(int height)
    A height written for the default page, for this one: grown as the page is wider, so a window (a scene, a picture) keeps its shape on a larger page rather than turning into a strip.
    text(String raw)
    Text set out to the content's width.
    static void
    title(GuidePainter painter, net.minecraft.network.chat.Component title, int y)
    A page's title: bold, with a line under it.
    static void
    title(GuidePainter painter, net.minecraft.network.chat.Component title, int y, GuideIcon icon)
    As title(GuidePainter, Component, int), with an icon before it, unless none: three quarters of its size, centred over a mark of the book's colour that heads the line under the title, the title starting where the rest of the line does.
     
    void
    The icon put before the titles of the pages laid out next (as flow(String, int, String, GuidePage.Part) draws them): their entry's, or a page's own.
    net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport
    viewport(int width, int height)
    A scene for a page to show (an entity, a structure), drawn to a texture of width by height pixels (its size on the page times SCENE_DETAIL).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PAGE_WIDTH

      public static final int PAGE_WIDTH
      The default page's size: a handheld book's, and a screen book's at the Auto GUI scale.
      See Also:
    • PAGE_HEIGHT

      public static final int PAGE_HEIGHT
      See Also:
    • MARGIN

      public static final int MARGIN
      See Also:
    • CONTENT_LEFT

      public static final int CONTENT_LEFT
      See Also:
    • CONTENT_RIGHT

      public static final int CONTENT_RIGHT
      See Also:
    • CONTENT_WIDTH

      public static final int CONTENT_WIDTH
      See Also:
    • CONTENT_TOP

      public static final int CONTENT_TOP
      See Also:
    • CONTENT_BOTTOM

      public static final int CONTENT_BOTTOM
      Under this are the page's number and its turn buttons, with 2 pixels between them and what is on the page.
      See Also:
    • TITLE_HEIGHT

      public static final int TITLE_HEIGHT
      How much room a title takes, its rule under it included.
      See Also:
    • SCENE_DETAIL

      public static final int SCENE_DETAIL
      How many texture pixels a scene has for each page pixel it is shown over: enough for it to stay sharp on a handheld book held close and on large screens.
      See Also:
  • Constructor Details

    • GuideLayout

      public GuideLayout(GuideBook book, net.minecraft.client.gui.Font font)
    • GuideLayout

      public GuideLayout(GuideBook book, net.minecraft.client.gui.Font font, int pageWidth, int pageHeight)
      A layout for pages pageWidth by pageHeight, no smaller than the default page.
  • Method Details

    • pageWidth

      public int pageWidth()
      The page's width and height, in its own pixels.
    • pageHeight

      public int pageHeight()
    • scaled

      public int scaled(int height)
      A height written for the default page, for this one: grown as the page is wider, so a window (a scene, a picture) keeps its shape on a larger page rather than turning into a strip.
    • contentRight

      public int contentRight()
      Where content ends at the right, how wide it is, and where it ends at the foot (above the number and turn buttons).
    • contentWidth

      public int contentWidth()
    • contentBottom

      public int contentBottom()
    • book

      public GuideBook book()
    • font

      public net.minecraft.client.gui.Font font()
    • text

      public GuideText text(String raw)
      Text set out to the content's width.
    • flow

      public List<GuidePage.Laid> flow(@Nullable String title, int reserved, @Nullable String text, @Nullable GuidePage.Part part)
      A page with an optional title, a part of its own reserved pixels tall under it, and text under that; text that doesn't fit runs on over as many more pages as it needs.
      Parameters:
      part - draws the page's own part, given the height it starts at; null for none
    • capture

      public List<GuideLayout.Flow> capture(GuidePage page)
      Lays a page out only as far as what it asks flow(String, int, String, GuidePage.Part) for, to set it inside another page; empty for a page that lays itself out some other way.
    • titleIcon

      public void titleIcon(GuideIcon icon)
      The icon put before the titles of the pages laid out next (as flow(String, int, String, GuidePage.Part) draws them): their entry's, or a page's own. The book sets it as it lays out each page of an entry; GuideIcon.NONE for none.
    • titleIcon

      public GuideIcon titleIcon()
    • title

      public static void title(GuidePainter painter, net.minecraft.network.chat.Component title, int y)
      A page's title: bold, with a line under it.
    • title

      public static void title(GuidePainter painter, net.minecraft.network.chat.Component title, int y, GuideIcon icon)
      As title(GuidePainter, Component, int), with an icon before it, unless none: three quarters of its size, centred over a mark of the book's colour that heads the line under the title, the title starting where the rest of the line does. Without an icon the line runs unbroken.
    • viewport

      public net.ixdarklord.coolcatcanvas.api.client.viewport.SceneViewport viewport(int width, int height)
      A scene for a page to show (an entity, a structure), drawn to a texture of width by height pixels (its size on the page times SCENE_DETAIL). It belongs to this layout: it is closed when the book is laid out again.
    • close

      public void close()
      Closes the scenes made for this layout.