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 scissor = true
} }
private val cosButton: EditablePanel<S>?
private val exosuitButton: EditablePanel<S>?
init { init {
if (entity is Player && isCosmeticArmorLoaded) { 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) { if (entity is Player) {
val matteryPlayer = entity.matteryPlayer val matteryPlayer = entity.matteryPlayer
if (matteryPlayer != null && matteryPlayer.hasExoSuit) { 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(), prop = matteryPlayer::displayExoSuit.asGetterOnly(),
skinElementActive = Widgets8.EXOSUIT_SHOWN, skinElementActive = Widgets8.EXOSUIT_SHOWN,
skinElementInactive = Widgets8.EXOSUIT_HIDDEN, 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() { override fun performLayout() {
super.performLayout() super.performLayout()
val cosButton = children.firstOrNull { it is CosmeticToggleRenderButton } as CosmeticToggleRenderButton?
if (cosButton != null) { if (cosButton != null) {
cosButton.x = this.width - 7f cosButton.x = this.width - 7f
cosButton.y = this.height - 7f cosButton.y = this.height - 7f
} }
val toggleButton = children.firstOrNull { it is SmallBooleanRectangleButtonPanel } as SmallBooleanRectangleButtonPanel? if (exosuitButton != null) {
exosuitButton.x = this.width - 2f - exosuitButton.width
if (toggleButton != null) { exosuitButton.y = 2f
toggleButton.x = this.width - 2f - toggleButton.width
toggleButton.y = 2f
} }
} }
} }