frame tabs icons, pattern panel tab icons

This commit is contained in:
DBotThePony 2022-09-03 21:11:15 +07:00
parent a142e4da98
commit 3ab641efb4
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 21 additions and 6 deletions

View File

@ -7,7 +7,8 @@ import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.capability.matter.IPatternState
import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask
import ru.dbotthepony.mc.otm.capability.matter.PatternState
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.element
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.maxScrollDivision
@ -35,8 +36,8 @@ class MatterPanelScreen(
scrollBar.dock = Dock.RIGHT
frame.Tab(onOpen = { isPatternView = true })
frame.Tab(onOpen = { isPatternView = false })
frame.Tab(onOpen = { isPatternView = true }, activeIcon = PATTERN_LIST_ACTIVE, inactiveIcon = PATTERN_LIST_INACTIVE)
frame.Tab(onOpen = { isPatternView = false }, activeIcon = TASK_LIST_ACTIVE, inactiveIcon = TASK_LIST_INACTIVE)
val canvas = object : EditablePanel(this@MatterPanelScreen, frame, width = GRID_WIDTH * AbstractSlotPanel.SIZE) {
init {
@ -291,5 +292,10 @@ class MatterPanelScreen(
companion object {
const val GRID_HEIGHT = 8
const val GRID_WIDTH = 9
val PATTERN_LIST_ACTIVE = WidgetLocation.WIDGETS.element(36f, 0f, 14f, 23f)
val TASK_LIST_ACTIVE = WidgetLocation.WIDGETS.element(64f, 0f, 16f, 16f)
val PATTERN_LIST_INACTIVE = WidgetLocation.WIDGETS.element(50f, 0f, 14f, 23f)
val TASK_LIST_INACTIVE = WidgetLocation.WIDGETS.element(80f, 0f, 16f, 16f)
}
}

View File

@ -22,9 +22,12 @@ open class FramePanel(
) : EditablePanel(screen, parent, x, y, width, height), NarratableEntry {
constructor(screen: MatteryScreen<*>, width: Float, height: Float, title: Component) : this(screen, null, 0f, 0f, width, height, title)
open inner class Tab(var onOpen: Runnable? = null, var onClose: Runnable? = null) :
EditablePanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) {
open inner class Tab(
var onOpen: Runnable? = null,
var onClose: Runnable? = null,
var activeIcon: SkinElement? = null,
var inactiveIcon: SkinElement? = null,
) : EditablePanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) {
var isActive = tabs.isEmpty()
var initial = false
@ -78,6 +81,12 @@ open class FramePanel(
width - TAB_RIGHT_CONNECTION.w,
height - TAB_LEFT_CONNECTION.h - 1
)
val skinActive = activeIcon ?: return
skinActive.render(stack, TAB_WIDTH_ACTIVE / 2f - skinActive.w / 2f, TAB_HEIGHT_ACTIVE / 2f - skinActive.h / 2f)
} else {
val skinInactive = inactiveIcon ?: return
skinInactive.render(stack, width / 2f - skinInactive.w / 2f, TAB_HEIGHT_ACTIVE / 2f - skinInactive.h / 2f)
}
}