0.5.1: fix UI widget coords — relative not absolute
Build / build (push) Has been cancelled

FTB Library's Widget.setPos(x, y) takes coords RELATIVE to the parent
panel. My code passed (getX() + offset, getY() + offset), so widgets
ended up at panel-pos * 2 + offset, far off-screen to the bottom-right.

Fix: drop getX()/getY() everywhere in alignWidgets. Refresh button,
close button, header bar, sub-panels — all relative now. Plus
BaseBnsScreen.contentTop()/contentBottom() are now plain offsets
(20 and getHeight() - 24) instead of getY()-prefixed.

Visual bug surfaced with user screenshot of HubScreen showing all
buttons stacked on the right edge of the screen with empty dark panel
on the left.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-06-08 14:42:52 +00:00
parent 0b90e94079
commit 1630a8370f
8 changed files with 30 additions and 28 deletions
+1 -1
View File
@@ -19,5 +19,5 @@ loader_version_range=[1,)
mod_id=bnstoolkit
mod_name=Brass and Sigil Toolkit
mod_license=All Rights Reserved
mod_version=0.5.0
mod_version=0.5.1
mod_group_id=uk.sijbers.bnstoolkit
@@ -45,13 +45,18 @@ public abstract class BaseBnsScreen extends BaseScreen {
theme.drawString(graphics, screenTitle, x + 8, y + 6, Color4I.WHITE, Theme.SHADOW);
}
/** Top y of the content area (below title bar). */
/**
* Top y of the content area (below title bar), relative to the panel's
* top-left. FTB Library's Panel/Widget setPos uses parent-relative
* coordinates, so all alignWidgets impls reference these as plain offsets
* (not getY() + offset).
*/
protected int contentTop() {
return getY() + 20;
return 20;
}
/** Bottom y of the content area (above action row). */
/** Bottom y of the content area (above action row), relative to the panel. */
protected int contentBottom() {
return getY() + getHeight() - 24;
return getHeight() - 24;
}
}
@@ -44,13 +44,13 @@ public final class BountyBoardScreen extends BaseBnsScreen {
@Override
public void alignWidgets() {
getWidgets().get(0).setPos(getX() + 8, contentTop());
getWidgets().get(0).setPos(8, contentTop());
getWidgets().get(0).setSize(170, getHeight() - 30);
getWidgets().get(1).setPos(getX() + 186, contentTop());
getWidgets().get(1).setPos(186, contentTop());
getWidgets().get(1).setSize(getWidth() - 194, getHeight() - 30);
Widget rf = getWidgets().get(2);
rf.setSize(60, 16);
rf.setPos(getX() + getWidth() - 68, getY() + getHeight() - 22);
rf.setPos(getWidth() - 68, getHeight() - 22);
}
private static final class BountyList extends Panel {
@@ -45,12 +45,12 @@ public final class HubScreen extends BaseBnsScreen {
@Override
public void alignWidgets() {
// Header across the top
// All coordinates here are RELATIVE to the panel's top-left — FTB
// Library's renderer adds the panel's own (getX(), getY()) for us.
Widget header = getWidgets().get(0);
header.setPos(getX() + 8, contentTop());
header.setPos(8, contentTop());
header.setSize(getWidth() - 16, 20);
// 5 routing buttons stacked vertically in two columns
int cols = 2;
int btnW = (getWidth() - 24) / cols;
int btnH = 22;
@@ -61,13 +61,12 @@ public final class HubScreen extends BaseBnsScreen {
int col = i % cols;
Widget w = getWidgets().get(1 + i);
w.setSize(btnW, btnH);
w.setPos(getX() + 8 + col * (btnW + gap), top + row * (btnH + gap));
w.setPos(8 + col * (btnW + gap), top + row * (btnH + gap));
}
// Close button bottom-right
Widget close = getWidgets().get(6);
close.setSize(64, 16);
close.setPos(getX() + getWidth() - 72, getY() + getHeight() - 22);
close.setPos(getWidth() - 72, getHeight() - 22);
}
private SimpleTextButton makeButton(String label, Icon icon, String snapshot,
@@ -43,13 +43,13 @@ public final class PlotPurchaseScreen extends BaseBnsScreen {
@Override
public void alignWidgets() {
getWidgets().get(0).setPos(getX() + 8, contentTop());
getWidgets().get(0).setPos(8, contentTop());
getWidgets().get(0).setSize(170, getHeight() - 30);
getWidgets().get(1).setPos(getX() + 186, contentTop());
getWidgets().get(1).setPos(186, contentTop());
getWidgets().get(1).setSize(getWidth() - 194, getHeight() - 30);
Widget rf = getWidgets().get(2);
rf.setSize(60, 16);
rf.setPos(getX() + getWidth() - 68, getY() + getHeight() - 22);
rf.setPos(getWidth() - 68, getHeight() - 22);
}
private static final class PlotList extends Panel {
@@ -39,11 +39,11 @@ public final class QuestLogScreen extends BaseBnsScreen {
@Override
public void alignWidgets() {
getWidgets().get(0).setPos(getX() + 8, contentTop());
getWidgets().get(0).setPos(8, contentTop());
getWidgets().get(0).setSize(getWidth() - 16, getHeight() - 30);
Widget rf = getWidgets().get(1);
rf.setSize(60, 16);
rf.setPos(getX() + getWidth() - 68, getY() + getHeight() - 22);
rf.setPos(getWidth() - 68, getHeight() - 22);
}
private static final class SummaryPanel extends Panel {
@@ -53,13 +53,13 @@ public final class ShopBrowserScreen extends BaseBnsScreen {
@Override
public void alignWidgets() {
getWidgets().get(0).setPos(getX() + 8, contentTop());
getWidgets().get(0).setPos(8, contentTop());
getWidgets().get(0).setSize(170, getHeight() - 30);
getWidgets().get(1).setPos(getX() + 186, contentTop());
getWidgets().get(1).setPos(186, contentTop());
getWidgets().get(1).setSize(getWidth() - 194, getHeight() - 30);
Widget rf = getWidgets().get(2);
rf.setSize(60, 16);
rf.setPos(getX() + getWidth() - 68, getY() + getHeight() - 22);
rf.setPos(getWidth() - 68, getHeight() - 22);
}
// ─── Item grid ───────────────────────────────────────────────────
@@ -47,16 +47,14 @@ public final class TierUpgradeScreen extends BaseBnsScreen {
@Override
public void alignWidgets() {
// ladder panel
getWidgets().get(0).setPos(getX() + 8, contentTop());
// FTB Library setPos uses parent-relative coords.
getWidgets().get(0).setPos(8, contentTop());
getWidgets().get(0).setSize(180, getHeight() - 28);
// detail panel
getWidgets().get(1).setPos(getX() + 196, contentTop());
getWidgets().get(1).setPos(196, contentTop());
getWidgets().get(1).setSize(getWidth() - 204, getHeight() - 50);
// refresh button bottom-right
Widget rf = getWidgets().get(2);
rf.setSize(60, 16);
rf.setPos(getX() + getWidth() - 68, getY() + getHeight() - 22);
rf.setPos(getWidth() - 68, getHeight() - 22);
}
// ─── Sub-panels ──────────────────────────────────────────────────