diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-10-11 12:42:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-11 18:42:33 +0200 |
commit | 7c2d4ed566246513bc438272e436627412147d62 (patch) | |
tree | edf8d3d01a49bd7c4f5993bae6367613c32fcaac /src/main/java/at/hannibal2/skyhanni/utils/renderables | |
parent | 0671e35163d55ab0f940aa6806a0d7bfb2876429 (diff) | |
download | skyhanni-7c2d4ed566246513bc438272e436627412147d62.tar.gz skyhanni-7c2d4ed566246513bc438272e436627412147d62.tar.bz2 skyhanni-7c2d4ed566246513bc438272e436627412147d62.zip |
Backend: Detekt Fixes Part 6 (#2657)
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/renderables')
3 files changed, 24 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 5362cc177..94f0bc16e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -564,7 +564,7 @@ interface Renderable { for ((index, renderable) in row.withIndex()) { GlStateManager.pushMatrix() GlStateManager.translate(xOffsets[index].toFloat(), yOffsets[rowIndex].toFloat(), 0F) - renderable?.renderXYAligned( + renderable.renderXYAligned( posX + xOffsets[index], posY + yOffsets[rowIndex], xOffsets[index + 1] - xOffsets[index] - emptySpaceX, @@ -1140,8 +1140,10 @@ interface Renderable { renderY += yShift } @Suppress("SpacingAroundCurly") - val range = yOffsets.indexOfFirst { it >= scroll.asInt() }..<(yOffsets.indexOfFirst { it >= end }.takeIf { it > 0 } - ?: yOffsets.size) - 1 + val range = yOffsets.indexOfFirst { it >= scroll.asInt() }..<( + yOffsets.indexOfFirst { it >= end }.takeIf { it > 0 } + ?: yOffsets.size + ) - 1 val range2 = if (range.last + 3 <= yOffsets.size && yOffsets[range.last + 2] - yOffsets[range.first] <= height - renderY) { range.first..range.last() + 1 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableInventory.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableInventory.kt index 9760ef867..310a0523b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableInventory.kt @@ -87,15 +87,20 @@ object RenderableInventory { uvRow.map { uv -> val uvArray = uv.getUvCoords() val renderable = if (uv == SlotsUv.CENTER) { - (items[index]?.let { item -> - Renderable.itemStack( - item, - scale, - 0, - 0, - false, + ( + items[index]?.let { item -> + Renderable.itemStack( + item, + scale, + 0, + 0, + false, + ) + } ?: Renderable.placeholder( + (16 * scale).toInt(), + (16 * scale).toInt() ) - } ?: Renderable.placeholder((16 * scale).toInt(), (16 * scale).toInt())).also { index++ } + ).also { index++ } } else Renderable.placeholder(0, 0) Renderable.drawInsideFixedSizedImage( renderable, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt index 64c1d8f86..d71ac51a6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt @@ -33,10 +33,12 @@ internal object RenderableUtils { /** Calculates the absolute y position of the rows in a table*/ fun calculateTableYOffsets(content: List<List<Renderable?>>, yPadding: Int) = run { var buffer = 0 - listOf(0) + (content.takeIf { it.isNotEmpty() }?.map { row -> - buffer += (row.maxOfOrNull { it?.height ?: 0 } ?: 0) + yPadding - buffer - } ?: listOf(yPadding)) + listOf(0) + ( + content.takeIf { it.isNotEmpty() }?.map { row -> + buffer += (row.maxOfOrNull { it?.height ?: 0 } ?: 0) + yPadding + buffer + } ?: listOf(yPadding) + ) } fun calculateAlignmentXOffset(width: Int, xSpace: Int, alignment: HorizontalAlignment) = when (alignment) { |