diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 2f45327b1..219e89685 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -27,7 +27,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) val input = NetworkedStringInputPanel(this, frame, backend = menu.text) input.dock = Dock.FILL - input.multiLine = true + input.isMultiLine = true val lock = CheckBoxLabelInputPanel(this, frame, menu.locked, TranslatableComponent("otm.gui.lock_holo_screen")) lock.dock = Dock.BOTTOM diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index bd7a9111b..ae8dfaf87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -86,19 +86,19 @@ open class TextInputPanel( private val cursorLine = this@TextInputPanel.cursorLine private val cursorCharacter = this@TextInputPanel.cursorRow private val selections = Int2ObjectAVLTreeMap(this@TextInputPanel.selections) - private val multiLine = this@TextInputPanel.multiLine + private val multiLine = this@TextInputPanel.isMultiLine fun apply() { this@TextInputPanel.lines.clear() - if (this@TextInputPanel.multiLine) + if (this@TextInputPanel.isMultiLine) this@TextInputPanel.lines.addAll(lines) else this@TextInputPanel.lines.add(lines.joinToString("")) this@TextInputPanel.selections.clear() - if (this@TextInputPanel.multiLine && multiLine) + if (this@TextInputPanel.isMultiLine && multiLine) this@TextInputPanel.selections.putAll(selections) this@TextInputPanel.cursorRow = cursorCharacter @@ -129,7 +129,7 @@ open class TextInputPanel( } var debugDraw = false - var multiLine = false + var isMultiLine = false set(value) { if (field == value) return @@ -279,7 +279,7 @@ open class TextInputPanel( if (index < 0) throw IndexOutOfBoundsException("negative index $index") - if (!multiLine && index != 0) + if (!isMultiLine && index != 0) throw IllegalStateException("Not accepting newlines") lines.ensureCapacity(index) @@ -305,7 +305,7 @@ open class TextInputPanel( } fun insertLine(index: Int, value: String = "") { - if (!multiLine && lines.isNotEmpty()) + if (!isMultiLine && lines.isNotEmpty()) throw IllegalStateException("Not accepting newlines") lines.ensureCapacity(index) @@ -461,7 +461,7 @@ open class TextInputPanel( cursorRow = 0 textCache = null - if (multiLine) { + if (isMultiLine) { lines.addAll(value.split(NEWLINES)) } else { lines.add(value.replace(NEWLINES, "")) @@ -668,7 +668,7 @@ open class TextInputPanel( } if (key == InputConstants.KEY_RETURN) { - if (multiLine) { + if (isMultiLine) { if (!minecraft.window.isShiftDown && !minecraft.window.isCtrlDown) wipeSelection() @@ -905,7 +905,7 @@ open class TextInputPanel( wipeSelection() pushbackSnapshot() - if (multiLine) { + if (isMultiLine) { var index = cursorRow + (0 until cursorLine).iterator().map { this[it]?.length ?: 0 }.reduce(0, Int::plus) val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").filter { acceptsCharacter(it, 0, index++) }.split(NEWLINES).toMutableList() val actualLastSize = insert.lastOrNull()?.length ?: 0 @@ -1068,7 +1068,7 @@ open class TextInputPanel( wipeSelection() - if (!multiLine) + if (!isMultiLine) cursorLine = 0 var line = this[cursorLine] @@ -1125,7 +1125,7 @@ open class TextInputPanel( var topPadding = dockPadding.top - if (multiLine) { + if (isMultiLine) { val heightInLines = ((height - dockPadding.top - dockPadding.bottom) / (font.lineHeight + rowSpacing)).toInt() if (heightInLines > 0) { @@ -1301,6 +1301,8 @@ open class TextInputPanel( isSelecting = true tryToGrabMouseInput() + } else if (button == InputConstants.MOUSE_BUTTON_RIGHT && !isMultiLine) { + text = "" } return true