Class BookEditScreen
java.lang.Object
net.minecraft.client.gui.DrawableHelper
net.minecraft.client.gui.AbstractParentElement
net.minecraft.client.gui.screen.Screen
net.minecraft.client.gui.screen.ingame.BookEditScreen
- All Implemented Interfaces:
Drawable
,Element
,ParentElement
,TickableElement
@Environment(CLIENT) public class BookEditScreen extends Screen
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
BookEditScreen.Line
(package private) static class
BookEditScreen.PageContent
(package private) static class
BookEditScreen.Position
-
Field Summary
Fields Modifier and Type Field Description private static OrderedText
BLACK_CURSOR_TEXT
private SelectionManager
bookTitleSelectionManager
private ButtonWidget
cancelButton
private int
currentPage
private SelectionManager
currentPageSelectionManager
private boolean
dirty
private ButtonWidget
doneButton
private static Text
EDIT_TITLE_TEXT
private static Text
FINALIZE_WARNING_TEXT
private ButtonWidget
finalizeButton
private static OrderedText
GRAY_CURSOR_TEXT
private Hand
hand
private ItemStack
itemStack
private int
lastClickIndex
private long
lastClickTime
private PageTurnWidget
nextPageButton
private BookEditScreen.PageContent
pageContent
private Text
pageIndicatorText
private List<String>
pages
private PlayerEntity
player
private PageTurnWidget
previousPageButton
private ButtonWidget
signButton
private Text
signedByText
private boolean
signing
private int
tickCounter
private String
title
Fields inherited from class net.minecraft.client.gui.screen.Screen
buttons, children, client, height, itemRenderer, passEvents, textRenderer, width
Fields inherited from class net.minecraft.client.gui.DrawableHelper
GUI_ICONS_TEXTURE, OPTIONS_BACKGROUND_TEXTURE, STATS_ICON_TEXTURE
-
Constructor Summary
Constructors Constructor Description BookEditScreen(PlayerEntity player, ItemStack itemStack, Hand hand)
-
Method Summary
Modifier and Type Method Description private BookEditScreen.Position
absolutePositionToScreenPosition(BookEditScreen.Position position)
private void
appendNewPage()
private void
changePage()
boolean
charTyped(char chr, int modifiers)
Callback for when a character input has been captured.private int
countPages()
private BookEditScreen.PageContent
createPageContent()
private void
drawCursor(MatrixStack matrices, BookEditScreen.Position position, boolean atEnd)
private void
drawSelection(Rect2i[] selectionRectangles)
private void
finalizeBook(boolean signBook)
private String
getClipboard()
private String
getCurrentPageContent()
private static int
getLineFromOffset(int[] lineStarts, int position)
private Rect2i
getLineSelectionRectangle(String string, TextHandler handler, int selectionStart, int selectionEnd, int lineY, int lineStart)
private BookEditScreen.PageContent
getPageContent()
private Rect2i
getRectFromCorners(BookEditScreen.Position start, BookEditScreen.Position end)
protected void
init()
Called when a screen should be initialized.private void
invalidatePageContent()
boolean
keyPressed(int keyCode, int scanCode, int modifiers)
Callback for when a key down event has been captured.private boolean
keyPressedEditMode(int keyCode, int scanCode, int modifiers)
private boolean
keyPressedSignMode(int keyCode, int scanCode, int modifiers)
boolean
mouseClicked(double mouseX, double mouseY, int button)
Callback for when a mouse button down event has been captured.boolean
mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
Callback for when a mouse button drag event has been captured.private void
moveDownLine()
private void
moveToLineEnd()
private void
moveToLineStart()
private void
moveUpLine()
private void
moveVertically(int lines)
private void
openNextPage()
private void
openPreviousPage()
void
removed()
private void
removeEmptyPages()
void
render(MatrixStack matrices, int mouseX, int mouseY, float delta)
private BookEditScreen.Position
screenPositionToAbsolutePosition(BookEditScreen.Position position)
private void
selectCurrentWord(int cursor)
private void
setClipboard(String clipboard)
private void
setPageContent(String newContent)
void
tick()
private void
updateButtons()
Methods inherited from class net.minecraft.client.gui.screen.Screen
addButton, addChild, children, filesDragged, getNarrationMessage, getTitle, getTooltipFromItem, handleTextClick, hasAltDown, hasControlDown, hasShiftDown, init, insertText, isCopy, isCut, isMouseOver, isPaste, isPauseScreen, isSelectAll, isValidCharacterForName, onClose, renderBackground, renderBackground, renderBackgroundTexture, renderOrderedTooltip, renderTextHoverEffect, renderTooltip, renderTooltip, renderTooltip, resize, sendMessage, sendMessage, shouldCloseOnEsc, wrapScreenError
Methods inherited from class net.minecraft.client.gui.AbstractParentElement
getFocused, isDragging, setDragging, setFocused
Methods inherited from class net.minecraft.client.gui.DrawableHelper
drawCenteredString, drawCenteredText, drawHorizontalLine, drawSprite, drawStringWithShadow, drawTexture, drawTexture, drawTexture, drawTexture, drawTextWithShadow, drawVerticalLine, fill, fillGradient, fillGradient, getZOffset, method_29343, setZOffset
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.client.gui.Element
mouseMoved
Methods inherited from interface net.minecraft.client.gui.ParentElement
changeFocus, focusOn, hoveredElement, keyReleased, mouseReleased, mouseScrolled, setInitialFocus
-
Field Details
-
EDIT_TITLE_TEXT
-
FINALIZE_WARNING_TEXT
-
BLACK_CURSOR_TEXT
-
GRAY_CURSOR_TEXT
-
player
-
itemStack
-
dirty
private boolean dirty -
signing
private boolean signing -
tickCounter
private int tickCounter -
currentPage
private int currentPage -
pages
-
title
-
currentPageSelectionManager
-
bookTitleSelectionManager
-
lastClickTime
private long lastClickTime -
lastClickIndex
private int lastClickIndex -
nextPageButton
-
previousPageButton
-
doneButton
-
signButton
-
finalizeButton
-
cancelButton
-
hand
-
pageContent
-
pageIndicatorText
-
signedByText
-
-
Constructor Details
-
BookEditScreen
-
-
Method Details
-
setClipboard
-
getClipboard
-
countPages
private int countPages() -
tick
public void tick()- Specified by:
tick
in interfaceTickableElement
- Overrides:
tick
in classScreen
-
init
protected void init()Called when a screen should be initialized.This method is called when this screen is
opened
or resized. -
openPreviousPage
private void openPreviousPage() -
openNextPage
private void openNextPage() -
removed
public void removed() -
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 inGLFW
class.- Specified by:
keyPressed
in interfaceElement
- Specified by:
keyPressed
in interfaceParentElement
- Overrides:
keyPressed
in classScreen
- Parameters:
keyCode
- the named key code of the event as described in theGLFW
classscanCode
- the unique/platform-specific scan code of the keyboard inputmodifiers
- 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 inGLFW
class.- Parameters:
chr
- the captured charactermodifiers
- 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
-
setPageContent
-
render
-
drawCursor
-
drawSelection
-
screenPositionToAbsolutePosition
-
absolutePositionToScreenPosition
-
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 inGLFW
class.- Parameters:
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mousebutton
- 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 inGLFW
class.- Parameters:
mouseX
- the current X coordinate of the mousemouseY
- the current Y coordinate of the mousebutton
- the mouse button numberdeltaX
- the difference of the current X with the previous X coordinatedeltaY
- 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
-
invalidatePageContent
private void invalidatePageContent() -
changePage
private void changePage() -
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
-