diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-06-26 04:09:06 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-06-28 03:21:12 +0800 |
| commit | 091c92b90421c13bcde0f80909170fde0e317d39 (patch) | |
| tree | 22116d5c5fa733dbd0c2a2c03e5f2559dc8e5d3a /default-plugin/src/main/java/me/shedaniel/rei/plugin | |
| parent | ae947d3c2f9935ad4f5d1de0d06d19609940818d (diff) | |
| download | RoughlyEnoughItems-091c92b90421c13bcde0f80909170fde0e317d39.tar.gz RoughlyEnoughItems-091c92b90421c13bcde0f80909170fde0e317d39.tar.bz2 RoughlyEnoughItems-091c92b90421c13bcde0f80909170fde0e317d39.zip | |
Adapt scissors to transform
Diffstat (limited to 'default-plugin/src/main/java/me/shedaniel/rei/plugin')
4 files changed, 42 insertions, 47 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java index 50adee384..615269b80 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java @@ -36,6 +36,7 @@ import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.gui.AbstractRenderer; import me.shedaniel.rei.api.client.gui.DisplayRenderer; import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.CloseableScissors; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.gui.widgets.Widgets; @@ -192,18 +193,18 @@ public class DefaultInformationCategory implements DisplayCategory<DefaultInform public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { scrolling.updatePosition(delta); Rectangle innerBounds = scrolling.getScissorBounds(); - ScissorsHandler.INSTANCE.scissor(innerBounds); - int currentY = -scrolling.scrollAmountInt() + innerBounds.y; - for (FormattedCharSequence text : texts) { - if (text != null && currentY + font.lineHeight >= innerBounds.y && currentY <= innerBounds.getMaxY()) { - font.draw(matrices, text, innerBounds.x + 2, currentY + 2, REIRuntime.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : 0xFF090909); + try (CloseableScissors scissors = scissor(matrices, innerBounds)) { + int currentY = -scrolling.scrollAmountInt() + innerBounds.y; + for (FormattedCharSequence text : texts) { + if (text != null && currentY + font.lineHeight >= innerBounds.y && currentY <= innerBounds.getMaxY()) { + font.draw(matrices, text, innerBounds.x + 2, currentY + 2, REIRuntime.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : 0xFF090909); + } + currentY += text == null ? 4 : font.lineHeight; } - currentY += text == null ? 4 : font.lineHeight; } - ScissorsHandler.INSTANCE.removeLastScissor(); - ScissorsHandler.INSTANCE.scissor(scrolling.getBounds()); - scrolling.renderScrollBar(0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); - ScissorsHandler.INSTANCE.removeLastScissor(); + try (CloseableScissors scissors = scissor(matrices, scrolling.getBounds())) { + scrolling.renderScrollBar(0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); + } } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java index 049756b68..9ea7bc9aa 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java @@ -33,10 +33,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.gui.DisplayRenderer; import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.client.gui.widgets.Slot; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.gui.widgets.*; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.util.CollectionUtils; @@ -157,21 +154,21 @@ public class DefaultBeaconBaseCategory implements DisplayCategory<DefaultBeaconB public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { scrolling.updatePosition(delta); Rectangle innerBounds = scrolling.getScissorBounds(); - ScissorsHandler.INSTANCE.scissor(innerBounds); - for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) { - for (int x = 0; x < 8; x++) { - int index = y * 8 + x; - if (widgets.size() <= index) - break; - Slot widget = widgets.get(index); - widget.getBounds().setLocation(bounds.x + 1 + x * 18, bounds.y + 1 + y * 18 - scrolling.scrollAmountInt()); - widget.render(matrices, mouseX, mouseY, delta); + try (CloseableScissors scissors = scissor(matrices, innerBounds)) { + for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) { + for (int x = 0; x < 8; x++) { + int index = y * 8 + x; + if (widgets.size() <= index) + break; + Slot widget = widgets.get(index); + widget.getBounds().setLocation(bounds.x + 1 + x * 18, bounds.y + 1 + y * 18 - scrolling.scrollAmountInt()); + widget.render(matrices, mouseX, mouseY, delta); + } } } - ScissorsHandler.INSTANCE.removeLastScissor(); - ScissorsHandler.INSTANCE.scissor(scrolling.getBounds()); - scrolling.renderScrollBar(0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); - ScissorsHandler.INSTANCE.removeLastScissor(); + try (CloseableScissors scissors = scissor(matrices, scrolling.getBounds())) { + scrolling.renderScrollBar(0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); + } } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java index 853df98b5..478408619 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java @@ -33,10 +33,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.gui.DisplayRenderer; import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.client.gui.widgets.Slot; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.gui.widgets.*; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.util.CollectionUtils; @@ -157,21 +154,21 @@ public class DefaultBeaconPaymentCategory implements DisplayCategory<DefaultBeac public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { scrolling.updatePosition(delta); Rectangle innerBounds = scrolling.getScissorBounds(); - ScissorsHandler.INSTANCE.scissor(innerBounds); - for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) { - for (int x = 0; x < 8; x++) { - int index = y * 8 + x; - if (widgets.size() <= index) - break; - Slot widget = widgets.get(index); - widget.getBounds().setLocation(bounds.x + 1 + x * 18, bounds.y + 1 + y * 18 - scrolling.scrollAmountInt()); - widget.render(matrices, mouseX, mouseY, delta); + try (CloseableScissors scissors = scissor(matrices, innerBounds)) { + for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) { + for (int x = 0; x < 8; x++) { + int index = y * 8 + x; + if (widgets.size() <= index) + break; + Slot widget = widgets.get(index); + widget.getBounds().setLocation(bounds.x + 1 + x * 18, bounds.y + 1 + y * 18 - scrolling.scrollAmountInt()); + widget.render(matrices, mouseX, mouseY, delta); + } } } - ScissorsHandler.INSTANCE.removeLastScissor(); - ScissorsHandler.INSTANCE.scissor(scrolling.getBounds()); - scrolling.renderScrollBar(0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); - ScissorsHandler.INSTANCE.removeLastScissor(); + try (CloseableScissors scissors = scissor(matrices, scrolling.getBounds())) { + scrolling.renderScrollBar(0xff000000, 1, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); + } } @Override diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java index c79cc9eb3..07d5fe985 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java @@ -86,9 +86,9 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?, new GuiComponent() { { fillGradient(matrices, 0, 0, 1000, 1000, 0xff3489eb, 0xffc41868); - for (int x = 0; x < 20; x++) { - for (int y = 0; y < 20; y++) { - Widgets.createSlot(new Point(500 - 9 * 20 + x * 18, 500 - 9 * 20 + y * 18)) + for (int x = 0; x < 10; x++) { + for (int y = 0; y < 10; y++) { + Widgets.createSlot(new Point(500 - 9 * 10 + x * 18, 500 - 9 * 10 + y * 18)) .entry(EntryStacks.of(Registry.ITEM.byId(x + y * 10 + 1))) .disableBackground() .render(matrices, mouseX, mouseY, delta); |
