mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-21 20:33:10 +01:00
Fixed spellbook pages being cut off
This commit is contained in:
parent
0e7ec6af72
commit
db73dc7781
4 changed files with 24 additions and 13 deletions
|
@ -10,7 +10,6 @@ import com.minelittlepony.common.client.gui.IViewRoot;
|
|||
import com.minelittlepony.common.client.gui.dimension.Bounds;
|
||||
import com.minelittlepony.common.client.gui.element.Button;
|
||||
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
|
||||
import com.minelittlepony.unicopia.Debug;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||
|
@ -147,10 +146,6 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
|
|||
|
||||
context.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight, 512, 256);
|
||||
|
||||
if (Debug.SPELLBOOK_CHAPTERS) {
|
||||
clearAndInit();
|
||||
}
|
||||
|
||||
tabs.getAllTabs().forEach(tab -> {
|
||||
Bounds bounds = tab.bounds();
|
||||
boolean hover = bounds.contains(mouseX, mouseY);
|
||||
|
|
|
@ -144,7 +144,6 @@ public class DynamicContent implements Content {
|
|||
}
|
||||
|
||||
public void drawHeader(DrawContext context, int mouseX, int mouseY) {
|
||||
|
||||
if (elements.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Optional;
|
|||
import com.minelittlepony.common.client.gui.IViewRoot;
|
||||
import com.minelittlepony.common.client.gui.ScrollContainer;
|
||||
import com.minelittlepony.common.client.gui.dimension.Bounds;
|
||||
import com.minelittlepony.common.client.gui.dimension.Padding;
|
||||
import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookScreen;
|
||||
import com.minelittlepony.unicopia.client.gui.spellbook.element.DynamicContent.Page;
|
||||
|
||||
|
@ -26,7 +27,7 @@ class Panel extends ScrollContainer {
|
|||
|
||||
int width = screen.getBackgroundWidth() / 2;
|
||||
margin.top = screen.getY() + 35;
|
||||
margin.bottom = screen.height - screen.getBackgroundHeight() - screen.getY() + 40;
|
||||
margin.bottom = screen.height - screen.getBackgroundHeight() - screen.getY() + 20;
|
||||
margin.left = screen.getX() + 30;
|
||||
|
||||
if (pageIndex % 2 == 1) {
|
||||
|
@ -42,6 +43,15 @@ class Panel extends ScrollContainer {
|
|||
|
||||
@Override
|
||||
protected void renderContents(DrawContext context, int mouseX, int mouseY, float partialTicks) {
|
||||
var scissorBounds = getBounds();
|
||||
|
||||
context.disableScissor();
|
||||
context.enableScissor(
|
||||
scissorBounds.left,
|
||||
scissorBounds.top,
|
||||
scissorBounds.right(),
|
||||
scissorBounds.bottom()
|
||||
);
|
||||
page.ifPresent(p -> {
|
||||
int oldHeight = p.getBounds().height;
|
||||
p.draw(context, mouseX, mouseY, this);
|
||||
|
@ -55,15 +65,22 @@ class Panel extends ScrollContainer {
|
|||
@Override
|
||||
public Bounds getContentBounds() {
|
||||
return page == null ? Bounds.empty() : page.map(page -> {
|
||||
return new Bounds(0, 0, 1, page.getBounds().height);
|
||||
}).orElse(Bounds.empty());
|
||||
return page.getBounds();
|
||||
}).orElse(Bounds.empty()).offset(new Padding(
|
||||
getBounds().top + getScrollY(),
|
||||
getBounds().left + getScrollX(), 0, 0)
|
||||
).offset(getContentPadding());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(DrawContext context, int mouseX, int mouseY, float partialTicks) { }
|
||||
protected void drawBackground(DrawContext context, int mouseX, int mouseY, float partialTicks) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawDecorations(DrawContext context, int mouseX, int mouseY, float partialTicks) { }
|
||||
protected void drawDecorations(DrawContext context, int mouseX, int mouseY, float partialTicks) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawOverlays(DrawContext context, int mouseX, int mouseY, float partialTicks) {
|
||||
|
|
|
@ -28,8 +28,8 @@ public record Structure(Bounds bounds, Schematic schematic) implements PageEleme
|
|||
|
||||
matrices.push();
|
||||
if (container != null) {
|
||||
matrices.translate(container.getBounds().width / 2, container.getBounds().height / 2, 100);
|
||||
float minDimensions = Math.min(container.getBounds().width, container.getBounds().height) - 30;
|
||||
matrices.translate(container.getBounds().width / 2, container.getBounds().height / 2 - 20, 100);
|
||||
float minDimensions = Math.min(container.getBounds().width * 0.7F, container.getBounds().height) - 30;
|
||||
int minSize = (Math.max(schematic.dx(), Math.max(schematic.dy(), schematic.dz())) + 1) * 16;
|
||||
float scale = minDimensions / minSize;
|
||||
matrices.scale(scale, scale, 1);
|
||||
|
|
Loading…
Reference in a new issue