@@ -98,6 +98,8 @@ class SplicingTableScreen(
9898 }
9999 }
100100
101+ private var clearGridButton: SpriteButton ? = null
102+
101103 override fun init () {
102104 super .init ()
103105
@@ -125,47 +127,73 @@ class SplicingTableScreen(
125127 .build()
126128 }
127129
128- staffButtons + = listOf (
129- button(" clear_grid" ) { guiSpellcasting.mixin.`clearPatterns$hexdebug`() }
130- .pos(leftPos - 200 , topPos - 24 )
131- .size(64 , 16 )
132- .build()
133- )
134-
135130 viewButtons + = listOf (
136131 button(" export" ) { exportToSystemClipboard() }
137132 .pos(leftPos + imageWidth + 2 , topPos)
138133 .size(128 , 16 )
139134 .build()
140135 )
141136
137+ clearGridButton = object : SpriteButton (
138+ x = (staffMinX + staffMaxX) / 2 - 19 ,
139+ y = staffMaxY - 10 ,
140+ uOffset = 192 ,
141+ vOffset = 293 ,
142+ width = 38 ,
143+ height = 25 ,
144+ message = buttonText(" clear_grid" ),
145+ onPress = {
146+ guiSpellcasting.mixin.`clearPatterns$hexdebug`()
147+ },
148+ ) {
149+ override val uOffsetHovered get() = uOffset
150+ override val vOffsetHovered get() = vOffset
151+
152+ override val uOffsetDisabled get() = uOffset
153+ override val vOffsetDisabled get() = vOffset
154+
155+ override fun testVisible () = hasStaffItem
156+
157+ override fun testHitbox (mouseX : Double , mouseY : Double ) =
158+ mouseX >= x + 2 && mouseY >= y + 2 && mouseX < x + width - 2 && mouseY < y + height - 3
159+ }.also (::addRenderableWidget)
160+
142161 predicateButtons + = listOf (
143162 // move view
144163
145- SpriteButton (
164+ object : SpriteButton (
146165 x = leftPos + 4 ,
147166 y = topPos + 25 ,
148167 uOffset = 256 ,
149168 vOffset = 0 ,
150169 width = 10 ,
151170 height = 10 ,
152171 message = buttonText(" view_left" ),
153- ) { // onPress
154- moveView(- 1 )
172+ onPress = {
173+ moveView(- 1 )
174+ },
175+ ) {
176+ // TODO: remove when sam adds a disabled texture lol
177+ override val uOffsetDisabled get() = uOffset
178+ override val vOffsetDisabled get() = vOffset
155179 } to { // test
156180 viewStartIndex > 0
157181 },
158182
159- SpriteButton (
183+ object : SpriteButton (
160184 x = leftPos + 178 ,
161185 y = topPos + 25 ,
162186 uOffset = 266 ,
163187 vOffset = 0 ,
164188 width = 10 ,
165189 height = 10 ,
166190 message = buttonText(" view_right" ),
167- ) { // onPress
168- moveView(1 )
191+ onPress = {
192+ moveView(1 )
193+ },
194+ ) {
195+ override val uOffsetDisabled get() = uOffset
196+ override val vOffsetDisabled get() = vOffset
169197 } to { // test
170198 viewStartIndex < data.lastIndex - IOTA_BUTTONS + 1
171199 },
@@ -540,7 +568,10 @@ class SplicingTableScreen(
540568
541569 private fun isInStaffGrid (mouseX : Double , mouseY : Double , button : Int ) =
542570 staffMinX <= mouseX && mouseX <= staffMaxX && staffMinY <= mouseY && mouseY <= staffMaxY
543- && hasClickedOutside(mouseX, mouseY, leftPos, topPos, button) // avoid interacting with the grid when inserting the staff item
571+ // avoid interacting with the grid when inserting the staff item...
572+ && hasClickedOutside(mouseX, mouseY, leftPos, topPos, button)
573+ // or when clicking the clear grid button
574+ && ! (clearGridButton?.testHitbox(mouseX, mouseY) ? : false )
544575
545576 override fun hasClickedOutside (
546577 mouseX : Double ,
@@ -736,12 +767,12 @@ class SplicingTableScreen(
736767 private val backgroundType by button::backgroundType
737768
738769 override fun render (guiGraphics : GuiGraphics , mouseX : Int , mouseY : Int , partialTick : Float ) {
739- if (! data.isInRange(index)) return
740- val backgroundType = backgroundType ? : return
770+ if (! data.isInRange(index) || backgroundType == null ) return
771+ RenderSystem .enableBlend()
741772 when (val selection = selection) {
742773 is Selection .Range -> if (index in selection) {
743774 drawRangeSelection(
744- guiGraphics, offset, backgroundType,
775+ guiGraphics, offset,
745776 leftEdge = index == selection.start,
746777 rightEdge = index == selection.end,
747778 )
@@ -751,14 +782,15 @@ class SplicingTableScreen(
751782 }
752783 null -> {}
753784 }
785+ RenderSystem .disableBlend()
754786 }
755787
756- private fun drawRangeSelection (guiGraphics : GuiGraphics , offset : Int , type : IotaBackgroundType , leftEdge : Boolean , rightEdge : Boolean ) {
788+ private fun drawRangeSelection (guiGraphics : GuiGraphics , offset : Int , leftEdge : Boolean , rightEdge : Boolean ) {
757789 blitSprite(
758790 guiGraphics,
759791 x = leftPos + 15 + 18 * offset,
760792 y = topPos + 18 ,
761- uOffset = 352 + 20 * type.ordinal ,
793+ uOffset = 352 ,
762794 vOffset = 24 ,
763795 width = 18 ,
764796 height = 25 ,
@@ -772,8 +804,15 @@ class SplicingTableScreen(
772804 }
773805
774806 private fun drawEdgeSelection (guiGraphics : GuiGraphics , offset : Int ) {
775- drawSelectionEndCap(guiGraphics, offset - 1 , SelectionEndCap .RIGHT )
776- drawSelectionEndCap(guiGraphics, offset, SelectionEndCap .LEFT )
807+ blitSprite(
808+ guiGraphics,
809+ x = leftPos + 13 + 18 * offset,
810+ y = topPos + 23 ,
811+ uOffset = 375 ,
812+ vOffset = 29 ,
813+ width = 4 ,
814+ height = 15 ,
815+ )
777816 }
778817
779818 private fun drawSelectionEndCap (guiGraphics : GuiGraphics , offset : Int , endCap : SelectionEndCap ) {
0 commit comments