diff options
author | Anton <79146501+btwonion@users.noreply.github.com> | 2024-02-15 21:15:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-15 15:15:00 -0500 |
commit | 177656cbbb6dc0f25125371e6f600e053d8ca1bc (patch) | |
tree | 13b910f006a7e53207d27828f1794a8046afc4cd /src | |
parent | af424284c4d43447c9cdd9c94e6cffa3b7e88290 (diff) | |
download | Skyblocker-177656cbbb6dc0f25125371e6f600e053d8ca1bc.tar.gz Skyblocker-177656cbbb6dc0f25125371e6f600e053d8ca1bc.tar.bz2 Skyblocker-177656cbbb6dc0f25125371e6f600e053d8ca1bc.zip |
center table components (#543)
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/TableComponent.java | 11 |
1 files 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 dbc0bf55..2d813b56 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 class TableComponent extends Component { // 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 class TableComponent extends Component { 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 |