Improve effect list render

This commit is contained in:
DBotThePony 2022-09-10 16:45:30 +07:00
parent b280e3c6c5
commit 371627f5f5
Signed by: DBot
GPG Key ID: DCC23B5715498507
4 changed files with 158 additions and 398 deletions

View File

@ -64,52 +64,80 @@ enum class TextAlign {
BOTTOM_RIGHT,
}
fun Font.drawAligned(poseStack: PoseStack, text: String, align: TextAlign, x: Float, y: Float, color: Int): Int {
return when (align) {
TextAlign.TOP_LEFT -> draw(poseStack, text, x, y, color)
TextAlign.TOP_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), y, color)
TextAlign.TOP_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), y, color)
private fun Font.drawScaledDuckTyped(poseStack: PoseStack, text: Any, scale: Float, x: Float, y: Float, color: Int): Int {
val translation = poseStack.translation()
TextAlign.CENTER_LEFT -> draw(poseStack, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color)
poseStack.pushPose()
poseStack.translate(-translation)
poseStack.scale(scale, scale, scale)
val inv = 1f / scale
poseStack.translate(-translation * inv)
val size = drawDuckTyped(poseStack, text, x * inv, y * inv, color)
poseStack.popPose()
TextAlign.BOTTOM_LEFT -> draw(poseStack, text, x, (y - lineHeight).roundToInt().toFloat(), color)
TextAlign.BOTTOM_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color)
TextAlign.BOTTOM_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color)
return size
}
private fun Font.drawDuckTyped(poseStack: PoseStack, text: Any, x: Float, y: Float, color: Int): Int {
return when (text) {
is Component -> draw(poseStack, text, x, y, color)
is String -> draw(poseStack, text, x, y, color)
is FormattedCharSequence -> draw(poseStack, text, x, y, color)
else -> throw ClassCastException(text::class.qualifiedName)
}
}
private fun Font.widthDuckTyped(text: Any): Int {
return when (text) {
is Component -> width(text)
is String -> width(text)
is FormattedCharSequence -> width(text)
else -> throw ClassCastException(text::class.qualifiedName)
}
}
private fun Font.drawAlignedDuckTyped(poseStack: PoseStack, text: Any, align: TextAlign, x: Float, y: Float, color: Int): Int {
return when (align) {
TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, text, x, y, color)
TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), y, color)
TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), y, color)
TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, text, x, (y - lineHeight).roundToInt().toFloat(), color)
TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color)
TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color)
}
}
private fun Font.drawScaledAlignedDuckTyped(poseStack: PoseStack, text: Any, scale: Float, align: TextAlign, x: Float, y: Float, color: Int): Int {
return when (align) {
TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, y, color)
TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), y, color)
TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), y, color)
TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, (y - lineHeight / 2f * scale).roundToInt().toFloat(), color)
TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color)
TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, (y - lineHeight * scale).roundToInt().toFloat(), color)
TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color)
TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color)
}
}
fun Font.drawAligned(poseStack: PoseStack, text: String, align: TextAlign, x: Float, y: Float, color: Int): Int {
return drawAlignedDuckTyped(poseStack, text, align, x, y, color)
}
fun Font.drawAligned(poseStack: PoseStack, text: Component, align: TextAlign, x: Float, y: Float, color: Int): Int {
return when (align) {
TextAlign.TOP_LEFT -> draw(poseStack, text, x, y, color)
TextAlign.TOP_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), y, color)
TextAlign.TOP_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), y, color)
TextAlign.CENTER_LEFT -> draw(poseStack, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.BOTTOM_LEFT -> draw(poseStack, text, x, (y - lineHeight).roundToInt().toFloat(), color)
TextAlign.BOTTOM_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color)
TextAlign.BOTTOM_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color)
}
return drawAlignedDuckTyped(poseStack, text, align, x, y, color)
}
fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int): Int {
return when (align) {
TextAlign.TOP_LEFT -> draw(poseStack, text, x, y, color)
TextAlign.TOP_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), y, color)
TextAlign.TOP_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), y, color)
TextAlign.CENTER_LEFT -> draw(poseStack, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.CENTER_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color)
TextAlign.BOTTOM_LEFT -> draw(poseStack, text, x, (y - lineHeight).roundToInt().toFloat(), color)
TextAlign.BOTTOM_CENTER -> draw(poseStack, text, (x - width(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color)
TextAlign.BOTTOM_RIGHT -> draw(poseStack, text, (x - width(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color)
}
return drawAlignedDuckTyped(poseStack, text, align, x, y, color)
}
fun Font.drawAligned(poseStack: PoseStack, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor): Int {
@ -124,361 +152,26 @@ fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: T
return drawAligned(poseStack, text, align, x, y, color.toInt())
}
fun Font.drawAlignedLines(poseStack: PoseStack, text: List<Any?>, align: TextAlign, x: Float, y: Float, color: Int) {
var totalWidth = 0
var height = 0
for (line in text) {
var accumulate = 0
when (line) {
is Component -> {
accumulate += width(line)
height += lineHeight
}
is String -> {
accumulate += width(line)
height += lineHeight
}
is FormattedCharSequence -> {
accumulate += width(line)
height += lineHeight
}
else -> height += lineHeight
}
totalWidth = totalWidth.coerceAtLeast(accumulate)
}
if (height == 0 || totalWidth == 0) {
return
}
var y = y
when (align) {
TextAlign.TOP_LEFT -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x, y, color)
is String -> draw(poseStack, line, x, y, color)
is FormattedCharSequence -> draw(poseStack, line, x, y, color)
}
y += lineHeight
}
}
TextAlign.TOP_CENTER -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x - width(line) / 2f, y, color)
is String -> draw(poseStack, line, x - width(line) / 2f, y, color)
is FormattedCharSequence -> draw(poseStack, line, x - width(line) / 2f, y, color)
}
y += lineHeight
}
}
TextAlign.TOP_RIGHT -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x - width(line), y, color)
is String -> draw(poseStack, line, x - width(line), y, color)
is FormattedCharSequence -> draw(poseStack, line, x - width(line), y, color)
}
y += lineHeight
}
}
TextAlign.CENTER_LEFT -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x, y - height / 2f, color)
is String -> draw(poseStack, line, x, y - height / 2f, color)
is FormattedCharSequence -> draw(poseStack, line, x, y - height / 2f, color)
}
y += lineHeight
}
}
TextAlign.CENTER_CENTER -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x - width(line) / 2f, y - height / 2f, color)
is String -> draw(poseStack, line, x - width(line) / 2f, y - height / 2f, color)
is FormattedCharSequence -> draw(poseStack, line, x - width(line) / 2f, y - height / 2f, color)
}
y += lineHeight
}
}
TextAlign.CENTER_RIGHT -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x - width(line), y - height / 2f, color)
is String -> draw(poseStack, line, x - width(line), y - height / 2f, color)
is FormattedCharSequence -> draw(poseStack, line, x - width(line), y - height / 2f, color)
}
y += lineHeight
}
}
TextAlign.BOTTOM_LEFT -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x, y - height, color)
is String -> draw(poseStack, line, x, y - height, color)
is FormattedCharSequence -> draw(poseStack, line, x, y - height, color)
}
y += lineHeight
}
}
TextAlign.BOTTOM_CENTER -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x - width(line) / 2f, y - height, color)
is String -> draw(poseStack, line, x - width(line) / 2f, y - height, color)
is FormattedCharSequence -> draw(poseStack, line, x - width(line) / 2f, y - height, color)
}
y += lineHeight
}
}
TextAlign.BOTTOM_RIGHT -> {
for (line in text) {
when (line) {
is Component -> draw(poseStack, line, x - width(line), y - height, color)
is String -> draw(poseStack, line, x - width(line), y - height, color)
is FormattedCharSequence -> draw(poseStack, line, x - width(line), y - height, color)
}
y += lineHeight
}
}
}
fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int): Int {
return drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color)
}
fun Font.drawAlignedStripe(poseStack: PoseStack, text: List<Any>, align: TextAlign, x: Float, y: Float, color: Int) {
var totalWidth = 0
for (line in text) {
totalWidth += when (line) {
is Component -> {
width(line)
}
is String -> {
width(line)
}
is FormattedCharSequence -> {
width(line)
}
else -> throw IllegalArgumentException("Invalid stripe value ${line}")
}
}
if (totalWidth == 0) {
return
}
var x = x
when (align) {
TextAlign.TOP_LEFT -> {
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y, color)
x += width(line)
}
is String -> {
draw(poseStack, line, x, y, color)
x += width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y, color)
x += width(line)
}
}
}
}
TextAlign.TOP_CENTER -> {
x += totalWidth / 2f
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y, color)
x -= width(line)
}
is String -> {
draw(poseStack, line, x, y, color)
x -= width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y, color)
x -= width(line)
}
}
}
}
TextAlign.TOP_RIGHT -> {
x += totalWidth
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y, color)
x -= width(line)
}
is String -> {
draw(poseStack, line, x, y, color)
x -= width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y, color)
x -= width(line)
}
}
}
}
TextAlign.CENTER_LEFT -> {
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x += width(line)
}
is String -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x += width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x += width(line)
}
}
}
}
TextAlign.CENTER_CENTER -> {
x += totalWidth / 2f
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x -= width(line)
}
is String -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x -= width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x -= width(line)
}
}
}
}
TextAlign.CENTER_RIGHT -> {
x += totalWidth
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x -= width(line)
}
is String -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x -= width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y - lineHeight / 2f, color)
x -= width(line)
}
}
}
}
TextAlign.BOTTOM_LEFT -> {
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y - lineHeight, color)
x += width(line)
}
is String -> {
draw(poseStack, line, x, y - lineHeight, color)
x += width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y - lineHeight, color)
x += width(line)
}
}
}
}
TextAlign.BOTTOM_CENTER -> {
x += totalWidth / 2f
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y - lineHeight, color)
x -= width(line)
}
is String -> {
draw(poseStack, line, x, y - lineHeight, color)
x -= width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y - lineHeight, color)
x -= width(line)
}
}
}
}
TextAlign.BOTTOM_RIGHT -> {
x += totalWidth
for (line in text) {
when (line) {
is Component -> {
draw(poseStack, line, x, y - lineHeight, color)
x -= width(line)
}
is String -> {
draw(poseStack, line, x, y - lineHeight, color)
x -= width(line)
}
is FormattedCharSequence -> {
draw(poseStack, line, x, y - lineHeight, color)
x -= width(line)
}
}
}
}
}
fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int): Int {
return drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color)
}
fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int): Int {
return drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color)
}
fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor): Int {
return drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt())
}
fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor): Int {
return drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt())
}
fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor): Int {
return drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt())
}

