Class BookEditScreen

All Implemented Interfaces:
ContainerEventHandler, GuiEventListener, Renderable, TabOrderedElement

public class BookEditScreen extends Screen
  • Field Details

    • TEXT_WIDTH

      private static final int TEXT_WIDTH
      See Also:
    • TEXT_HEIGHT

      private static final int TEXT_HEIGHT
      See Also:
    • IMAGE_WIDTH

      private static final int IMAGE_WIDTH
      See Also:
    • IMAGE_HEIGHT

      private static final int IMAGE_HEIGHT
      See Also:
    • EDIT_TITLE_LABEL

      private static final Component EDIT_TITLE_LABEL
    • FINALIZE_WARNING_LABEL

      private static final Component FINALIZE_WARNING_LABEL
    • BLACK_CURSOR

      private static final FormattedCharSequence BLACK_CURSOR
    • GRAY_CURSOR

      private static final FormattedCharSequence GRAY_CURSOR
    • owner

      private final Player owner
    • book

      private final ItemStack book
    • isModified

      private boolean isModified
      Whether the book's title or contents has been modified since being opened
    • isSigning

      private boolean isSigning
      Determines if the signing screen is open
    • frameTick

      private int frameTick
      Update ticks since the gui was opened
    • currentPage

      private int currentPage
    • pages

      private final List<String> pages
    • title

      private String title
    • pageEdit

      private final TextFieldHelper pageEdit
    • titleEdit

      private final TextFieldHelper titleEdit
    • lastClickTime

      private long lastClickTime
      In milliseconds
    • lastIndex

      private int lastIndex
    • forwardButton

      private PageButton forwardButton
    • backButton

      private PageButton backButton
    • doneButton

      private Button doneButton
    • signButton

      private Button signButton
    • finalizeButton

      private Button finalizeButton
    • cancelButton

      private Button cancelButton
    • hand

      private final InteractionHand hand
    • displayCache

      @Nullable private BookEditScreen.DisplayCache displayCache
    • pageMsg

      private Component pageMsg
    • ownerText

      private final Component ownerText
  • Constructor Details

  • Method Details

    • setClipboard

      private void setClipboard(String p_98148_)
    • getClipboard

      private String getClipboard()
    • getNumPages

      private int getNumPages()
    • tick

      public void tick()
      Overrides:
      tick in class Screen
    • init

      protected void init()
      Overrides:
      init in class Screen
    • pageBack

      private void pageBack()
    • pageForward

      private void pageForward()
    • updateButtonVisibility

      private void updateButtonVisibility()
    • eraseEmptyTrailingPages

      private void eraseEmptyTrailingPages()
    • saveChanges

      private void saveChanges(boolean pPublish)
    • updateLocalCopy

      private void updateLocalCopy()
    • appendPageToBook

      private void appendPageToBook()
    • keyPressed

      public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers)
      Called when a keyboard key is pressed within the GUI element.

      Specified by:
      keyPressed in interface ContainerEventHandler
      Specified by:
      keyPressed in interface GuiEventListener
      Overrides:
      keyPressed in class Screen
      Parameters:
      pKeyCode - the key code of the pressed key.
      pScanCode - the scan code of the pressed key.
      pModifiers - the keyboard modifiers.
      Returns:
      true if the event is consumed, false otherwise.
    • charTyped

      public boolean charTyped(char pCodePoint, int pModifiers)
      Called when a character is typed within the GUI element.

      Parameters:
      pCodePoint - the code point of the typed character.
      pModifiers - the keyboard modifiers.
      Returns:
      true if the event is consumed, false otherwise.
    • bookKeyPressed

      private boolean bookKeyPressed(int pKeyCode, int pScanCode, int pModifiers)
      Handles keypresses, clipboard functions, and page turning
    • keyUp

      private void keyUp()
    • keyDown

      private void keyDown()
    • changeLine

      private void changeLine(int pYChange)
    • keyHome

      private void keyHome()
    • keyEnd

      private void keyEnd()
    • titleKeyPressed

      private boolean titleKeyPressed(int pKeyCode, int pScanCode, int pModifiers)
      Handles special keys pressed while editing the book's title
    • getCurrentPageText

      private String getCurrentPageText()
    • setCurrentPageText

      private void setCurrentPageText(String p_98159_)
    • render

      public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick)
      Renders the graphical user interface (GUI) element.
      Specified by:
      render in interface Renderable
      Overrides:
      render in class Screen
      Parameters:
      pGuiGraphics - the GuiGraphics object used for rendering.
      pMouseX - the x-coordinate of the mouse cursor.
      pMouseY - the y-coordinate of the mouse cursor.
      pPartialTick - the partial tick time.
    • renderBackground

      public void renderBackground(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick)
      Overrides:
      renderBackground in class Screen
    • renderCursor

      private void renderCursor(GuiGraphics pGuiGraphics, BookEditScreen.Pos2i pCursorPos, boolean pIsEndOfText)
    • renderHighlight

      private void renderHighlight(GuiGraphics pGuiGraphics, Rect2i[] pHighlightAreas)
    • convertScreenToLocal

      private BookEditScreen.Pos2i convertScreenToLocal(BookEditScreen.Pos2i pScreenPos)
    • convertLocalToScreen

      private BookEditScreen.Pos2i convertLocalToScreen(BookEditScreen.Pos2i pLocalScreenPos)
    • mouseClicked

      public boolean mouseClicked(double pMouseX, double pMouseY, int pButton)
      Called when a mouse button is clicked within the GUI element.

      Parameters:
      pMouseX - the X coordinate of the mouse.
      pMouseY - the Y coordinate of the mouse.
      pButton - the button that was clicked.
      Returns:
      true if the event is consumed, false otherwise.
    • selectWord

      private void selectWord(int pIndex)
    • mouseDragged

      public boolean mouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY)
      Called when the mouse is dragged within the GUI element.

      Parameters:
      pMouseX - the X coordinate of the mouse.
      pMouseY - the Y coordinate of the mouse.
      pButton - the button that is being dragged.
      pDragX - the X distance of the drag.
      pDragY - the Y distance of the drag.
      Returns:
      true if the event is consumed, false otherwise.
    • getDisplayCache

      private BookEditScreen.DisplayCache getDisplayCache()
    • clearDisplayCache

      private void clearDisplayCache()
    • clearDisplayCacheAfterPageChange

      private void clearDisplayCacheAfterPageChange()
    • rebuildDisplayCache

      private BookEditScreen.DisplayCache rebuildDisplayCache()
    • findLineFromPos

      static int findLineFromPos(int[] pLineStarts, int pFind)
    • createPartialLineSelection

      private Rect2i createPartialLineSelection(String pInput, StringSplitter pSplitter, int pStartPos, int pEndPos, int pY, int pLineStart)
    • createSelection

      private Rect2i createSelection(BookEditScreen.Pos2i pCorner1, BookEditScreen.Pos2i pCorner2)