mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
rendering: hud: RowLayout
This commit is contained in:
parent
82483282fe
commit
cd16c9d495
@ -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,
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user