View File

@ -414,7 +414,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
)
}
var currentScissorRect = currentScissorRect
val currentScissorRect = currentScissorRect
if (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height)) {
// do not render if we are getting cut off by screen scissor

View File

@ -14,10 +14,12 @@ import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.TextAlign
import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition
import ru.dbotthepony.mc.otm.client.render.drawAligned
import ru.dbotthepony.mc.otm.client.render.drawScaledAligned
import ru.dbotthepony.mc.otm.client.render.element
import ru.dbotthepony.mc.otm.client.render.render
import ru.dbotthepony.mc.otm.core.RGBAColor
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.formatTickDuration
import ru.dbotthepony.mc.otm.core.maxScrollDivision
import java.util.stream.Collectors
@ -56,16 +58,34 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
init {
scroll.visible = false
scissor = true
//scissor = true
}
open inner class EffectSquare(
val effect: MobEffectInstance,
effect: MobEffectInstance,
x: Float = 0f,
y: Float = 0f,
width: Float = SQUARE_THIN.width,
height: Float = SQUARE_THIN.height,
) : EditablePanel<S>(screen, this@EffectListPanel.canvas, x, y, width, height) {
protected var lastInstance: MobEffectInstance = effect
val effectType: MobEffect = effect.effect
val effect: MobEffectInstance get() {
val get = entity.activeEffectsMap[effectType]
if (get != null) {
lastInstance = get
return get
}
return lastInstance
}
val isStillValid: Boolean get() {
return entity.activeEffectsMap[effectType]?.let { it.duration > 0 } ?: false
}
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
if (this@EffectListPanel.scroll.visible) {
this@EffectListPanel.scroll.mouseScrolledInner(x, y, scroll)
@ -77,7 +97,8 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
override fun tick() {
super.tick()
if (effect.duration <= 0) {
if (!isStillValid) {
effectButtons.remove(effectType)
remove()
}
}
@ -90,7 +111,7 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
minecraft.mobEffectTextures.get(effect.effect).render(stack, x = 3f, y = 3f, width = width - 6f, height = height - 6f)
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
font.drawAligned(stack, MobEffectUtil.formatDuration(effect, 1.0f), TextAlign.CENTER_CENTER, width / 2f + 0.5f, height / 2f, RGBAColor.WHITE)
font.drawScaledAligned(stack, formatTickDuration(effect.duration), 0.75f, TextAlign.CENTER_CENTER, width / 2f + 0.5f, height / 2f, RGBAColor.WHITE)
}
override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
@ -119,7 +140,7 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
}
font.drawAligned(stack, name, TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 8f, RGBAColor.WHITE)
font.drawAligned(stack, MobEffectUtil.formatDuration(effect, 1.0f), TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 8f + font.lineHeight + 2f, 8355711)
font.drawAligned(stack, formatTickDuration(effect.duration, true), TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 8f + font.lineHeight + 2f, 8355711)
}
return isHovered

View File

@ -335,3 +335,49 @@ fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent(
fun formatPowerLevel(a: ImpreciseFraction, b: ImpreciseFraction, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces), b.formatPower(decimalPlaces))
fun formatMatterLevel(a: ImpreciseFraction, b: ImpreciseFraction, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces), b.formatMatter(decimalPlaces))
private fun padded(num: Int): String {
if (num in 0 .. 9) {
return "0$num"
}
return num.toString()
}
fun formatTickDuration(ticks: Int, longFormat: Boolean = false): String {
@Suppress("name_shadowing")
var leftTicks = ticks
// val mTicks = leftTicks % 20
leftTicks /= 20
val seconds = padded(leftTicks % 60)
leftTicks /= 60
if (longFormat) {
if (ticks <= 0) {
return "00:00:00"
} else if (ticks <= 20) {
return ".00000${padded(ticks)}"
}
val minutes = padded(leftTicks % 60)
leftTicks /= 60
val hours = padded(leftTicks)
return "$hours:$minutes:$seconds"
} else {
if (ticks <= 0) {
return "00:00"
} else if (ticks <= 20) {
return ".00${padded(ticks)}"
}
val minutes = leftTicks
if (minutes > 99) {
return "**:**"
}
return "${padded(minutes)}:$seconds"
}
}