Fixed spellbook tabs appearing cut off on certain screen resolutions

This commit is contained in:
Sollace 2023-08-28 20:24:20 +01:00
parent d47433a463
commit b10a26e150
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 17 additions and 5 deletions

View file

@ -172,7 +172,17 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
context.drawTexture(TEXTURE, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256);
RenderSystem.setShaderColor(1, 1, 1, 1);
context.drawTexture(tab.icon().get(), isRight ? bounds.left + bounds.width - 16 - 10 : bounds.left + 10, bounds.top + (bounds.height - 16) / 2, 0, 0, 16, 16, 16, 16);
float widthScale = bounds.width / 35F;
int resolution = (int)(16 * widthScale);
int iconInset = (int)(Math.min(widthScale * 2, 1) * 10);
context.drawTexture(tab.icon().get(),
isRight ? bounds.left + bounds.width - resolution - iconInset : bounds.left + iconInset,
bounds.top + (bounds.height - resolution) / 2,
0, 0,
resolution, resolution,
resolution, resolution
);
});
MatrixStack matrices = context.getMatrices();

View file

@ -38,19 +38,21 @@ public class SpellbookTabBar {
int backgroundHeight = screen.getBackgroundHeight();
int backgroundWidth = screen.getBackgroundWidth();
int tabInset = 14;
int tabInset = 14 + Math.min((screen.width - backgroundWidth) / 2, 0);
int top = (screen.height - backgroundHeight) / 2 + 20;
int left = (screen.width - backgroundWidth) / 2;
int tabWidth = Math.min(35, left + 15);
int tabHeight = 23;
List<Chapter> leftTabs = chapters.getTabs(side)
.sorted(Comparator.comparing(Chapter::tabY))
.toList();
int tabWidth = 35;
int tabHeight = 23;
int totalTabs = leftTabs.size();
float squashFactor = Math.min(1, (float)(backgroundHeight - 40) / ((tabHeight + 8) * leftTabs.size()));