mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
furnace: show container title
This commit is contained in:
parent
36af4bb474
commit
38b8f8e64a
@ -13,29 +13,14 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui.screen.container
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.minosoft.data.container.types.CraftingContainer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.container.text.ContainerText
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class CraftingContainerScreen(guiRenderer: GUIRenderer, container: CraftingContainer) : BackgroundedContainerScreen<CraftingContainer>(guiRenderer, container, guiRenderer.atlasManager["minecraft:crafting_container".toResourceLocation()]) {
|
||||
private val title = ContainerText.of(guiRenderer, atlasElement?.areas?.get("crafting_text"), container.title)
|
||||
private val inventoryTitle = ContainerText.createInventoryTitle(guiRenderer, atlasElement?.areas?.get("inventory_text"))
|
||||
class CraftingContainerScreen(guiRenderer: GUIRenderer, container: CraftingContainer) : LabeledContainerScreen<CraftingContainer>(guiRenderer, container, guiRenderer.atlasManager["minecraft:crafting_container".toResourceLocation()]) {
|
||||
|
||||
|
||||
override fun forceRender(offset: Vec2i, consumer: GUIVertexConsumer, options: GUIVertexOptions?) {
|
||||
super.forceRender(offset, consumer, options)
|
||||
val centerOffset = offset + (size - containerBackground.size) / 2
|
||||
if (container.title != null) {
|
||||
title?.render(centerOffset, consumer, options)
|
||||
}
|
||||
inventoryTitle?.render(centerOffset, consumer, options)
|
||||
}
|
||||
|
||||
companion object : ContainerGUIFactory<CraftingContainerScreen, CraftingContainer> {
|
||||
override val clazz: KClass<CraftingContainer> = CraftingContainer::class
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui.screen.container
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.minosoft.data.container.Container
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasSlot
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.container.text.ContainerText
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
|
||||
abstract class LabeledContainerScreen<C : Container>(
|
||||
guiRenderer: GUIRenderer,
|
||||
container: C,
|
||||
atlasElement: AtlasElement?,
|
||||
items: Int2ObjectOpenHashMap<AtlasSlot> = atlasElement?.slots ?: Int2ObjectOpenHashMap(),
|
||||
) : BackgroundedContainerScreen<C>(guiRenderer, container, atlasElement, items) {
|
||||
protected val titleText = ContainerText.of(guiRenderer, atlasElement?.areas?.get("title"), container.title)
|
||||
protected val inventoryTitleText = ContainerText.createInventoryTitle(guiRenderer, atlasElement?.areas?.get("inventory_text"))
|
||||
|
||||
override fun forceRenderContainerScreen(offset: Vec2i, consumer: GUIVertexConsumer, options: GUIVertexOptions?) {
|
||||
super.forceRenderContainerScreen(offset, consumer, options)
|
||||
|
||||
if (container.title != null) {
|
||||
titleText?.render(offset, consumer, options)
|
||||
}
|
||||
inventoryTitleText?.render(offset, consumer, options)
|
||||
}
|
||||
}
|
@ -16,10 +16,10 @@ package de.bixilon.minosoft.gui.rendering.gui.gui.screen.container.processing
|
||||
import de.bixilon.minosoft.data.container.types.processing.ProcessingContainer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.container.BackgroundedContainerScreen
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.container.LabeledContainerScreen
|
||||
|
||||
abstract class ProcessingContainerScreen<C : ProcessingContainer>(
|
||||
guiRenderer: GUIRenderer,
|
||||
container: C,
|
||||
atlasElement: AtlasElement?,
|
||||
) : BackgroundedContainerScreen<C>(guiRenderer, container, atlasElement)
|
||||
) : LabeledContainerScreen<C>(guiRenderer, container, atlasElement)
|
||||
|
@ -1315,7 +1315,7 @@
|
||||
}
|
||||
},
|
||||
"areas": {
|
||||
"crafting_text": {
|
||||
"title": {
|
||||
"start": [29, 3],
|
||||
"end": [172, 16]
|
||||
},
|
||||
@ -1540,6 +1540,14 @@
|
||||
"process": {
|
||||
"start": [79, 35],
|
||||
"end": [103, 50]
|
||||
},
|
||||
"title": {
|
||||
"start": [29, 3],
|
||||
"end": [172, 16]
|
||||
},
|
||||
"inventory_text": {
|
||||
"start": [3, 70],
|
||||
"end": [172, 83]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user