Class BookEditScreen

All Implemented Interfaces:
Drawable, Element, ParentElement, TickableElement

@Environment(CLIENT)
public class BookEditScreen
extends Screen
  • Field Details

    • EDIT_TITLE_TEXT

      private static final Text EDIT_TITLE_TEXT
    • FINALIZE_WARNING_TEXT

      private static final Text FINALIZE_WARNING_TEXT
    • BLACK_CURSOR_TEXT

      private static final OrderedText BLACK_CURSOR_TEXT
    • GRAY_CURSOR_TEXT

      private static final OrderedText GRAY_CURSOR_TEXT
    • player

      private final PlayerEntity player
    • itemStack

      private final ItemStack itemStack
    • dirty

      private boolean dirty
    • signing

      private boolean signing
    • tickCounter

      private int tickCounter
    • currentPage

      private int currentPage
    • pages

      private final List<String> pages
    • title

      private String title
    • currentPageSelectionManager

      private final SelectionManager currentPageSelectionManager
    • bookTitleSelectionManager

      private final SelectionManager bookTitleSelectionManager
    • lastClickTime

      private long lastClickTime
    • lastClickIndex

      private int lastClickIndex
    • nextPageButton

      private PageTurnWidget nextPageButton
    • previousPageButton

      private PageTurnWidget previousPageButton
    • doneButton

      private ButtonWidget doneButton
    • signButton

      private ButtonWidget signButton
    • finalizeButton

      private ButtonWidget finalizeButton
    • cancelButton

      private ButtonWidget cancelButton
    • hand

      private final Hand hand
    • pageContent

    • pageIndicatorText

      private Text pageIndicatorText
    • signedByText

      private final Text signedByText
  • Constructor Details

  • Method Details

    • setClipboard

      private void setClipboard​(String clipboard)
    • getClipboard

      private String getClipboard()
    • countPages

      private int countPages()
    • tick

      public void tick()
      Specified by:
      tick in interface TickableElement
      Overrides:
      tick in class Screen
    • init

      protected void init()
      Called when a screen should be initialized.

      This method is called when this screen is opened or resized.

      Overrides:
      init in class Screen
    • openPreviousPage

      private void openPreviousPage()
    • openNextPage

      private void openNextPage()
    • removed

      public void removed()
      Overrides:
      removed in class Screen
    • updateButtons

      private void updateButtons()
    • removeEmptyPages

      private void removeEmptyPages()
    • finalizeBook

      private void finalizeBook​(boolean signBook)
    • appendNewPage

      private void appendNewPage()
    • keyPressed

      public boolean keyPressed​(int keyCode, int scanCode, int modifiers)
      Callback for when a key down event has been captured. The key code is identified by the constants in GLFW class.
      Specified by:
      keyPressed in interface Element
      Specified by:
      keyPressed in interface ParentElement
      Overrides:
      keyPressed in class Screen
      Parameters:
      keyCode - the named key code of the event as described in the GLFW class
      scanCode - the unique/platform-specific scan code of the keyboard input
      modifiers - a GLFW bitfield describing the modifier keys that are held down (see {@linkplain https://www.glfw.org/docs/3.3/group__mods.html GLFW Modifier key flags})
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Keyboard.onKey(long, int, int, int, int), GLFW.GLFW_KEY_Q, GLFWKeyCallbackI.invoke(long, int, int, int, int)
    • charTyped

      public boolean charTyped​(char chr, int modifiers)
      Callback for when a character input has been captured. The key code is identified by the constants in GLFW class.
      Parameters:
      chr - the captured character
      modifiers - a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags)
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Keyboard.onChar(long, int, int), GLFW.GLFW_KEY_Q, GLFWKeyCallbackI.invoke(long, int, int, int, int)
    • keyPressedEditMode

      private boolean keyPressedEditMode​(int keyCode, int scanCode, int modifiers)
    • moveUpLine

      private void moveUpLine()
    • moveDownLine

      private void moveDownLine()
    • moveVertically

      private void moveVertically​(int lines)
    • moveToLineStart

      private void moveToLineStart()
    • moveToLineEnd

      private void moveToLineEnd()
    • keyPressedSignMode

      private boolean keyPressedSignMode​(int keyCode, int scanCode, int modifiers)
    • getCurrentPageContent

      private String getCurrentPageContent()
    • setPageContent

      private void setPageContent​(String newContent)
    • render

      public void render​(MatrixStack matrices, int mouseX, int mouseY, float delta)
      Specified by:
      render in interface Drawable
      Overrides:
      render in class Screen
    • drawCursor

      private void drawCursor​(MatrixStack matrices, BookEditScreen.Position position, boolean atEnd)
    • drawSelection

      private void drawSelection​(Rect2i[] selectionRectangles)
    • screenPositionToAbsolutePosition

      private BookEditScreen.Position screenPositionToAbsolutePosition​(BookEditScreen.Position position)
    • absolutePositionToScreenPosition

      private BookEditScreen.Position absolutePositionToScreenPosition​(BookEditScreen.Position position)
    • mouseClicked

      public boolean mouseClicked​(double mouseX, double mouseY, int button)
      Callback for when a mouse button down event has been captured. The button number is identified by the constants in GLFW class.
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      button - the mouse button number
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onMouseButton(long, int, int, int), GLFW.GLFW_MOUSE_BUTTON_1
    • selectCurrentWord

      private void selectCurrentWord​(int cursor)
    • mouseDragged

      public boolean mouseDragged​(double mouseX, double mouseY, int button, double deltaX, double deltaY)
      Callback for when a mouse button drag event has been captured. The button number is identified by the constants in GLFW class.
      Parameters:
      mouseX - the current X coordinate of the mouse
      mouseY - the current Y coordinate of the mouse
      button - the mouse button number
      deltaX - the difference of the current X with the previous X coordinate
      deltaY - the difference of the current Y with the previous Y coordinate
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onCursorPos(long, double, double), GLFW.GLFW_MOUSE_BUTTON_1
    • getPageContent

      private BookEditScreen.PageContent getPageContent()
    • invalidatePageContent

      private void invalidatePageContent()
    • changePage

      private void changePage()
    • createPageContent

      private BookEditScreen.PageContent createPageContent()
    • getLineFromOffset

      private static int getLineFromOffset​(int[] lineStarts, int position)
    • getLineSelectionRectangle

      private Rect2i getLineSelectionRectangle​(String string, TextHandler handler, int selectionStart, int selectionEnd, int lineY, int lineStart)
    • getRectFromCorners

      private Rect2i getRectFromCorners​(BookEditScreen.Position start, BookEditScreen.Position end)