Remove entity renderer panel button hacks

This commit is contained in:
DBotThePony 2022-10-21 22:49:51 +07:00
parent b6b7ea6a77
commit 00f759d1a5
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -52,16 +52,21 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
scissor = true
}
private val cosButton: EditablePanel<S>?
private val exosuitButton: EditablePanel<S>?
init {
if (entity is Player && isCosmeticArmorLoaded) {
CosmeticToggleRenderButton(screen, this, x = this.width - 7f, y = this.height - 7f)
cosButton = CosmeticToggleRenderButton(screen, this, x = this.width - 7f, y = this.height - 7f)
} else {
cosButton = null
}
if (entity is Player) {
val matteryPlayer = entity.matteryPlayer
if (matteryPlayer != null && matteryPlayer.hasExoSuit) {
SmallBooleanRectangleButtonPanel(screen, this, this.width - 2f - SmallBooleanRectangleButtonPanel.SIZE, 2f,
exosuitButton = SmallBooleanRectangleButtonPanel(screen, this, this.width - 2f - SmallBooleanRectangleButtonPanel.SIZE, 2f,
prop = matteryPlayer::displayExoSuit.asGetterOnly(),
skinElementActive = Widgets8.EXOSUIT_SHOWN,
skinElementInactive = Widgets8.EXOSUIT_HIDDEN,
@ -73,7 +78,11 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
}
}
)
} else {
exosuitButton = null
}
} else {
exosuitButton = null
}
}
@ -98,18 +107,14 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
override fun performLayout() {
super.performLayout()
val cosButton = children.firstOrNull { it is CosmeticToggleRenderButton } as CosmeticToggleRenderButton?
if (cosButton != null) {
cosButton.x = this.width - 7f
cosButton.y = this.height - 7f
}
val toggleButton = children.firstOrNull { it is SmallBooleanRectangleButtonPanel } as SmallBooleanRectangleButtonPanel?
if (toggleButton != null) {
toggleButton.x = this.width - 2f - toggleButton.width
toggleButton.y = 2f
if (exosuitButton != null) {
exosuitButton.x = this.width - 2f - exosuitButton.width
exosuitButton.y = 2f
}
}
}