Actual tabs sprites, and all 4 sprite states for them
This commit is contained in:
parent
1346a3774d
commit
ff308ee67a
@ -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)
|
||||
|
@ -34,7 +34,6 @@ open class FramePanel<out S : Screen>(
|
||||
var inactiveIcon: IGUIRenderable? = null,
|
||||
) : AbstractButtonPanel<S>(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<out S : Screen>(
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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 {
|
||||
width = TAB_WIDTH
|
||||
height = TAB_HEIGHT
|
||||
TAB_BACKGROUND.render(graphics, 2f, 2f, width - 4, height - 2)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
activeIcon?.render(graphics, x = width / 2f - 1f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER)
|
||||
} else {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
} else {
|
||||
val skinInactive = inactiveIcon ?: return
|
||||
skinInactive.render(graphics, width / 2f, TAB_HEIGHT_ACTIVE / 2f, gravity = RenderGravity.CENTER_CENTER)
|
||||
inactiveIcon?.render(graphics, x = width / 2f - 1f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER)
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,6 +132,11 @@ open class FramePanel<out S : Screen>(
|
||||
onOpen()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRemoved() {
|
||||
super.onRemoved()
|
||||
tabs.remove(this)
|
||||
}
|
||||
}
|
||||
|
||||
inner class CloseButton : AbstractButtonPanel<S>(screen, this@FramePanel, this@FramePanel.width - CLOSE_BUTTON.width, 0f, CLOSE_BUTTON.width, CLOSE_BUTTON.height) {
|
||||
@ -200,8 +219,7 @@ open class FramePanel<out S : Screen>(
|
||||
|
||||
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<out S : Screen>(
|
||||
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<out S : Screen>(
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in New Issue
Block a user