Skip to content

Commit 35eb7db

Browse files
committed
Refactor more functions in SplicingTableScreen
1 parent ed0c602 commit 35eb7db

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

Common/src/main/kotlin/gay/object/hexdebug/gui/splicing/SplicingTableScreen.kt

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -642,41 +642,6 @@ class SplicingTableScreen(
642642
guiGraphics.disableScissor()
643643
}
644644

645-
private fun drawRangeSelection(guiGraphics: GuiGraphics, offset: Int, type: IotaBackgroundType, leftEdge: Boolean, rightEdge: Boolean) {
646-
blitSprite(
647-
guiGraphics,
648-
x = leftPos + 15 + 18 * offset,
649-
y = topPos + 18,
650-
uOffset = 352 + 20 * type.ordinal,
651-
vOffset = 24,
652-
width = 18,
653-
height = 25,
654-
)
655-
if (leftEdge) {
656-
drawSelectionEndCap(guiGraphics, offset, SelectionEndCap.LEFT)
657-
}
658-
if (rightEdge) {
659-
drawSelectionEndCap(guiGraphics, offset, SelectionEndCap.RIGHT)
660-
}
661-
}
662-
663-
private fun drawEdgeSelection(guiGraphics: GuiGraphics, offset: Int) {
664-
drawSelectionEndCap(guiGraphics, offset - 1, SelectionEndCap.RIGHT)
665-
drawSelectionEndCap(guiGraphics, offset, SelectionEndCap.LEFT)
666-
}
667-
668-
private fun drawSelectionEndCap(guiGraphics: GuiGraphics, offset: Int, endCap: SelectionEndCap) {
669-
blitSprite(
670-
guiGraphics,
671-
x = leftPos + 14 + 18 * offset + endCap.xOffset,
672-
y = topPos + 24,
673-
uOffset = 370 + endCap.uOffset,
674-
vOffset = 4,
675-
width = 1,
676-
height = 13,
677-
)
678-
}
679-
680645
companion object {
681646
val TEXTURE = HexDebug.id("textures/gui/splicing_table.png")
682647

@@ -733,11 +698,12 @@ class SplicingTableScreen(
733698
guiGraphics.blit(TEXTURE, x, y, uOffset.toFloat(), vOffset.toFloat(), width, height, 512, 512)
734699
}
735700

736-
fun button(name: String, onPress: Button.OnPress) = button(buttonKey(name).asTranslatedComponent, onPress)
737-
738-
fun button(message: Component, onPress: Button.OnPress) =
739-
Button.builder(message, onPress)
701+
// TODO: remove when we have icons for the remaining buttons
702+
fun button(name: String, onPress: Button.OnPress): Button.Builder {
703+
val message = buttonKey(name).asTranslatedComponent
704+
return Button.builder(message, onPress)
740705
.tooltip(Tooltip.create(message))
706+
}
741707

742708
fun buttonText(name: String, vararg args: Any) = buttonKey(name).asTranslatedComponent(*args)
743709
fun tooltipText(name: String, vararg args: Any) = tooltipKey(name).asTranslatedComponent(*args)
@@ -786,6 +752,41 @@ class SplicingTableScreen(
786752
null -> {}
787753
}
788754
}
755+
756+
private fun drawRangeSelection(guiGraphics: GuiGraphics, offset: Int, type: IotaBackgroundType, leftEdge: Boolean, rightEdge: Boolean) {
757+
blitSprite(
758+
guiGraphics,
759+
x = leftPos + 15 + 18 * offset,
760+
y = topPos + 18,
761+
uOffset = 352 + 20 * type.ordinal,
762+
vOffset = 24,
763+
width = 18,
764+
height = 25,
765+
)
766+
if (leftEdge) {
767+
drawSelectionEndCap(guiGraphics, offset, SelectionEndCap.LEFT)
768+
}
769+
if (rightEdge) {
770+
drawSelectionEndCap(guiGraphics, offset, SelectionEndCap.RIGHT)
771+
}
772+
}
773+
774+
private fun drawEdgeSelection(guiGraphics: GuiGraphics, offset: Int) {
775+
drawSelectionEndCap(guiGraphics, offset - 1, SelectionEndCap.RIGHT)
776+
drawSelectionEndCap(guiGraphics, offset, SelectionEndCap.LEFT)
777+
}
778+
779+
private fun drawSelectionEndCap(guiGraphics: GuiGraphics, offset: Int, endCap: SelectionEndCap) {
780+
blitSprite(
781+
guiGraphics,
782+
x = leftPos + 14 + 18 * offset + endCap.xOffset,
783+
y = topPos + 24,
784+
uOffset = 370 + endCap.uOffset,
785+
vOffset = 4,
786+
width = 1,
787+
height = 13,
788+
)
789+
}
789790
}
790791
}
791792

0 commit comments

Comments
 (0)