mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
hud: show system information
This commit is contained in:
parent
aed1ed0ff5
commit
995e923f6c
@ -132,8 +132,8 @@ class HUDTextElement : HUDElement {
|
||||
|
||||
private fun adjustPositionsForLineBreaks(newLinePositions: MutableList<Int>) {
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user