From ff308ee67a3159fb39c34d204bdac671c090e049 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 16:30:56 +0700 Subject: [PATCH] Actual tabs sprites, and all 4 sprite states for them --- .../mc/otm/client/render/WidgetLocation.kt | 1 + .../mc/otm/client/screen/panels/FramePanel.kt | 117 +++++++++++------- .../textures/gui/widgets/tabs.png | Bin 0 -> 1201 bytes 3 files changed, 74 insertions(+), 44 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/tabs.png diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 46e5c5f26..7c9ca1069 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -11,6 +11,7 @@ object WidgetLocation { val SLOT_BACKGROUNDS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/slot_backgrounds.png"), 72f, 72f) val MISC = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc.png"), 64f, 64f) + val TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/tabs.png"), 224f, 64f) val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 60f, 23f) val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 30f, 60f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index e921758ff..90325961a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -34,7 +34,6 @@ open class FramePanel( var inactiveIcon: IGUIRenderable? = null, ) : AbstractButtonPanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) { var isActive = tabs.isEmpty() - var initial = false init { tabs.add(this) @@ -54,44 +53,59 @@ open class FramePanel( } } + protected fun tabIndex(): Int { + return tabs.indexOf(this) + } + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - val width: Float - val height: Float - if (isActive) { - width = TAB_WIDTH_ACTIVE - height = TAB_HEIGHT_ACTIVE - RECTANGLE.middle.render(graphics, 2f, 2f, width - 4, height - 2) - } else { - width = TAB_WIDTH - height = TAB_HEIGHT - TAB_BACKGROUND.render(graphics, 2f, 2f, width - 4, height - 2) - } - - RECTANGLE.top.render(graphics, 3f, 0f, width = width - 6) - RECTANGLE.left.render(graphics, 0f, 3f, height = (height - if (isActive) if (initial) 2 else 4 else 3)) - - RECTANGLE.right.render(graphics, width - RECTANGLE.right.width, 3f, height = (height - if (isActive) 4 else 3)) - - RECTANGLE.topLeft.render(graphics, 0f, 0f) - RECTANGLE.topRight.render(graphics, width - RECTANGLE.topRight.width, 0f) - - if (isActive) { - if (!initial) { - TAB_LEFT_CONNECTION.render(graphics, 0f, height - TAB_LEFT_CONNECTION.height - 1) + if (tabIndex() == 0) { + if (isDisabled) { + TAB_ACTIVE0_DISABLED.render(graphics, x = -2f) + } else if (isPressed) { + TAB_ACTIVE0_PRESSED.render(graphics, x = -2f) + } else if (isHovered) { + TAB_ACTIVE0_HOVERED.render(graphics, x = -2f) + } else { + TAB_ACTIVE0_IDLE.render(graphics, x = -2f) + } + } else { + if (isDisabled) { + TAB_ACTIVE_DISABLED.render(graphics, x = -2f) + } else if (isPressed) { + TAB_ACTIVE_PRESSED.render(graphics, x = -2f) + } else if (isHovered) { + TAB_ACTIVE_HOVERED.render(graphics, x = -2f) + } else { + TAB_ACTIVE_IDLE.render(graphics, x = -2f) + } } - TAB_RIGHT_CONNECTION.render( - graphics, - width - TAB_RIGHT_CONNECTION.width, - height - TAB_LEFT_CONNECTION.height - 1 - ) - - val skinActive = activeIcon ?: return - skinActive.render(graphics, TAB_WIDTH_ACTIVE / 2f, TAB_HEIGHT_ACTIVE / 2f, gravity = RenderGravity.CENTER_CENTER) + activeIcon?.render(graphics, x = width / 2f - 1f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER) } else { - val skinInactive = inactiveIcon ?: return - skinInactive.render(graphics, width / 2f, TAB_HEIGHT_ACTIVE / 2f, gravity = RenderGravity.CENTER_CENTER) + if (tabIndex() == 0) { + if (isDisabled) { + TAB_INACTIVE0_DISABLED.render(graphics) + } else if (isPressed) { + TAB_INACTIVE0_PRESSED.render(graphics) + } else if (isHovered) { + TAB_INACTIVE0_HOVERED.render(graphics) + } else { + TAB_INACTIVE0_IDLE.render(graphics) + } + } else { + if (isDisabled) { + TAB_INACTIVE_DISABLED.render(graphics) + } else if (isPressed) { + TAB_INACTIVE_PRESSED.render(graphics) + } else if (isHovered) { + TAB_INACTIVE_HOVERED.render(graphics) + } else { + TAB_INACTIVE_IDLE.render(graphics) + } + } + + inactiveIcon?.render(graphics, x = width / 2f - 1f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER) } } @@ -118,6 +132,11 @@ open class FramePanel( onOpen() } } + + override fun onRemoved() { + super.onRemoved() + tabs.remove(this) + } } inner class CloseButton : AbstractButtonPanel(screen, this@FramePanel, this@FramePanel.width - CLOSE_BUTTON.width, 0f, CLOSE_BUTTON.width, CLOSE_BUTTON.height) { @@ -200,8 +219,7 @@ open class FramePanel( override fun performLayout() { for ((i, tab) in tabs.withIndex()) { - tab.setPos(i * TAB_WIDTH, -TAB_HEIGHT) - tab.initial = i == 0 + tab.setPos(i * 28f, -28f) } closeButton?.setPos(width - CLOSE_BUTTON.width, 0f) @@ -385,9 +403,25 @@ open class FramePanel( padding = DockProperty(-3f, -3f, -3f, -3f) ) - val TAB_RIGHT_CONNECTION = WidgetLocation.MISC.sprite(x = 30f, y = 0f, width = 3f, height = 5f) - val TAB_LEFT_CONNECTION = WidgetLocation.MISC.sprite(x = 33f, y = 0f, width = 3f, height = 5f) - val TAB_BACKGROUND = WidgetLocation.MISC.sprite(x = 30f, y = 6f, width = 6f, height = 6f) + val TAB_INACTIVE0_IDLE = WidgetLocation.TABS.sprite(x = 26f * 0f, width = 26f, height = 32f) + val TAB_INACTIVE0_HOVERED = WidgetLocation.TABS.sprite(x = 26f * 1f, width = 26f, height = 32f) + val TAB_INACTIVE0_PRESSED = WidgetLocation.TABS.sprite(x = 26f * 2f, width = 26f, height = 32f) + val TAB_INACTIVE0_DISABLED = WidgetLocation.TABS.sprite(x = 26f * 3f, width = 26f, height = 32f) + + val TAB_INACTIVE_IDLE = WidgetLocation.TABS.sprite(x = 26f * 0f, y = 32f, width = 26f, height = 32f) + val TAB_INACTIVE_HOVERED = WidgetLocation.TABS.sprite(x = 26f * 1f, y = 32f, width = 26f, height = 32f) + val TAB_INACTIVE_PRESSED = WidgetLocation.TABS.sprite(x = 26f * 2f, y = 32f, width = 26f, height = 32f) + val TAB_INACTIVE_DISABLED = WidgetLocation.TABS.sprite(x = 26f * 3f, y = 32f, width = 26f, height = 32f) + + val TAB_ACTIVE0_IDLE = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 0f, width = 30f, height = 32f) + val TAB_ACTIVE0_HOVERED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 1f, width = 30f, height = 32f) + val TAB_ACTIVE0_PRESSED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 2f, width = 30f, height = 32f) + val TAB_ACTIVE0_DISABLED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 3f, width = 30f, height = 32f) + + val TAB_ACTIVE_IDLE = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 0f, y = 32f, width = 30f, height = 32f) + val TAB_ACTIVE_HOVERED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 1f, y = 32f, width = 30f, height = 32f) + val TAB_ACTIVE_PRESSED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 2f, y = 32f, width = 30f, height = 32f) + val TAB_ACTIVE_DISABLED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 3f, y = 32f, width = 30f, height = 32f) val CLOSE_BUTTON = WidgetLocation.MISC.sprite(x = 51f, y = 0f, width = 13f, height = 14f) val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 14f, width = 13f, height = 14f) @@ -396,10 +430,5 @@ open class FramePanel( val HELP_BUTTON = WidgetLocation.MISC.sprite(x = 40f, y = 0f, width = 11f, height = 14f) val HELP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 40f, y = 14f, width = 11f, height = 14f) val HELP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 40f, y = 28f, width = 11f, height = 14f) - - const val TAB_HEIGHT = 28f - const val TAB_WIDTH = 28f - const val TAB_HEIGHT_ACTIVE = 32f - const val TAB_WIDTH_ACTIVE = 28f } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/tabs.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/tabs.png new file mode 100644 index 0000000000000000000000000000000000000000..660791b65715f565e057f22126bd24fd4523ea56 GIT binary patch literal 1201 zcmeAS@N?(olHy`uVBq!ia0vp^4}jQ#gAGVB8&>l(Ffg`cIy(n=Iy);A6y>L7=A<$( zXiTh~XzOv))G7Dl&QVtRYK8Aag$7spcom}>rKt_ z-J$H_>9Mjgtd1X;k6bmEm&y_qlP zeD6HGMo06=^CQA+u@inwe7)&({v2;UZX4sAl*^xwBqnXVa$NWa^wU5`E zHqP|FBrU63#KM!qEPh?q_a3uedBZ~WSR)npPnSiyTp#@H*{8|RbC2n7c3%G5+BtR% zk*~6TvRPQL9P^&C_ua>L``+FAXM6eGdv@z@Mc>cPJ8cMz7PcgBcNZWH1V5d3*8?fe z0*}aI1_nK45N51cYF`EvWH0gbb!C6fF3Ty(UU+QQ2cVE-iEBiObAE1aYF-J0b5Uwy zNotBhd1gt5g1e`0KzJjcI0FMyr>Bc!NX4zUcMbg>JBYA7Fz?7NXxy@sD@H+m!AZ>y zk@*Z-t74cqIhS~3YQ#L%yVthi-kOtorz_e_?_Y0Vy0re`&;DSA{UY|I6XT^Se9!HF zdgat)>!f!NTi3n*^nB@*K4VFooq~`ruQ(5_vtx>7mck;Fi3U0ia z!&iTC`~1Co_N1KNxqEkaN5`_vy3;%N>^U>7xUle}w_klg`}Lw5Z_EC!Z=N4CZ~pwv zPuE_5{cp~tl}c~E|IXRj-`@{3B|_)l4C_ZSmsc|N*CMF0XercJ-%i z^>21NJ)a%rXE^)pvQsm~x?QK$@ULSir=#TVff9s`JATL(_8!*_7B=`0Lg@RJ8$vN zX#Cr7c}8;Y&R_l#D?ET+BJ3%+idR}YWi^*g`}}Lg$Bm_}>pRz7+WJGc_%7rAeIkOH zYmRUEF8h{UXIk|Z`3({8F4i3Y3tsyE^*giHga4NfF>U|4@Na`^QTsRMX(wcF@kb=R gT=lo%gXk literal 0 HcmV?d00001