mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
hud: more debug info
This commit is contained in:
parent
cc166127f8
commit
6af9876cb1
@ -13,8 +13,13 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering
|
package de.bixilon.minosoft.gui.rendering
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.Minosoft
|
||||||
import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames
|
import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.gui.rendering.block.WorldRenderer
|
||||||
|
import de.bixilon.minosoft.gui.rendering.block.chunk.ChunkBorderRenderer
|
||||||
|
import de.bixilon.minosoft.gui.rendering.block.outline.BlockOutlineRenderer
|
||||||
|
import de.bixilon.minosoft.gui.rendering.entity.EntityHitBoxRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.font.Font
|
import de.bixilon.minosoft.gui.rendering.font.Font
|
||||||
import de.bixilon.minosoft.gui.rendering.font.FontLoader
|
import de.bixilon.minosoft.gui.rendering.font.FontLoader
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
|
||||||
@ -22,6 +27,8 @@ 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.hud.atlas.TextureLikeTexture
|
||||||
import de.bixilon.minosoft.gui.rendering.input.key.RenderWindowInputHandler
|
import de.bixilon.minosoft.gui.rendering.input.key.RenderWindowInputHandler
|
||||||
import de.bixilon.minosoft.gui.rendering.modding.events.*
|
import de.bixilon.minosoft.gui.rendering.modding.events.*
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.ParticleRenderer
|
||||||
|
import de.bixilon.minosoft.gui.rendering.sky.SkyRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.stats.AbstractRenderStats
|
import de.bixilon.minosoft.gui.rendering.stats.AbstractRenderStats
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.IntegratedBufferTypes
|
import de.bixilon.minosoft.gui.rendering.system.base.IntegratedBufferTypes
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.PolygonModes
|
import de.bixilon.minosoft.gui.rendering.system.base.PolygonModes
|
||||||
@ -111,7 +118,7 @@ class RenderWindow(
|
|||||||
})
|
})
|
||||||
|
|
||||||
// order dependent (from back to front)
|
// order dependent (from back to front)
|
||||||
/* registerRenderer(SkyRenderer)
|
registerRenderer(SkyRenderer)
|
||||||
registerRenderer(WorldRenderer)
|
registerRenderer(WorldRenderer)
|
||||||
registerRenderer(BlockOutlineRenderer)
|
registerRenderer(BlockOutlineRenderer)
|
||||||
if (Minosoft.config.config.game.graphics.particles.enabled) {
|
if (Minosoft.config.config.game.graphics.particles.enabled) {
|
||||||
@ -122,7 +129,7 @@ class RenderWindow(
|
|||||||
}
|
}
|
||||||
if (Minosoft.config.config.game.world.chunkBorders.enabled) {
|
if (Minosoft.config.config.game.world.chunkBorders.enabled) {
|
||||||
registerRenderer(ChunkBorderRenderer)
|
registerRenderer(ChunkBorderRenderer)
|
||||||
}*/
|
}
|
||||||
registerRenderer(HUDRenderer)
|
registerRenderer(HUDRenderer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import de.bixilon.minosoft.data.text.ChatColors
|
|||||||
import de.bixilon.minosoft.data.text.TextComponent
|
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.block.WorldRenderer
|
import de.bixilon.minosoft.gui.rendering.block.WorldRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.font.Font
|
|
||||||
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.elements.ElementAlignments
|
import de.bixilon.minosoft.gui.rendering.gui.elements.ElementAlignments
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.layout.RowLayout
|
import de.bixilon.minosoft.gui.rendering.gui.elements.layout.RowLayout
|
||||||
@ -29,15 +28,21 @@ 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.HUDRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.ParticleRenderer
|
import de.bixilon.minosoft.gui.rendering.particle.ParticleRenderer
|
||||||
|
import de.bixilon.minosoft.modding.event.events.DifficultyChangeEvent
|
||||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||||
|
import de.bixilon.minosoft.modding.loading.ModLoader
|
||||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||||
|
import de.bixilon.minosoft.util.GitInfo
|
||||||
|
import de.bixilon.minosoft.util.KUtil.decide
|
||||||
import de.bixilon.minosoft.util.KUtil.format
|
import de.bixilon.minosoft.util.KUtil.format
|
||||||
import de.bixilon.minosoft.util.MMath.round10
|
import de.bixilon.minosoft.util.MMath.round10
|
||||||
|
import de.bixilon.minosoft.util.SystemInformation
|
||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
import glm_.vec4.Vec4i
|
import glm_.vec4.Vec4i
|
||||||
|
|
||||||
class DebugHUD(val hudRenderer: HUDRenderer) : HUD<GridLayout> {
|
class DebugHUD(val hudRenderer: HUDRenderer) : HUD<GridLayout> {
|
||||||
override val renderWindow: RenderWindow = hudRenderer.renderWindow
|
override val renderWindow: RenderWindow = hudRenderer.renderWindow
|
||||||
|
private val connection = renderWindow.connection
|
||||||
override val layout = GridLayout(hudRenderer, Vec2i(3, 1)).apply {
|
override val layout = GridLayout(hudRenderer, Vec2i(3, 1)).apply {
|
||||||
columnConstraints[0].apply {
|
columnConstraints[0].apply {
|
||||||
grow = GridGrow.NEVER
|
grow = GridGrow.NEVER
|
||||||
@ -57,14 +62,14 @@ class DebugHUD(val hudRenderer: HUDRenderer) : HUD<GridLayout> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initLeft(): Element {
|
private fun initLeft(): Element {
|
||||||
val layout = RowLayout(hudRenderer, spacing = Font.VERTICAL_SPACING)
|
val layout = RowLayout(hudRenderer)
|
||||||
layout.margin = Vec4i(5)
|
layout.margin = Vec4i(5)
|
||||||
layout += TextElement(hudRenderer, TextComponent(RunConfiguration.VERSION_STRING, ChatColors.RED))
|
layout += TextElement(hudRenderer, TextComponent(RunConfiguration.VERSION_STRING, ChatColors.RED))
|
||||||
layout += AutoTextElement(hudRenderer, 1) { "FPS ${renderWindow.renderStats.smoothAvgFPS.round10}" }
|
layout += AutoTextElement(hudRenderer, 1) { "FPS ${renderWindow.renderStats.smoothAvgFPS.round10}" }
|
||||||
renderWindow[WorldRenderer]?.apply {
|
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) { "C v=${visibleChunks.size}, p=${allChunkSections.size}, q=${queuedChunks.size}, t=${connection.world.chunks.size}" }
|
||||||
}
|
}
|
||||||
layout += AutoTextElement(hudRenderer, 1) { "E t=${renderWindow.connection.world.entities.size}" }
|
layout += AutoTextElement(hudRenderer, 1) { "E t=${connection.world.entities.size}" }
|
||||||
|
|
||||||
renderWindow[ParticleRenderer]?.apply {
|
renderWindow[ParticleRenderer]?.apply {
|
||||||
layout += AutoTextElement(hudRenderer, 1) { "P t=$size" }
|
layout += AutoTextElement(hudRenderer, 1) { "P t=$size" }
|
||||||
@ -73,30 +78,65 @@ class DebugHUD(val hudRenderer: HUDRenderer) : HUD<GridLayout> {
|
|||||||
layout += LineSpacerElement(hudRenderer)
|
layout += LineSpacerElement(hudRenderer)
|
||||||
|
|
||||||
|
|
||||||
renderWindow.connection.player.apply {
|
connection.player.apply {
|
||||||
layout += AutoTextElement(hudRenderer, 1) { with(position) { "XYZ ${x.format()} / ${y.format()} / ${z.format()}" } }
|
layout += AutoTextElement(hudRenderer, 1) { with(position) { "XYZ ${x.format()} / ${y.format()} / ${z.format()}" } }
|
||||||
layout += AutoTextElement(hudRenderer, 1) { with(positionInfo.blockPosition) { "Block $x $y $z" } }
|
layout += AutoTextElement(hudRenderer, 1) { with(positionInfo.blockPosition) { "Block $x $y $z" } }
|
||||||
}
|
}
|
||||||
|
|
||||||
layout += LineSpacerElement(hudRenderer)
|
layout += LineSpacerElement(hudRenderer)
|
||||||
|
|
||||||
|
val chunk = connection.world[connection.player.positionInfo.chunkPosition]
|
||||||
|
|
||||||
|
if (chunk == null) {
|
||||||
|
layout += TextElement(hudRenderer, "Waiting for chunk...") // ToDo
|
||||||
|
}
|
||||||
|
|
||||||
|
layout += LineSpacerElement(hudRenderer)
|
||||||
|
|
||||||
|
layout += TextElement(hudRenderer, "Difficulty ${connection.world.difficulty.format()}, ${connection.world.difficultyLocked.decide("locked", "unlocked")}", ElementAlignments.RIGHT).apply {
|
||||||
|
connection.registerEvent(CallbackEventInvoker.of<DifficultyChangeEvent> {
|
||||||
|
text = "Difficulty ${it.difficulty.format()}, ${it.locked.decide("locked", "unlocked")}"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return layout
|
return layout
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initRight(): Element {
|
private fun initRight(): Element {
|
||||||
val layout = RowLayout(hudRenderer, ElementAlignments.RIGHT, Font.VERTICAL_SPACING)
|
val layout = RowLayout(hudRenderer, ElementAlignments.RIGHT)
|
||||||
layout.margin = Vec4i(5)
|
layout.margin = Vec4i(5)
|
||||||
layout += TextElement(hudRenderer, "Java ${Runtime.version()} ${System.getProperty("sun.arch.data.model")}bit", ElementAlignments.RIGHT)
|
layout += TextElement(hudRenderer, "Java ${Runtime.version()} ${System.getProperty("sun.arch.data.model")}bit", ElementAlignments.RIGHT)
|
||||||
|
|
||||||
layout += LineSpacerElement(hudRenderer)
|
layout += LineSpacerElement(hudRenderer)
|
||||||
|
|
||||||
|
layout += TextElement(hudRenderer, "OS ${SystemInformation.OS_TEXT}", ElementAlignments.RIGHT)
|
||||||
|
layout += TextElement(hudRenderer, "CPU ${SystemInformation.PROCESSOR_TEXT}", ElementAlignments.RIGHT)
|
||||||
|
|
||||||
|
layout += LineSpacerElement(hudRenderer)
|
||||||
|
|
||||||
layout += TextElement(hudRenderer, "Display TBA", ElementAlignments.RIGHT).apply {
|
layout += TextElement(hudRenderer, "Display TBA", ElementAlignments.RIGHT).apply {
|
||||||
hudRenderer.connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
|
hudRenderer.connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
|
||||||
text = "Display ${it.size.x}x${it.size.y}"
|
text = "Display ${it.size.x}x${it.size.y}"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
renderWindow.renderSystem.apply {
|
renderWindow.renderSystem.apply {
|
||||||
layout += TextElement(hudRenderer, "GPU $vendorString", ElementAlignments.RIGHT)
|
layout += TextElement(hudRenderer, "GPU $gpuType", ElementAlignments.RIGHT)
|
||||||
layout += TextElement(hudRenderer, "Version $version", ElementAlignments.RIGHT)
|
layout += TextElement(hudRenderer, "Version $version", ElementAlignments.RIGHT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GitInfo.IS_INITIALIZED) {
|
||||||
|
layout += LineSpacerElement(hudRenderer)
|
||||||
|
|
||||||
|
GitInfo.apply {
|
||||||
|
layout += TextElement(hudRenderer, "Git $GIT_COMMIT_ID_ABBREV: $GIT_COMMIT_MESSAGE_SHORT", ElementAlignments.RIGHT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
layout += LineSpacerElement(hudRenderer)
|
||||||
|
|
||||||
|
layout += TextElement(hudRenderer, "Mods ${ModLoader.MOD_MAP.size}x loaded, ${connection.size}x listeners", ElementAlignments.RIGHT)
|
||||||
|
|
||||||
return layout
|
return layout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 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.modding.event.events
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.Difficulties
|
||||||
|
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||||
|
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.play.ServerDifficultyS2CP
|
||||||
|
|
||||||
|
class DifficultyChangeEvent(
|
||||||
|
connection: PlayConnection,
|
||||||
|
initiator: EventInitiators = EventInitiators.DEFAULT,
|
||||||
|
val difficulty: Difficulties,
|
||||||
|
val locked: Boolean,
|
||||||
|
) : PlayConnectionEvent(connection, initiator) {
|
||||||
|
|
||||||
|
constructor(connection: PlayConnection, packet: ServerDifficultyS2CP) : this(connection, EventInitiators.SERVER, packet.difficulty, packet.locked)
|
||||||
|
}
|
@ -13,6 +13,7 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.s2c.play
|
package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.Difficulties
|
import de.bixilon.minosoft.data.Difficulties
|
||||||
|
import de.bixilon.minosoft.modding.event.events.DifficultyChangeEvent
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
@ -35,6 +36,7 @@ class ServerDifficultyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
|||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
connection.world.difficulty = difficulty
|
connection.world.difficulty = difficulty
|
||||||
connection.world.difficultyLocked = locked
|
connection.world.difficultyLocked = locked
|
||||||
|
connection.fireEvent(DifficultyChangeEvent(connection, this))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log() {
|
override fun log() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user