mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
wip debug hud
This commit is contained in:
parent
061f2e0f39
commit
1b25e8e19a
@ -27,6 +27,9 @@ class WorldEntities : Iterable<Entity> {
|
|||||||
private val entityUUIDMap: MutableMap<Entity, UUID> = synchronizedMapOf()
|
private val entityUUIDMap: MutableMap<Entity, UUID> = synchronizedMapOf()
|
||||||
private val uuidEntityMap: MutableMap<UUID, Entity> = synchronizedMapOf()
|
private val uuidEntityMap: MutableMap<UUID, Entity> = synchronizedMapOf()
|
||||||
|
|
||||||
|
val size: Int
|
||||||
|
get() = idEntityMap.size
|
||||||
|
|
||||||
|
|
||||||
fun add(entityId: Int?, entityUUID: UUID?, entity: Entity) {
|
fun add(entityId: Int?, entityUUID: UUID?, entity: Entity) {
|
||||||
check(entityId != null || entityUUID != null) { "Entity id and UUID is null!" }
|
check(entityId != null || entityUUID != null) { "Entity id and UUID is null!" }
|
||||||
|
@ -15,7 +15,6 @@ package de.bixilon.minosoft.gui.eros.main
|
|||||||
|
|
||||||
import de.bixilon.minosoft.Minosoft
|
import de.bixilon.minosoft.Minosoft
|
||||||
import de.bixilon.minosoft.ShutdownReasons
|
import de.bixilon.minosoft.ShutdownReasons
|
||||||
import de.bixilon.minosoft.config.StaticConfiguration
|
|
||||||
import de.bixilon.minosoft.data.accounts.Account
|
import de.bixilon.minosoft.data.accounts.Account
|
||||||
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
||||||
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
|
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
|
||||||
@ -26,8 +25,7 @@ import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.clickable
|
|||||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.ctext
|
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.ctext
|
||||||
import de.bixilon.minosoft.modding.event.events.account.AccountSelectEvent
|
import de.bixilon.minosoft.modding.event.events.account.AccountSelectEvent
|
||||||
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
|
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
|
||||||
import de.bixilon.minosoft.util.GitInfo
|
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||||
import de.bixilon.minosoft.util.KUtil.decide
|
|
||||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
import de.bixilon.minosoft.util.ShutdownManager
|
import de.bixilon.minosoft.util.ShutdownManager
|
||||||
import de.bixilon.minosoft.util.task.pool.DefaultThreadPool
|
import de.bixilon.minosoft.util.task.pool.DefaultThreadPool
|
||||||
@ -79,7 +77,7 @@ class MainErosController : JavaFXWindowController() {
|
|||||||
|
|
||||||
override fun init() {
|
override fun init() {
|
||||||
logoFX.image = JavaFXUtil.MINOSOFT_LOGO
|
logoFX.image = JavaFXUtil.MINOSOFT_LOGO
|
||||||
versionTextFX.text = "Minosoft " + GitInfo.IS_INITIALIZED.decide(GitInfo.GIT_COMMIT_ID_ABBREV, StaticConfiguration.VERSION)
|
versionTextFX.text = RunConfiguration.VERSION_STRING
|
||||||
iconMap = mapOf(
|
iconMap = mapOf(
|
||||||
ErosMainActivities.PlAY to playIconFX,
|
ErosMainActivities.PlAY to playIconFX,
|
||||||
ErosMainActivities.SETTINGS to settingsIconFX,
|
ErosMainActivities.SETTINGS to settingsIconFX,
|
||||||
|
@ -65,6 +65,7 @@ class Rendering(private val connection: PlayConnection) {
|
|||||||
CONTEXT_MAP.remove(Thread.currentThread())
|
CONTEXT_MAP.remove(Thread.currentThread())
|
||||||
exception.printStackTrace()
|
exception.printStackTrace()
|
||||||
try {
|
try {
|
||||||
|
renderWindow.window.close()
|
||||||
connection.fireEvent(WindowCloseEvent(window = renderWindow.window))
|
connection.fireEvent(WindowCloseEvent(window = renderWindow.window))
|
||||||
} catch (ignored: Throwable) {
|
} catch (ignored: Throwable) {
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.gui.elements
|
package de.bixilon.minosoft.gui.rendering.gui.elements
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||||
import de.bixilon.minosoft.gui.rendering.util.vec.Vec2Util.EMPTY
|
import de.bixilon.minosoft.gui.rendering.util.vec.Vec2Util.EMPTY
|
||||||
import de.bixilon.minosoft.gui.rendering.util.vec.Vec2Util.MAX
|
import de.bixilon.minosoft.gui.rendering.util.vec.Vec2Util.MAX
|
||||||
@ -20,12 +21,13 @@ import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.EMPTY
|
|||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
import glm_.vec4.Vec4i
|
import glm_.vec4.Vec4i
|
||||||
|
|
||||||
abstract class Element {
|
abstract class Element(val hudRenderer: HUDRenderer) {
|
||||||
|
val renderWindow = hudRenderer.renderWindow
|
||||||
open var parent: Element? = null
|
open var parent: Element? = null
|
||||||
open var prepared: Boolean = false
|
open var prepared: Boolean = false
|
||||||
|
|
||||||
open var minSize: Vec2i = Vec2i.EMPTY
|
open var minSize: Vec2i = Vec2i.EMPTY
|
||||||
open var prefMaxSize: Vec2i = Vec2i.MAX
|
open var prefMaxSize: Vec2i = Vec2i(-1, -1)
|
||||||
open var size: Vec2i = Vec2i()
|
open var size: Vec2i = Vec2i()
|
||||||
|
|
||||||
open var margin: Vec4i = Vec4i.EMPTY
|
open var margin: Vec4i = Vec4i.EMPTY
|
||||||
@ -43,6 +45,13 @@ abstract class Element {
|
|||||||
|
|
||||||
val maxSize = Vec2i(prefMaxSize)
|
val maxSize = Vec2i(prefMaxSize)
|
||||||
|
|
||||||
|
if (maxSize.x < 0) {
|
||||||
|
maxSize.x = hudRenderer.scaledSize.x.toInt()
|
||||||
|
}
|
||||||
|
if (maxSize.y < 0) {
|
||||||
|
maxSize.y = hudRenderer.scaledSize.y.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
if (maxSize.x < ret.x) {
|
if (maxSize.x < ret.x) {
|
||||||
ret.x = maxSize.x
|
ret.x = maxSize.x
|
||||||
}
|
}
|
||||||
@ -59,5 +68,7 @@ abstract class Element {
|
|||||||
abstract fun render(offset: Vec2i, z: Int, consumer: GUIVertexConsumer): Int
|
abstract fun render(offset: Vec2i, z: Int, consumer: GUIVertexConsumer): Int
|
||||||
|
|
||||||
|
|
||||||
open fun childChange(child: Element) {}
|
open fun childChange(child: Element?) {}
|
||||||
|
|
||||||
|
open fun tick() {}
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,6 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.gui.elements.layout
|
package de.bixilon.minosoft.gui.rendering.gui.elements.layout
|
||||||
|
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||||
|
|
||||||
abstract class Layout : Element()
|
abstract class Layout(hudRenderer: HUDRenderer) : Element(hudRenderer)
|
||||||
|
@ -14,21 +14,29 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.gui.elements.layout
|
package de.bixilon.minosoft.gui.rendering.gui.elements.layout
|
||||||
|
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
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.mesh.GUIVertexConsumer
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||||
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.bottom
|
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.bottom
|
||||||
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.horizontal
|
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.horizontal
|
||||||
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.left
|
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.left
|
||||||
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.top
|
import de.bixilon.minosoft.gui.rendering.util.vec.Vec4Util.top
|
||||||
import de.bixilon.minosoft.util.KUtil.synchronizedListOf
|
import de.bixilon.minosoft.util.KUtil.synchronizedListOf
|
||||||
|
import de.bixilon.minosoft.util.KUtil.toSynchronizedList
|
||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A layout, that works from top to bottom, containing other elements, that get wrapped below each other
|
* A layout, that works from top to bottom, containing other elements, that get wrapped below each other
|
||||||
*/
|
*/
|
||||||
class RowLayout : Layout() {
|
class RowLayout(hudRenderer: HUDRenderer) : Layout(hudRenderer) {
|
||||||
// ToDo: Spacing between elements
|
// ToDo: Spacing between elements
|
||||||
private val children: MutableList<Element> = synchronizedListOf()
|
private val children: MutableList<Element> = synchronizedListOf()
|
||||||
|
|
||||||
|
|
||||||
|
fun clear() {
|
||||||
|
children.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun render(offset: Vec2i, z: Int, consumer: GUIVertexConsumer): Int {
|
override fun render(offset: Vec2i, z: Int, consumer: GUIVertexConsumer): Int {
|
||||||
var childYOffset = 0
|
var childYOffset = 0
|
||||||
var totalZ = 0
|
var totalZ = 0
|
||||||
@ -53,7 +61,7 @@ class RowLayout : Layout() {
|
|||||||
parent?.childChange(this)
|
parent?.childChange(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun childChange(child: Element) {
|
override fun childChange(child: Element?) {
|
||||||
super.childChange(child)
|
super.childChange(child)
|
||||||
|
|
||||||
// ToDo: Check max size
|
// ToDo: Check max size
|
||||||
@ -76,4 +84,12 @@ class RowLayout : Layout() {
|
|||||||
|
|
||||||
this.size = size
|
this.size = size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun tick() {
|
||||||
|
super.tick()
|
||||||
|
|
||||||
|
for (child in children.toSynchronizedList()) {
|
||||||
|
child.tick()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.elements.text
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||||
|
|
||||||
|
open class AutoTextElement(
|
||||||
|
hudRenderer: HUDRenderer,
|
||||||
|
var interval: Int,
|
||||||
|
private val updater: () -> Any,
|
||||||
|
) : TextElement(hudRenderer, "TBD") {
|
||||||
|
private var remainingTicks = 0
|
||||||
|
|
||||||
|
override fun tick() {
|
||||||
|
super.tick()
|
||||||
|
|
||||||
|
if (remainingTicks-- > 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
text = updater()
|
||||||
|
|
||||||
|
remainingTicks = interval
|
||||||
|
}
|
||||||
|
}
|
@ -14,5 +14,6 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.gui.elements.text
|
package de.bixilon.minosoft.gui.rendering.gui.elements.text
|
||||||
|
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||||
|
|
||||||
abstract class LabeledElement : Element(), Labeled
|
abstract class LabeledElement(hudRenderer: HUDRenderer) : Element(hudRenderer), Labeled
|
||||||
|
@ -14,16 +14,16 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.gui.elements.text
|
package de.bixilon.minosoft.gui.rendering.gui.elements.text
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
|
||||||
import de.bixilon.minosoft.gui.rendering.font.renderer.ChatComponentRenderer
|
import de.bixilon.minosoft.gui.rendering.font.renderer.ChatComponentRenderer
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
import glm_.vec4.Vec4i
|
import glm_.vec4.Vec4i
|
||||||
|
|
||||||
class TextElement(
|
open class TextElement(
|
||||||
private val renderWindow: RenderWindow,
|
hudRenderer: HUDRenderer,
|
||||||
text: Any,
|
text: Any,
|
||||||
) : LabeledElement() {
|
) : LabeledElement(hudRenderer) {
|
||||||
override var text: Any = text
|
override var text: Any = text
|
||||||
set(value) {
|
set(value) {
|
||||||
textComponent = ChatComponent.of(value)
|
textComponent = ChatComponent.of(value)
|
||||||
@ -32,7 +32,7 @@ class TextElement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override var textComponent: ChatComponent = ChatComponent.of("")
|
override var textComponent: ChatComponent = ChatComponent.of("")
|
||||||
private set(value) {
|
protected set(value) {
|
||||||
field = value
|
field = value
|
||||||
prepare(value)
|
prepare(value)
|
||||||
}
|
}
|
||||||
|
@ -15,24 +15,23 @@ package de.bixilon.minosoft.gui.rendering.gui.hud
|
|||||||
|
|
||||||
import de.bixilon.minosoft.Minosoft
|
import de.bixilon.minosoft.Minosoft
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.text.ChatColors
|
|
||||||
import de.bixilon.minosoft.data.text.PreChatFormattingCodes
|
|
||||||
import de.bixilon.minosoft.data.text.TextComponent
|
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||||
import de.bixilon.minosoft.gui.rendering.Renderer
|
import de.bixilon.minosoft.gui.rendering.Renderer
|
||||||
import de.bixilon.minosoft.gui.rendering.RendererBuilder
|
import de.bixilon.minosoft.gui.rendering.RendererBuilder
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.layout.RowLayout
|
import de.bixilon.minosoft.gui.rendering.gui.hud.hud.DebugHUD
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
import de.bixilon.minosoft.gui.rendering.gui.hud.hud.HUD
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
|
||||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||||
|
import de.bixilon.minosoft.gui.rendering.util.vec.Vec2Util.EMPTY
|
||||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
|
import de.bixilon.minosoft.util.KUtil.synchronizedListOf
|
||||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
import glm_.glm
|
import glm_.glm
|
||||||
import glm_.mat4x4.Mat4
|
import glm_.mat4x4.Mat4
|
||||||
import glm_.vec2.Vec2
|
import glm_.vec2.Vec2
|
||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
import glm_.vec4.Vec4i
|
|
||||||
|
|
||||||
class HUDRenderer(
|
class HUDRenderer(
|
||||||
val connection: PlayConnection,
|
val connection: PlayConnection,
|
||||||
@ -43,16 +42,30 @@ class HUDRenderer(
|
|||||||
var scaledSize: Vec2 = renderWindow.window.sizef
|
var scaledSize: Vec2 = renderWindow.window.sizef
|
||||||
private var matrix: Mat4 = Mat4()
|
private var matrix: Mat4 = Mat4()
|
||||||
|
|
||||||
|
val hud: MutableList<HUD<*>> = synchronizedListOf(
|
||||||
|
DebugHUD(this),
|
||||||
|
)
|
||||||
|
|
||||||
|
private var lastTickTime = 0L
|
||||||
|
|
||||||
override fun init() {
|
override fun init() {
|
||||||
connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
|
connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
|
||||||
scaledSize = Vec2(it.size) / Minosoft.config.config.game.hud.scale
|
scaledSize = Vec2(it.size) / Minosoft.config.config.game.hud.scale
|
||||||
matrix = glm.ortho(0.0f, scaledSize.x, scaledSize.y, 0.0f)
|
matrix = glm.ortho(0.0f, scaledSize.x, scaledSize.y, 0.0f)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for (hud in this.hud) {
|
||||||
|
hud.init()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun postInit() {
|
override fun postInit() {
|
||||||
shader.load()
|
shader.load()
|
||||||
renderWindow.textureManager.staticTextures.use(shader)
|
renderWindow.textureManager.staticTextures.use(shader)
|
||||||
|
|
||||||
|
for (hud in this.hud) {
|
||||||
|
hud.postInit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun draw() {
|
override fun draw() {
|
||||||
@ -62,96 +75,29 @@ class HUDRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mesh = GUIMesh(renderWindow, matrix)
|
mesh = GUIMesh(renderWindow, matrix)
|
||||||
val text1 = TextElement(
|
|
||||||
renderWindow = renderWindow,
|
|
||||||
text = TextComponent(
|
|
||||||
message = "Moritz ist toll!!!",
|
|
||||||
color = ChatColors.RED,
|
|
||||||
formatting = mutableSetOf(
|
|
||||||
PreChatFormattingCodes.BOLD,
|
|
||||||
PreChatFormattingCodes.SHADOWED,
|
|
||||||
PreChatFormattingCodes.UNDERLINED,
|
|
||||||
PreChatFormattingCodes.ITALIC,
|
|
||||||
PreChatFormattingCodes.STRIKETHROUGH,
|
|
||||||
PreChatFormattingCodes.OBFUSCATED
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
val time = System.currentTimeMillis()
|
||||||
|
if (time - lastTickTime > ProtocolDefinition.TICK_TIME) {
|
||||||
|
for (hud in this.hud) {
|
||||||
|
hud.tick()
|
||||||
|
}
|
||||||
|
|
||||||
val text2 = TextElement(
|
lastTickTime = time
|
||||||
renderWindow = renderWindow,
|
}
|
||||||
text = TextComponent(
|
|
||||||
message = "Moritz\nist toll!!!",
|
|
||||||
color = ChatColors.BLUE,
|
|
||||||
formatting = mutableSetOf(
|
|
||||||
PreChatFormattingCodes.BOLD,
|
|
||||||
PreChatFormattingCodes.SHADOWED,
|
|
||||||
PreChatFormattingCodes.UNDERLINED,
|
|
||||||
PreChatFormattingCodes.ITALIC,
|
|
||||||
PreChatFormattingCodes.STRIKETHROUGH,
|
|
||||||
PreChatFormattingCodes.OBFUSCATED
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
val text3 = TextElement(
|
|
||||||
renderWindow = renderWindow,
|
|
||||||
text = TextComponent(
|
|
||||||
message = "!T→E↓S←T~_OÄBÖMÜ",
|
|
||||||
color = ChatColors.YELLOW,
|
|
||||||
formatting = mutableSetOf(
|
|
||||||
PreChatFormattingCodes.UNDERLINED,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
val text4 = TextElement(
|
|
||||||
renderWindow = renderWindow,
|
|
||||||
text = TextComponent(
|
|
||||||
message = "Noch viel längerer dummy normaler Text!",
|
|
||||||
color = ChatColors.GREEN,
|
|
||||||
formatting = mutableSetOf(
|
|
||||||
PreChatFormattingCodes.SHADOWED,
|
|
||||||
PreChatFormattingCodes.UNDERLINED,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
val text5 = TextElement(
|
|
||||||
renderWindow = renderWindow,
|
|
||||||
text = TextComponent(
|
|
||||||
message = "AäB",
|
|
||||||
color = ChatColors.GREEN,
|
|
||||||
formatting = mutableSetOf(
|
|
||||||
PreChatFormattingCodes.SHADOWED,
|
|
||||||
PreChatFormattingCodes.UNDERLINED,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
text3.prefMaxSize = Vec2i(50, Int.MAX_VALUE)
|
|
||||||
text4.prefMaxSize = Vec2i(50, Int.MAX_VALUE)
|
|
||||||
text4.margin = Vec4i(10, 0, 5, 10)
|
|
||||||
|
|
||||||
// ToDo: size > maxSize
|
// ToDo: size > maxSize
|
||||||
|
|
||||||
val layout = RowLayout()
|
|
||||||
|
|
||||||
layout.padding = Vec4i(4, 0, 0, 10)
|
for (hud in this.hud) {
|
||||||
|
val z = 0
|
||||||
|
val offset = Vec2i.EMPTY // ToDo
|
||||||
|
|
||||||
layout += text1
|
hud.layout?.render(offset, z, mesh)
|
||||||
layout += text2
|
hud.draw(offset, z, mesh)
|
||||||
layout += text3
|
}
|
||||||
layout += text4
|
|
||||||
layout += text5
|
|
||||||
|
|
||||||
|
|
||||||
layout.render(Vec2i(0, 0), 0, mesh)
|
|
||||||
|
|
||||||
mesh.load()
|
mesh.load()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
shader.use()
|
shader.use()
|
||||||
mesh.draw()
|
mesh.draw()
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.hud
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.text.ChatColors
|
||||||
|
import de.bixilon.minosoft.data.text.TextComponent
|
||||||
|
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||||
|
import de.bixilon.minosoft.gui.rendering.block.WorldRenderer
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.elements.layout.RowLayout
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.elements.text.AutoTextElement
|
||||||
|
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.particle.ParticleRenderer
|
||||||
|
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||||
|
import de.bixilon.minosoft.util.KUtil.format
|
||||||
|
import de.bixilon.minosoft.util.MMath.round10
|
||||||
|
|
||||||
|
class DebugHUD(val hudRenderer: HUDRenderer) : HUD<RowLayout> {
|
||||||
|
override val renderWindow: RenderWindow = hudRenderer.renderWindow
|
||||||
|
override val layout = RowLayout(hudRenderer)
|
||||||
|
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
layout += TextElement(hudRenderer, TextComponent(RunConfiguration.VERSION_STRING, ChatColors.RED))
|
||||||
|
layout += AutoTextElement(hudRenderer, 1) { "FPS ${renderWindow.renderStats.smoothAvgFPS.round10}" }
|
||||||
|
renderWindow[WorldRenderer]?.apply {
|
||||||
|
layout += AutoTextElement(hudRenderer, 1) { "C v=${visibleChunks.size}, p=${allChunkSections.size}, q=${queuedChunks.size}, t=${renderWindow.connection.world.chunks.size}" }
|
||||||
|
}
|
||||||
|
layout += AutoTextElement(hudRenderer, 1) { "E t=${renderWindow.connection.world.entities.size}" }
|
||||||
|
|
||||||
|
renderWindow[ParticleRenderer]?.apply {
|
||||||
|
layout += AutoTextElement(hudRenderer, 1) { "P t=$size" }
|
||||||
|
}
|
||||||
|
|
||||||
|
layout += TextElement(hudRenderer, "") // ToDo: Spacer element
|
||||||
|
|
||||||
|
|
||||||
|
renderWindow.connection.player.apply {
|
||||||
|
layout += AutoTextElement(hudRenderer, 1) { with(position) { "XYZ ${x.format()} / ${y.format()} / ${z.format()}" } }
|
||||||
|
layout += AutoTextElement(hudRenderer, 1) { with(positionInfo.blockPosition) { "Block $x $y $z" } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.hud
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.elements.layout.Layout
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||||
|
import glm_.vec2.Vec2i
|
||||||
|
|
||||||
|
interface HUD<T : Layout> {
|
||||||
|
val renderWindow: RenderWindow
|
||||||
|
|
||||||
|
val layout: T?
|
||||||
|
get() = null
|
||||||
|
|
||||||
|
fun init() {}
|
||||||
|
|
||||||
|
fun postInit() {}
|
||||||
|
|
||||||
|
fun draw(offset: Vec2i, z: Int, consumer: GUIVertexConsumer) {}
|
||||||
|
|
||||||
|
fun tick() {
|
||||||
|
layout?.tick()
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,9 @@ class ParticleRenderer(
|
|||||||
|
|
||||||
private var particles: MutableSet<Particle> = synchronizedSetOf()
|
private var particles: MutableSet<Particle> = synchronizedSetOf()
|
||||||
|
|
||||||
|
val size: Int
|
||||||
|
get() = particles.size
|
||||||
|
|
||||||
override fun init() {
|
override fun init() {
|
||||||
connection.registerEvent(CallbackEventInvoker.of<CameraMatrixChangeEvent> {
|
connection.registerEvent(CallbackEventInvoker.of<CameraMatrixChangeEvent> {
|
||||||
renderWindow.queue += {
|
renderWindow.queue += {
|
||||||
|
@ -42,7 +42,7 @@ class BlockDustParticle(connection: PlayConnection, position: Vec3d, velocity: V
|
|||||||
}
|
}
|
||||||
|
|
||||||
texture = when (renderer) {
|
texture = when (renderer) {
|
||||||
is BlockRenderer -> renderer.textureMapping.iterator().next().value
|
is BlockRenderer -> renderer.textureMapping.iterator().next().value // ToDo: If this is empty the rendering crashes
|
||||||
is FluidRenderer -> renderer.stillTexture // ToDo
|
is FluidRenderer -> renderer.stillTexture // ToDo
|
||||||
else -> TODO()
|
else -> TODO()
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ class PlayConnection(
|
|||||||
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.FATAL) { exception }
|
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.FATAL) { exception }
|
||||||
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.FATAL) { "Could not load version $version. This version seems to be unsupported" }
|
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.FATAL) { "Could not load version $version. This version seems to be unsupported" }
|
||||||
version.unload()
|
version.unload()
|
||||||
error = RegistriesLoadingException("Mappings could not be loaded", exception)
|
error = RegistriesLoadingException("Registries could not be loaded", exception)
|
||||||
retry = false
|
retry = false
|
||||||
}
|
}
|
||||||
latch.dec()
|
latch.dec()
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.terminal
|
package de.bixilon.minosoft.terminal
|
||||||
|
|
||||||
import com.google.common.base.StandardSystemProperty
|
import com.google.common.base.StandardSystemProperty
|
||||||
|
import de.bixilon.minosoft.config.StaticConfiguration
|
||||||
import de.bixilon.minosoft.util.OSUtil
|
import de.bixilon.minosoft.util.OSUtil
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -49,5 +50,8 @@ object RunConfiguration {
|
|||||||
}
|
}
|
||||||
folder.absolutePath + "/"
|
folder.absolutePath + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
val TEMPORARY_FOLDER = System.getProperty("java.io.tmpdir", "$HOME_DIRECTORY/tmp/") + "/"
|
val TEMPORARY_FOLDER = System.getProperty("java.io.tmpdir", "$HOME_DIRECTORY/tmp/") + "/"
|
||||||
|
|
||||||
|
var VERSION_STRING = "Minosoft $StaticConfiguration.VERSION"
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.util
|
|||||||
import de.bixilon.minosoft.Minosoft
|
import de.bixilon.minosoft.Minosoft
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
|
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||||
import de.bixilon.minosoft.util.KUtil.toBoolean
|
import de.bixilon.minosoft.util.KUtil.toBoolean
|
||||||
import de.bixilon.minosoft.util.KUtil.toInt
|
import de.bixilon.minosoft.util.KUtil.toInt
|
||||||
import de.bixilon.minosoft.util.KUtil.unsafeCast
|
import de.bixilon.minosoft.util.KUtil.unsafeCast
|
||||||
@ -105,6 +106,8 @@ object GitInfo {
|
|||||||
}
|
}
|
||||||
GIT_TOTAL_COMMIT_COUNT = json["git.total.commit.count"].toInt()
|
GIT_TOTAL_COMMIT_COUNT = json["git.total.commit.count"].toInt()
|
||||||
|
|
||||||
|
|
||||||
|
RunConfiguration.VERSION_STRING = "Minosoft $GIT_COMMIT_ID_ABBREV"
|
||||||
IS_INITIALIZED = true
|
IS_INITIALIZED = true
|
||||||
} catch (exception: Throwable) {
|
} catch (exception: Throwable) {
|
||||||
Log.log(LogMessageType.OTHER, level = LogLevels.WARN) { "Could not load git information." }
|
Log.log(LogMessageType.OTHER, level = LogLevels.WARN) { "Could not load git information." }
|
||||||
|
@ -31,6 +31,9 @@ class LongAverage(override val nanos: Long) : Average<Long> {
|
|||||||
}
|
}
|
||||||
cleanup()
|
cleanup()
|
||||||
val data = data.toSynchronizedList()
|
val data = data.toSynchronizedList()
|
||||||
|
if (data.size == 0) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
var total = 0L
|
var total = 0L
|
||||||
for ((_, value) in data) {
|
for ((_, value) in data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user