diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/hud/elements/text/HUDTextElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/hud/elements/text/HUDTextElement.kt index 1c8545a1a..722c2905f 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/hud/elements/text/HUDTextElement.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/hud/elements/text/HUDTextElement.kt @@ -132,8 +132,8 @@ class HUDTextElement : HUDElement { private fun adjustPositionsForLineBreaks(newLinePositions: MutableList) { var y = when (alignment) { - HUDElementPositionAnchors.TOP_LEFT, HUDElementPositionAnchors.BOTTOM_LEFT -> super.getPositionAtAnchor(HUDElementPositionAnchors.TOP_LEFT).y - HUDElementPositionAnchors.TOP_RIGHT, HUDElementPositionAnchors.BOTTOM_RIGHT -> super.getPositionAtAnchor(HUDElementPositionAnchors.BOTTOM_RIGHT).y - (newLinePositions.size - 2) * (Font.CHAR_HEIGHT + 1) * Minosoft.getConfig().config.game.hud.scale.toInt() + HUDElementPositionAnchors.TOP_LEFT, HUDElementPositionAnchors.TOP_RIGHT -> super.getPositionAtAnchor(HUDElementPositionAnchors.TOP_LEFT).y + HUDElementPositionAnchors.BOTTOM_LEFT, HUDElementPositionAnchors.BOTTOM_RIGHT -> super.getPositionAtAnchor(HUDElementPositionAnchors.BOTTOM_RIGHT).y - (newLinePositions.size - 2) * (Font.CHAR_HEIGHT + 1) * Minosoft.getConfig().config.game.hud.scale.toInt() else -> TODO() } val left = super.getPositionAtAnchor(HUDElementPositionAnchors.TOP_LEFT).x diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/hud/elements/text/HUDTextTranslator.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/hud/elements/text/HUDTextTranslator.kt index 1e733677c..15f69ef23 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/hud/elements/text/HUDTextTranslator.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/hud/elements/text/HUDTextTranslator.kt @@ -29,6 +29,7 @@ import de.bixilon.minosoft.util.MMath.nanosToMillis import de.bixilon.minosoft.util.MMath.rotationFormatted import de.bixilon.minosoft.util.MMath.round import de.bixilon.minosoft.util.MMath.unitFormatted +import de.bixilon.minosoft.util.SystemInformation import java.util.* @@ -122,6 +123,44 @@ class HUDTextTranslator(private val hudRenderer: HUDRenderer) : Translator { insertRunnables[ResourceLocation("minosoft:difficulty")] = { connection, _, _ -> connection.world.difficulty?.name ?: "" } + + insertRunnables[ResourceLocation("minosoft:java_runtime_version")] = { _, _, _ -> + Runtime.version().toString() + } + insertRunnables[ResourceLocation("minosoft:system_bits")] = { _, _, _ -> + System.getProperty("sun.arch.data.model") + } + + insertRunnables[ResourceLocation("minosoft:used_memory_percent")] = { _, _, _ -> + (100 * (SystemInformation.RUNTIME.totalMemory() - SystemInformation.RUNTIME.freeMemory()) / SystemInformation.RUNTIME.maxMemory()).toString() + } + insertRunnables[ResourceLocation("minosoft:used_memory")] = { _, _, _ -> + (SystemInformation.RUNTIME.totalMemory() - SystemInformation.RUNTIME.freeMemory()).unitFormatted + } + insertRunnables[ResourceLocation("minosoft:max_memory")] = { _, _, _ -> + SystemInformation.MAX_MEMORY_TEXT + } + insertRunnables[ResourceLocation("minosoft:allocated_memory_percent")] = { _, _, _ -> + (100 * SystemInformation.RUNTIME.totalMemory() / SystemInformation.RUNTIME.maxMemory()).toString() + } + insertRunnables[ResourceLocation("minosoft:allocated_memory_formatted")] = { _, _, _ -> + SystemInformation.RUNTIME.totalMemory().unitFormatted + } + + insertRunnables[ResourceLocation("minosoft:system")] = { _, _, _ -> + SystemInformation.SYSTEM_MEMORY_TEXT + } + insertRunnables[ResourceLocation("minosoft:os")] = { _, _, _ -> + SystemInformation.OS_TEXT + } + insertRunnables[ResourceLocation("minosoft:cpu")] = { _, _, _ -> + SystemInformation.PROCESSOR_TEXT + } + insertRunnables[ResourceLocation("minosoft:screen_dimensions")] = { _, _, hudRenderer -> + hudRenderer.renderWindow.screenDimensions.toString() + } + + } const val ROUND_DIGITS = 2 diff --git a/src/main/java/de/bixilon/minosoft/util/MMath.kt b/src/main/java/de/bixilon/minosoft/util/MMath.kt index 926d6ea7f..aa596aa84 100644 --- a/src/main/java/de/bixilon/minosoft/util/MMath.kt +++ b/src/main/java/de/bixilon/minosoft/util/MMath.kt @@ -116,6 +116,8 @@ object MMath { val Int.unitFormatted get() = UnitFormatter.formatNumber(this) + val Long.unitFormatted get() = UnitFormatter.formatNumber(this) + val Float.rotationFormatted get() = "%.1f".format(this) val Double.rotationFormatted get() = "%.1f".format(this)