Unify player armor strip logic
This commit is contained in:
parent
fafa42b9b7
commit
2c037b755a
@ -706,11 +706,8 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
val playerStrip = EditablePanel(this, frame, height = 72f)
|
||||
playerStrip.dock = Dock.TOP
|
||||
|
||||
val armorStrip = EditablePanel(this, playerStrip, width = AbstractSlotPanel.SIZE)
|
||||
armorStrip.dock = Dock.LEFT
|
||||
|
||||
for (slot in menu.armorSlots) {
|
||||
SlotPanel(this, armorStrip, slot).also { it.dock = Dock.TOP }
|
||||
makeArmorStrip(menu.armorSlots, playerStrip).also {
|
||||
it.dock = Dock.LEFT
|
||||
}
|
||||
|
||||
EntityRendererPanel(this, playerStrip, minecraft!!.player!!).also {
|
||||
|
@ -101,26 +101,8 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuit
|
||||
topLine.dock = Dock.TOP
|
||||
topLine.setDockMargin(top = 3f)
|
||||
|
||||
val armorSlotsStrip = EditablePanel(this, topLine, width = 18f)
|
||||
armorSlotsStrip.dock = Dock.LEFT
|
||||
|
||||
for (slot in menu.armorSlots) {
|
||||
val cosmeticSlot = menu.cosmeticArmorSlots[slot.type]
|
||||
|
||||
if (cosmeticSlot == null) {
|
||||
SlotPanel(this, armorSlotsStrip, slot).also {
|
||||
it.dock = Dock.TOP
|
||||
}
|
||||
} else {
|
||||
FoldableSlotPanel(this, armorSlotsStrip,
|
||||
SlotPanel(this, null, slot).also {
|
||||
CosmeticToggleButton(this, it, slot.type)
|
||||
},
|
||||
listOf(SlotPanel(this, null, cosmeticSlot))
|
||||
).also {
|
||||
it.dock = Dock.TOP
|
||||
}
|
||||
}
|
||||
makeArmorStrip(menu.armorSlots, topLine).also {
|
||||
it.dock = Dock.LEFT
|
||||
}
|
||||
|
||||
val playerRectangle = EntityRendererPanel(this, topLine, minecraft!!.player!!)
|
||||
|
@ -19,6 +19,7 @@ import org.lwjgl.opengl.GL13
|
||||
import ru.dbotthepony.mc.otm.ClientConfig
|
||||
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
||||
import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton
|
||||
import ru.dbotthepony.mc.otm.core.maxScrollDivision
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
import java.util.Collections
|
||||
@ -533,6 +534,30 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
}
|
||||
}
|
||||
|
||||
fun makeArmorStrip(slots: Collection<Pair<MatteryMenu.EquipmentSlot, Slot?>>, parent: EditablePanel<*>? = null): EditablePanel<*> {
|
||||
val armorSlotsStrip = EditablePanel(this, parent, width = 18f)
|
||||
armorSlotsStrip.dock = Dock.LEFT
|
||||
|
||||
for ((slot, cosmeticSlot) in slots) {
|
||||
if (cosmeticSlot == null) {
|
||||
SlotPanel(this, armorSlotsStrip, slot).also {
|
||||
it.dock = Dock.TOP
|
||||
}
|
||||
} else {
|
||||
FoldableSlotPanel(this, armorSlotsStrip,
|
||||
SlotPanel(this, null, slot).also {
|
||||
CosmeticToggleButton(this, it, slot.type)
|
||||
},
|
||||
listOf(SlotPanel(this, null, cosmeticSlot))
|
||||
).also {
|
||||
it.dock = Dock.TOP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return armorSlotsStrip
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_FRAME_WIDTH = AbstractSlotPanel.SIZE * 9f + 16f
|
||||
const val DEFAULT_FRAME_HEIGHT = 100f
|
||||
|
@ -117,13 +117,21 @@ class AndroidStationMenu @JvmOverloads constructor(
|
||||
val armorSlots = makeArmorSlots()
|
||||
|
||||
init {
|
||||
armorSlots.forEach(this::addSlot)
|
||||
for ((a, b) in armorSlots) {
|
||||
addSlot(a)
|
||||
if (b != null) addSlot(b)
|
||||
}
|
||||
|
||||
addInventorySlots()
|
||||
|
||||
addSlot(androidBattery)
|
||||
|
||||
val builder = ImmutableList.builder<Slot>()
|
||||
builder.addAll(armorSlots)
|
||||
|
||||
for ((a, _) in armorSlots) {
|
||||
builder.add(a)
|
||||
}
|
||||
|
||||
builder.add(androidBattery)
|
||||
storageSlots = builder.build()
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
}
|
||||
}
|
||||
|
||||
val armorSlots: List<EquipmentSlot> = makeArmorSlots()
|
||||
val armorSlots: List<kotlin.Pair<EquipmentSlot, Slot?>> = makeArmorSlots()
|
||||
|
||||
val offhandSlot = object : InventorySlot(capability.ply.inventory, 40) {
|
||||
override fun getNoItemIcon(): Pair<ResourceLocation, ResourceLocation> {
|
||||
@ -66,7 +66,11 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
|
||||
craftingSlots.forEach(this::addSlot)
|
||||
addSlot(offhandSlot)
|
||||
armorSlots.forEach(this::addSlot)
|
||||
|
||||
for ((a, b) in armorSlots) {
|
||||
addSlot(a)
|
||||
if (b != null) addSlot(b)
|
||||
}
|
||||
|
||||
val builder = ImmutableList.builder<Slot>()
|
||||
|
||||
@ -86,8 +90,6 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
}
|
||||
}
|
||||
|
||||
val cosmeticArmorSlots: Map<net.minecraft.world.entity.EquipmentSlot, Slot> = ply.cosmeticArmorSlots?.also { it.values.forEach(this::addSlot) } ?: mapOf()
|
||||
|
||||
override fun slotsChanged(container: Container) {
|
||||
super.slotsChanged(container)
|
||||
|
||||
|
@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.Dock
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel
|
||||
import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots
|
||||
import ru.dbotthepony.mc.otm.container.ItemFilter
|
||||
import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot
|
||||
import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget
|
||||
@ -431,12 +432,16 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
|
||||
super.addDataSlots(p_38885_)
|
||||
}
|
||||
|
||||
fun makeArmorSlots(): List<EquipmentSlot> = ImmutableList.of(
|
||||
EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.HEAD),
|
||||
EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.CHEST),
|
||||
EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS),
|
||||
EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET),
|
||||
)
|
||||
fun makeArmorSlots(): List<kotlin.Pair<EquipmentSlot, Slot?>> {
|
||||
val cosmetic = ply.cosmeticArmorSlots
|
||||
|
||||
return ImmutableList.of(
|
||||
EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.HEAD) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.HEAD),
|
||||
EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.CHEST) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.CHEST),
|
||||
EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.LEGS),
|
||||
EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.FEET),
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TEXTURE_EMPTY_SLOTS: List<ResourceLocation> = ImmutableList.of(
|
||||
|
Loading…
Reference in New Issue
Block a user