Skip to content

Commit aa3f0ce

Browse files
committed
fix: dynamically determine space width
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
1 parent ba9e086 commit aa3f0ce

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/main/kotlin/ru/octol1ttle/flightassistant/api/util/extensions/GuiGraphicsExtensions.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ru.octol1ttle.flightassistant.api.util.extensions
22

33
import com.mojang.blaze3d.vertex.PoseStack
44
import java.awt.Color
5+
import kotlin.math.max
56
import net.minecraft.ChatFormatting
67
import net.minecraft.client.gui.Font
78
import net.minecraft.client.gui.GuiGraphics
@@ -64,14 +65,14 @@ fun GuiGraphics.hLineDashed(
6465
x1: Int, x2: Int, y: Int,
6566
dashCount: Int, color: Int
6667
) {
67-
// TODO: Spacing looks wrong on small GUI scales. Determine optimal spacing based on total width
6868
val width = x2 - x1
6969
if (width <= dashCount) {
7070
hLine(x1, x2, y, color)
7171
return
7272
}
7373
val spaces = dashCount - 1
74-
var spaceOffset = 3 // the actual space width is (spaceOffset - 1)
74+
// the actual space width is (spaceOffset - 1)
75+
var spaceOffset = max(2, width / (dashCount * 2))
7576
while ((width - spaces * spaceOffset) % dashCount != 0) {
7677
spaceOffset++
7778
}

0 commit comments

Comments
 (0)