Chart "ago" label
This commit is contained in:
parent
184203ee20
commit
cea43a6ac6
@ -827,6 +827,8 @@ private fun androidFeatures(provider: MatteryLanguageProvider) {
|
||||
|
||||
private fun gui(provider: MatteryLanguageProvider) {
|
||||
with(provider.english) {
|
||||
gui("ago", "%s ago")
|
||||
|
||||
gui("part_of_multiblock", "Part of multiblock structure, useless on its own")
|
||||
gui("quicksearch", "Quick search...")
|
||||
|
||||
|
@ -832,6 +832,8 @@ private fun androidFeatures(provider: MatteryLanguageProvider) {
|
||||
|
||||
private fun gui(provider: MatteryLanguageProvider) {
|
||||
with(provider.russian) {
|
||||
gui("ago", "%s тому назад")
|
||||
|
||||
gui("part_of_multiblock", "Часть мультиблока, бесполезен сам по себе")
|
||||
gui("quicksearch", "Быстрый поиск...")
|
||||
|
||||
|
@ -30,7 +30,7 @@ private val LINE_TEXT_COLOR = RGBAColor(1f, 0f, 1f, 0.5f)
|
||||
data class ChartMouseLabels(
|
||||
val mouseX: Float,
|
||||
val mouseY: Float,
|
||||
val labels: (Int) -> Component,
|
||||
val labels: (Int) -> List<Component>,
|
||||
val font: Font,
|
||||
val color: RGBAColor = RGBAColor.WHITE,
|
||||
val pillarColor: RGBAColor = RGBAColor.WHITE,
|
||||
@ -154,13 +154,20 @@ fun renderChart(
|
||||
renderRect(pose, drawPointX - HIGHLIGHT_WIDTH / 2f, drawPointY - HIGHLIGHT_WIDTH / 2f, HIGHLIGHT_WIDTH, HIGHLIGHT_WIDTH, color = labels.color)
|
||||
|
||||
val label = labels.labels(drawLabel)
|
||||
val fWidth = labels.font.width(label).toFloat() + 2f
|
||||
val fHeight = labels.font.lineHeight.toFloat() + 2f
|
||||
|
||||
val anchorX = labels.mouseX // drawPointX
|
||||
val anchorY = labels.mouseY - fHeight / 2f - 2f
|
||||
if (label.isNotEmpty()) {
|
||||
val fWidth = label.maxOf { labels.font.width(it).toFloat() + 2f }
|
||||
val fHeight = labels.font.lineHeight.toFloat() * label.size + 2f
|
||||
|
||||
renderRect(pose, anchorX - fWidth / 2f, anchorY - fHeight / 2f, fWidth, fHeight, color = labels.textBackgroundColor)
|
||||
labels.font.draw(poseStack, label, anchorX, anchorY, gravity = RenderGravity.CENTER_CENTER, color = labels.textColor)
|
||||
val anchorX = labels.mouseX // drawPointX
|
||||
var anchorY = labels.mouseY - fHeight - 2f
|
||||
|
||||
renderRect(pose, anchorX - fWidth / 2f, anchorY - 2f, fWidth, fHeight + 4f, color = labels.textBackgroundColor)
|
||||
|
||||
label.forEach {
|
||||
labels.font.draw(poseStack, it, anchorX, anchorY, gravity = RenderGravity.TOP_CENTER, color = labels.textColor)
|
||||
anchorY += labels.font.lineHeight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ import ru.dbotthepony.mc.otm.client.render.renderChart
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.core.DecimalHistoryChart
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.core.util.formatTickDuration
|
||||
|
||||
open class DecimalHistoryChartPanel<out S : MatteryScreen<*>>(
|
||||
screen: S,
|
||||
@ -62,7 +64,13 @@ open class DecimalHistoryChartPanel<out S : MatteryScreen<*>>(
|
||||
labels = ChartMouseLabels(
|
||||
mouseX - absoluteX,
|
||||
mouseY - absoluteY,
|
||||
{ formatText(graph[it]) },
|
||||
{
|
||||
listOf(
|
||||
formatText(graph[it]),
|
||||
TextComponent(""),
|
||||
TranslatableComponent("otm.gui.ago", formatTickDuration(it * graph.resolution, true))
|
||||
)
|
||||
},
|
||||
font,
|
||||
),
|
||||
levelLabels = levelLabels
|
||||
|
Loading…
Reference in New Issue
Block a user