From fbb0c5c47033f71b43d48e141e6dbfdddc87abc6 Mon Sep 17 00:00:00 2001 From: btwonion Date: Thu, 15 Feb 2024 17:59:26 +0100 Subject: [PATCH] center table components --- .../tabhud/widget/component/TableComponent.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/TableComponent.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/TableComponent.java index dbc0bf552e..2d813b5679 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/TableComponent.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/TableComponent.java @@ -25,11 +25,7 @@ public void addToCell(int x, int y, Component c) { // pad extra to add a vertical line later this.cellW = Math.max(this.cellW, c.width + PAD_S + PAD_L); - - // assume all rows are equally high so overwriting doesn't matter - // if this wasn't the case, drawing would need more math - // not doing any of that if it's not needed - this.cellH = c.height + PAD_S; + this.cellH = Math.max(c.height + PAD_S, cellH); this.width = this.cellW * this.cols; this.height = (this.cellH * this.rows) - PAD_S / 2; @@ -40,8 +36,9 @@ public void addToCell(int x, int y, Component c) { public void render(DrawContext context, int xpos, int ypos) { for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { - if (comps[x][y] != null) { - comps[x][y].render(context, xpos + (x * cellW), ypos + y * cellH); + Component comp = comps[x][y]; + if (comp != null) { + comp.render(context, xpos + (x * cellW), ypos + y * cellH + (cellH / 2 - comp.height / 2)); } } // add a line before the col if we're not drawing the first one