mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
make AtlasManager a property of RenderWindow
This commit is contained in:
parent
38e3602be3
commit
6d2f0e1de2
@ -25,8 +25,9 @@ import de.bixilon.minosoft.gui.rendering.camera.Camera
|
||||
import de.bixilon.minosoft.gui.rendering.font.Font
|
||||
import de.bixilon.minosoft.gui.rendering.font.FontLoader
|
||||
import de.bixilon.minosoft.gui.rendering.framebuffer.FramebufferManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.TextureLike
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.TextureLikeTexture
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.TextureLike
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.TextureLikeTexture
|
||||
import de.bixilon.minosoft.gui.rendering.input.key.DefaultKeyCombinations
|
||||
import de.bixilon.minosoft.gui.rendering.input.key.RenderWindowInputHandler
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.*
|
||||
@ -92,6 +93,8 @@ class RenderWindow(
|
||||
var tickCount = 0L
|
||||
var lastTickTimer = TimeUtil.time
|
||||
|
||||
val atlasManager = AtlasManager(this)
|
||||
|
||||
|
||||
var renderingState = RenderingStates.RUNNING
|
||||
private set(value) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -11,13 +11,13 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.atlas
|
||||
package de.bixilon.minosoft.gui.rendering.gui.atlas
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import glm_.vec2.Vec2
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class HUDAtlasElement(
|
||||
class AtlasElement(
|
||||
override val texture: AbstractTexture,
|
||||
val start: Vec2i,
|
||||
val end: Vec2i,
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -11,27 +11,31 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.atlas
|
||||
package de.bixilon.minosoft.gui.rendering.gui.atlas
|
||||
|
||||
import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||
import de.bixilon.kutil.json.JsonUtil.toJsonObject
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.assets.util.FileUtil.readJsonObject
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.toVec2i
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import glm_.vec2.Vec2
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class HUDAtlasManager(private val hudRenderer: HUDRenderer) {
|
||||
private lateinit var elements: Map<ResourceLocation, HUDAtlasElement>
|
||||
class AtlasManager(private val renderWindow: RenderWindow) {
|
||||
private lateinit var elements: Map<ResourceLocation, AtlasElement>
|
||||
var initialized = false
|
||||
private set
|
||||
|
||||
@Synchronized
|
||||
fun init() {
|
||||
val data = hudRenderer.connection.assetsManager[ATLAS_DATA].readJsonObject()
|
||||
val versionId = hudRenderer.connection.version.versionId
|
||||
check(!initialized)
|
||||
val data = renderWindow.connection.assetsManager[ATLAS_DATA].readJsonObject()
|
||||
val versionId = renderWindow.connection.version.versionId
|
||||
|
||||
val elements: MutableMap<ResourceLocation, HUDAtlasElement> = mutableMapOf()
|
||||
val elements: MutableMap<ResourceLocation, AtlasElement> = mutableMapOf()
|
||||
|
||||
for ((resourceLocationString, versions) in data) {
|
||||
val resourceLocation = resourceLocationString.toResourceLocation()
|
||||
@ -52,7 +56,7 @@ class HUDAtlasManager(private val hudRenderer: HUDRenderer) {
|
||||
}
|
||||
val versionData = versions[versionToUse.toString()].asJsonObject()
|
||||
|
||||
val texture = hudRenderer.renderWindow.textureManager.staticTextures.createTexture(versionData["texture"].toResourceLocation(), mipmaps = false)
|
||||
val texture = renderWindow.textureManager.staticTextures.createTexture(versionData["texture"].toResourceLocation(), mipmaps = false)
|
||||
val start = versionData["start"].toVec2i()
|
||||
val end = versionData["end"].toVec2i()
|
||||
val slots: MutableMap<Int, Vec2iBinding> = mutableMapOf()
|
||||
@ -67,7 +71,7 @@ class HUDAtlasManager(private val hudRenderer: HUDRenderer) {
|
||||
}
|
||||
}
|
||||
|
||||
val atlasElement = HUDAtlasElement(
|
||||
val atlasElement = AtlasElement(
|
||||
texture = texture,
|
||||
start = start,
|
||||
end = end,
|
||||
@ -78,6 +82,7 @@ class HUDAtlasManager(private val hudRenderer: HUDRenderer) {
|
||||
}
|
||||
|
||||
this.elements = elements
|
||||
this.initialized = true
|
||||
}
|
||||
|
||||
fun postInit() {
|
||||
@ -87,11 +92,11 @@ class HUDAtlasManager(private val hudRenderer: HUDRenderer) {
|
||||
}
|
||||
}
|
||||
|
||||
operator fun get(resourceLocation: ResourceLocation): HUDAtlasElement? {
|
||||
operator fun get(resourceLocation: ResourceLocation): AtlasElement? {
|
||||
return elements[resourceLocation]
|
||||
}
|
||||
|
||||
operator fun get(resourceLocation: String): HUDAtlasElement? {
|
||||
operator fun get(resourceLocation: String): AtlasElement? {
|
||||
return elements[resourceLocation.toResourceLocation()]
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.atlas
|
||||
package de.bixilon.minosoft.gui.rendering.gui.atlas
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import glm_.vec2.Vec2
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.atlas
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import glm_.vec2.Vec2
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class TextureLikeTexture(
|
||||
override val texture: AbstractTexture,
|
||||
override val uvStart: Vec2,
|
||||
override val uvEnd: Vec2,
|
||||
override val size: Vec2i,
|
||||
) : TextureLike
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.atlas
|
||||
package de.bixilon.minosoft.gui.rendering.gui.atlas
|
||||
|
||||
import glm_.vec2.Vec2i
|
||||
|
@ -16,9 +16,9 @@ package de.bixilon.minosoft.gui.rendering.gui.elements.items
|
||||
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedMap
|
||||
import de.bixilon.minosoft.data.registries.other.containers.Container
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.Vec2iBinding
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.Vec2iBinding
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import glm_.vec2.Vec2i
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -15,9 +15,9 @@ package de.bixilon.minosoft.gui.rendering.gui.elements.primitive
|
||||
|
||||
import de.bixilon.minosoft.data.text.ChatColors
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.TextureLike
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.TextureLike
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -13,10 +13,10 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.elements.util
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ImageElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil
|
||||
@ -25,8 +25,8 @@ import glm_.vec2.Vec2i
|
||||
|
||||
open class ProgressElement(
|
||||
hudRenderer: HUDRenderer,
|
||||
val emptyAtlasElement: HUDAtlasElement,
|
||||
val fullAtlasElement: HUDAtlasElement,
|
||||
val emptyAtlasElement: AtlasElement,
|
||||
val fullAtlasElement: AtlasElement,
|
||||
progress: Float = 0.0f,
|
||||
) : Element(hudRenderer) {
|
||||
var progress = progress
|
||||
@ -42,7 +42,7 @@ open class ProgressElement(
|
||||
protected lateinit var progressImage: ImageElement
|
||||
|
||||
|
||||
constructor(hudRenderer: HUDRenderer, atlasElements: Array<HUDAtlasElement>, progress: Float = 0.0f) : this(hudRenderer, atlasElements[0], atlasElements[1], progress)
|
||||
constructor(hudRenderer: HUDRenderer, atlasElements: Array<AtlasElement>, progress: Float = 0.0f) : this(hudRenderer, atlasElements[0], atlasElements[1], progress)
|
||||
|
||||
init {
|
||||
_size = emptyAtlasElement.size
|
||||
|
@ -25,7 +25,6 @@ import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegate
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.bossbar.BossbarHUDElement
|
||||
@ -77,7 +76,7 @@ class HUDRenderer(
|
||||
|
||||
private var lastTickTime = 0L
|
||||
|
||||
val atlasManager = HUDAtlasManager(this)
|
||||
val atlasManager = renderWindow.atlasManager
|
||||
|
||||
override val skipOther: Boolean
|
||||
get() = !enabled
|
||||
@ -123,7 +122,9 @@ class HUDRenderer(
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> { recalculateMatrices(it.size) })
|
||||
profile::scale.profileWatchRendering(this, profile = profile) { recalculateMatrices(scale = it) }
|
||||
atlasManager.init()
|
||||
if (!atlasManager.initialized) {
|
||||
atlasManager.init()
|
||||
}
|
||||
|
||||
registerDefaultElements()
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.gui.hud.atlas
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import glm_.vec2.Vec2
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class TextureLikeTexture(
|
||||
override val texture: AbstractTexture,
|
||||
override val uvStart: Vec2,
|
||||
override val uvEnd: Vec2,
|
||||
override val size: Vec2i,
|
||||
) : TextureLike
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -17,13 +17,13 @@ import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.data.bossbar.Bossbar
|
||||
import de.bixilon.minosoft.data.bossbar.BossbarColors
|
||||
import de.bixilon.minosoft.data.bossbar.BossbarNotches
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments.Companion.getOffset
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import glm_.vec2.Vec2i
|
||||
@ -32,7 +32,7 @@ import java.lang.Integer.max
|
||||
class BossbarElement(
|
||||
hudRenderer: HUDRenderer,
|
||||
val bossbar: Bossbar,
|
||||
val atlas: Array<Array<Array<HUDAtlasElement?>>>,
|
||||
val atlas: Array<Array<Array<AtlasElement?>>>,
|
||||
) : Element(hudRenderer), Pollable {
|
||||
private var color: BossbarColors = bossbar.color
|
||||
private var notches: BossbarNotches = bossbar.notches
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -13,26 +13,26 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.bossbar
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ImageElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.util.ProgressElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
open class BossbarProgressElement(
|
||||
hudRenderer: HUDRenderer,
|
||||
emptyProgressAtlasElement: HUDAtlasElement,
|
||||
fullProgressAtlasElement: HUDAtlasElement,
|
||||
emptyNotchesElement: HUDAtlasElement?,
|
||||
fullNotchesElement: HUDAtlasElement?,
|
||||
emptyProgressAtlasElement: AtlasElement,
|
||||
fullProgressAtlasElement: AtlasElement,
|
||||
emptyNotchesElement: AtlasElement?,
|
||||
fullNotchesElement: AtlasElement?,
|
||||
progress: Float = 0.0f,
|
||||
) : ProgressElement(hudRenderer, emptyProgressAtlasElement, fullProgressAtlasElement, progress) {
|
||||
private val emptyNotchesImage = emptyNotchesElement?.let { ImageElement(hudRenderer, it, emptyProgressAtlasElement.size) }
|
||||
private val fullNotchesImage = fullNotchesElement?.let { ImageElement(hudRenderer, it, emptyProgressAtlasElement.size) }
|
||||
|
||||
constructor(hudRenderer: HUDRenderer, progressElements: Array<HUDAtlasElement>, notchesElements: Array<HUDAtlasElement>?, progress: Float = 0.0f) : this(hudRenderer, progressElements[0], progressElements[1], notchesElements?.get(0), notchesElements?.get(1), progress)
|
||||
constructor(hudRenderer: HUDRenderer, progressElements: Array<AtlasElement>, notchesElements: Array<AtlasElement>?, progress: Float = 0.0f) : this(hudRenderer, progressElements[0], progressElements[1], notchesElements?.get(0), notchesElements?.get(1), progress)
|
||||
|
||||
override fun forceRender(offset: Vec2i, z: Int, consumer: GUIVertexConsumer, options: GUIVertexOptions?): Int {
|
||||
emptyImage.render(offset, z, consumer, options)
|
||||
|
@ -16,11 +16,11 @@ package de.bixilon.minosoft.gui.rendering.gui.hud.elements.hotbar
|
||||
import de.bixilon.kutil.math.MMath.ceil
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.data.text.RGBColor.Companion.asColor
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ImageElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import glm_.vec2.Vec2i
|
||||
@ -54,7 +54,7 @@ abstract class AbstractHotbarHealthElement(hudRenderer: HUDRenderer) : Element(h
|
||||
cacheUpToDate = false
|
||||
}
|
||||
|
||||
protected fun drawCanisters(offset: Vec2i, z: Int, consumer: GUIVertexConsumer, options: GUIVertexOptions?, atlasElement: HUDAtlasElement) {
|
||||
protected fun drawCanisters(offset: Vec2i, z: Int, consumer: GUIVertexConsumer, options: GUIVertexOptions?, atlasElement: AtlasElement) {
|
||||
for (heart in 0 until totalMaxHearts) {
|
||||
val row = heart / HEARTS_PER_ROW
|
||||
val column = heart % HEARTS_PER_ROW
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -22,10 +22,10 @@ import de.bixilon.minosoft.data.text.BaseComponent
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.data.text.RGBColor.Companion.asColor
|
||||
import de.bixilon.minosoft.data.text.TextComponent
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ImageElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import glm_.vec2.Vec2i
|
||||
@ -194,7 +194,7 @@ class HotbarHealthElement(hudRenderer: HUDRenderer) : AbstractHotbarHealthElemen
|
||||
|
||||
|
||||
val halfHeart = healthLeft < 1.5f
|
||||
val image = selectArray.unsafeCast<Array<HUDAtlasElement?>>()[when {
|
||||
val image = selectArray.unsafeCast<Array<AtlasElement?>>()[when {
|
||||
halfHeart -> 1
|
||||
else -> 0
|
||||
}]?.let { ImageElement(hudRenderer, it) }
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -14,11 +14,11 @@
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.hotbar
|
||||
|
||||
import de.bixilon.minosoft.data.registries.effects.DefaultStatusEffects
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ImageElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import glm_.vec2.Vec2i
|
||||
@ -111,14 +111,14 @@ class HotbarHungerElement(hudRenderer: HUDRenderer) : Element(hudRenderer), Poll
|
||||
continue
|
||||
}
|
||||
|
||||
val hungerElement: HUDAtlasElement
|
||||
val hungerElement: AtlasElement
|
||||
|
||||
if (hungerLeft == 1) {
|
||||
hungerLeft--
|
||||
hungerElement = selectArray[1] as HUDAtlasElement
|
||||
hungerElement = selectArray[1] as AtlasElement
|
||||
} else {
|
||||
hungerLeft -= 2
|
||||
hungerElement = selectArray[0] as HUDAtlasElement
|
||||
hungerElement = selectArray[0] as AtlasElement
|
||||
}
|
||||
|
||||
ImageElement(hudRenderer, hungerElement).render(hungerOffset, z + 1, consumer, options)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -18,8 +18,8 @@ import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.gui.rendering.camera.target.targets.EntityTarget
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.CustomHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
|
||||
@ -30,7 +30,7 @@ import de.bixilon.minosoft.util.collections.floats.DirectArrayFloatList
|
||||
class CrosshairHUDElement(hudRenderer: HUDRenderer) : CustomHUDElement(hudRenderer) {
|
||||
private val profile = hudRenderer.connection.profiles.hud
|
||||
private val crosshairProfile = profile.crosshair
|
||||
private lateinit var crosshairAtlasElement: HUDAtlasElement
|
||||
private lateinit var crosshairAtlasElement: AtlasElement
|
||||
private var mesh: GUIMesh? = null
|
||||
private var previousDebugEnabled: Boolean? = true
|
||||
private var reapply = true
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -17,13 +17,13 @@ import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedMap
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments.Companion.getOffset
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ColorElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.HUDAtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
@ -45,7 +45,7 @@ class TabListElement(hudRenderer: HUDRenderer) : Element(hudRenderer) {
|
||||
private set
|
||||
private var columns = 0
|
||||
|
||||
val pingBarsAtlasElements: Array<HUDAtlasElement> = arrayOf(
|
||||
val pingBarsAtlasElements: Array<AtlasElement> = arrayOf(
|
||||
hudRenderer.atlasManager["minecraft:tab_list_ping_0"]!!,
|
||||
hudRenderer.atlasManager["minecraft:tab_list_ping_1"]!!,
|
||||
hudRenderer.atlasManager["minecraft:tab_list_ping_2"]!!,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.gui.mesh
|
||||
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.TextureLike
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.TextureLike
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import glm_.vec2.Vec2
|
||||
import glm_.vec2.Vec2t
|
||||
|
Loading…
x
Reference in New Issue
Block a user