From 4bbcbc8ea64c4efcb2cf4b4e3d6d7a78f6f3a062 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Oct 2024 11:15:29 +0700 Subject: [PATCH] Less confusing time frames for charts --- .../client/screen/panels/DecimalHistoryChartPanel.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DecimalHistoryChartPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DecimalHistoryChartPanel.kt index 4bc772cde..313eacffa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DecimalHistoryChartPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DecimalHistoryChartPanel.kt @@ -73,7 +73,15 @@ open class DecimalHistoryChartPanel>( } result.add(TextComponent("")) - result.add(TranslatableComponent("otm.gui.ago", formatTickDuration(it * chart.resolution, true))) + + if (chart.resolution <= 20) { + result.add(TranslatableComponent("otm.gui.ago", formatTickDuration(it * chart.resolution, false))) + } else { + val useLongFormat = chart.resolution * chart.width / 20 > 99 * 60 + result.add(TranslatableComponent("otm.gui.ago", formatTickDuration(it * chart.resolution, useLongFormat) + "-" + formatTickDuration((it + 1) * chart.resolution, useLongFormat))) + result.add(TextComponent("(${formatTickDuration(chart.resolution, useLongFormat)})")) + } + result }, font,