rendering: hud: RowLayout

This commit is contained in:
Bixilon 2021-05-05 17:18:20 +02:00
parent 82483282fe
commit cd16c9d495
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 43 additions and 8 deletions

View File

@ -70,7 +70,7 @@ data class Biome(
waterFogColor = TintColorCalculator.getJsonColor(data["water_fog_color"]?.asInt ?: 0),
category = mappings.biomeCategoryRegistry.get(data["category"]?.asInt ?: -1) ?: DEFAULT_CATEGORY,
precipitation = mappings.biomePrecipitationRegistry.get(data["precipitation"]?.asInt ?: -1) ?: DEFAULT_PRECIPITATION,
skyColor = data["sky_color"]?.asInt?.let { it.asRGBColor() } ?: RenderConstants.GRASS_FAILOVER_COLOR,
skyColor = data["sky_color"]?.asInt?.asRGBColor() ?: RenderConstants.GRASS_FAILOVER_COLOR,
foliageColorOverride = TintColorCalculator.getJsonColor(data["foliage_color_override"]?.asInt ?: 0),
grassColorOverride = TintColorCalculator.getJsonColor(data["grass_color_override"]?.asInt ?: 0),
descriptionId = data["water_fog_color"]?.asString,

View File

@ -18,14 +18,16 @@ import de.bixilon.minosoft.gui.rendering.hud.HUDElementProperties
import de.bixilon.minosoft.gui.rendering.hud.HUDRenderBuilder
import de.bixilon.minosoft.gui.rendering.hud.HUDRenderer
import de.bixilon.minosoft.gui.rendering.hud.nodes.HUDElement
import de.bixilon.minosoft.gui.rendering.hud.nodes.layout.AbsoluteLayout
import de.bixilon.minosoft.gui.rendering.hud.nodes.primitive.ImageNode
import de.bixilon.minosoft.gui.rendering.hud.nodes.properties.NodeSizing
import glm_.vec2.Vec2
import glm_.vec2.Vec2i
class CrosshairHUDElement(
hudRender: HUDRenderer,
) : HUDElement(hudRender) {
hudRenderer: HUDRenderer,
) : HUDElement(hudRenderer) {
override val layout = AbsoluteLayout(hudRenderer.renderWindow)
private lateinit var crosshairImage: ImageNode
override fun init() {

View File

@ -16,10 +16,10 @@ package de.bixilon.minosoft.gui.rendering.hud.nodes
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.gui.rendering.hud.HUDElementProperties
import de.bixilon.minosoft.gui.rendering.hud.HUDRenderer
import de.bixilon.minosoft.gui.rendering.hud.nodes.layout.AbsoluteLayout
import de.bixilon.minosoft.gui.rendering.hud.nodes.layout.Layout
abstract class HUDElement(protected val hudRenderer: HUDRenderer) {
val layout = AbsoluteLayout(hudRenderer.renderWindow)
abstract val layout: Layout
lateinit var properties: HUDElementProperties

View File

@ -22,11 +22,13 @@ import de.bixilon.minosoft.gui.rendering.hud.HUDRenderer
import de.bixilon.minosoft.gui.rendering.hud.elements.input.TextField
import de.bixilon.minosoft.gui.rendering.hud.elements.input.TextFieldProperties
import de.bixilon.minosoft.gui.rendering.hud.nodes.HUDElement
import de.bixilon.minosoft.gui.rendering.hud.nodes.layout.AbsoluteLayout
import de.bixilon.minosoft.gui.rendering.util.abstractions.ScreenResizeCallback
import glm_.vec2.Vec2
import glm_.vec2.Vec2i
class ChatBoxHUDElement(hudRenderer: HUDRenderer) : HUDElement(hudRenderer), ScreenResizeCallback {
override val layout = AbsoluteLayout(hudRenderer.renderWindow)
private lateinit var inputField: TextField
override fun init() {

View File

@ -16,16 +16,16 @@ package de.bixilon.minosoft.gui.rendering.hud.nodes.debug
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.gui.rendering.hud.HUDRenderer
import de.bixilon.minosoft.gui.rendering.hud.nodes.HUDElement
import de.bixilon.minosoft.gui.rendering.hud.nodes.layout.RowLayout
import de.bixilon.minosoft.gui.rendering.hud.nodes.primitive.LabelNode
import glm_.vec2.Vec2i
abstract class DebugScreenNode(hudRenderer: HUDRenderer) : HUDElement(hudRenderer) {
override val layout = RowLayout(hudRenderer.renderWindow)
protected var lastPrepareTime = 0L
fun text(text: String = ""): LabelNode {
val textElement = LabelNode(hudRenderer.renderWindow, text = ChatComponent.of(text))
layout.addChild(Vec2i(0, layout.sizing.currentSize.y), textElement)
layout.apply()
layout.addRow(textElement)
return textElement
}
}

View File

@ -0,0 +1,31 @@
/*
* Minosoft
* Copyright (C) 2021 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.hud.nodes.layout
import de.bixilon.minosoft.gui.rendering.RenderWindow
import de.bixilon.minosoft.gui.rendering.hud.nodes.primitive.Node
import de.bixilon.minosoft.gui.rendering.hud.nodes.properties.NodeSizing
import glm_.vec2.Vec2i
class RowLayout(
renderWindow: RenderWindow,
sizing: NodeSizing = NodeSizing(),
initialCacheSize: Int = DEFAULT_INITIAL_CACHE_SIZE,
) : AbsoluteLayout(renderWindow, sizing, initialCacheSize) {
fun addRow(node: Node) {
addChild(Vec2i(0, sizing.currentSize.y + node.sizing.margin.top + node.sizing.padding.top), node)
apply()
}
}