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 784eb3605..b3f29b3ec 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 @@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime +import kotlin.math.roundToInt open class TextInputPanel( screen: S, @@ -1049,6 +1050,8 @@ open class TextInputPanel( if (!backgroundColor.isFullyTransparent) drawRect(stack, 0f, 0f, width, height, backgroundColor) + var topPadding = dockPadding.top + if (multiLine) { val heightInLines = ((height - dockPadding.top - dockPadding.bottom) / (font.lineHeight + rowSpacing)).toInt() @@ -1061,6 +1064,8 @@ open class TextInputPanel( } } else { scrollLines = 0 + + topPadding += ((height - dockPadding.top - dockPadding.bottom - font.lineHeight).coerceAtLeast(0f) / 2f).roundToInt() } val selectedLine = this[cursorLine] @@ -1078,7 +1083,7 @@ open class TextInputPanel( stack.pushPose() stack.translate(-scrollPixels, 0f, 0f) - var y = dockPadding.top + var y = topPadding for (i in scrollLines until lines.size) { val line = lines[i] @@ -1146,7 +1151,7 @@ open class TextInputPanel( text = "_", align = TextAlign.TOP_LEFT, x = dockPadding.left + (if (activeLine == null) 0f else font.width(activeLine).toFloat()), - y = dockPadding.top + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), + y = topPadding + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor ) } else { @@ -1156,7 +1161,7 @@ open class TextInputPanel( text = "|", align = TextAlign.TOP_LEFT, x = dockPadding.left + font.width(activeLine.substring(0, cursorRow)).toFloat() - 1f, - y = dockPadding.top + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), + y = topPadding + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor ) } @@ -1171,7 +1176,7 @@ open class TextInputPanel( text = cursorLine.toString(), align = TextAlign.TOP_RIGHT, x = width, - y = dockPadding.top, + y = topPadding, color = cursorColor ) @@ -1181,7 +1186,7 @@ open class TextInputPanel( text = cursorRow.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, - y = dockPadding.top + font.lineHeight + rowSpacing, + y = topPadding + font.lineHeight + rowSpacing, color = cursorColor ) @@ -1191,7 +1196,7 @@ open class TextInputPanel( text = lines.size.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, - y = dockPadding.top + font.lineHeight * 2f + rowSpacing * 2f, + y = topPadding + font.lineHeight * 2f + rowSpacing * 2f, color = cursorColor ) }