diff --git a/.editorconfig b/.editorconfig index 363785069..6ddef3d3c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,6 +16,7 @@ indent_size = 2 [*.java] indent_style = tab +ij_continuation_indent_size = 8 ij_java_class_count_to_use_import_on_demand = 99 ij_java_names_count_to_use_import_on_demand = 99 -ij_java_imports_layout = $*,|,java.**,|,javax.**,|,org.**,|,com.**,|,* \ No newline at end of file +ij_java_imports_layout = $*,|,java.**,|,javax.**,|,org.**,|,com.**,|,* diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java index fdcf71eff..98086a786 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java @@ -27,14 +27,14 @@ public abstract class ConfigScreen extends AbstractSimiScreen { /* * * zelo's list for configUI - * TODO * - * replace java's awt color with something mutable + * reduce number of packets sent to the server when saving a bunch of values + * maybe replace java's awt color with something mutable + * find out why framebuffer blending is incorrect * * FIXME * * tooltips are hidden underneath the scrollbar, if the bar is near the middle - * framebuffer blending is incorrect -> wait for jozu's changes to merge * * */ @@ -60,7 +60,6 @@ public abstract class ConfigScreen extends AbstractSimiScreen { @Override protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - //RenderSystem.disableDepthTest(); if (this.client != null && this.client.world != null) { fill(ms, 0, 0, this.width, this.height, 0xb0_282c34); } else { @@ -84,16 +83,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - int x = (int) (width * 0.5f); - int y = (int) (height * 0.5f); - //this.drawHorizontalLine(ms, x-25, x+25, y, 0xff_807060); - //this.drawVerticalLine(ms, x, y-25, y+25, 0xff_90a0b0); - - //this.testStencil.render(ms); - - //UIRenderHelper.streak(ms, 0, mouseX, mouseY, 16, 50, 0xaa_1e1e1e); - } + protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {} @Override public boolean mouseScrolled(double mouseX, double mouseY, double delta) { @@ -113,7 +103,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { ms.push(); ms.translate(-100, 100, -100); - ms.scale(200, 200, .1f); + ms.scale(200, 200, 1); GuiGameElement.of(cogwheelState) .rotateBlock(22.5, cogSpin.getValue(partialTicks), 22.5) .render(ms); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java index 71b6680ff..a0d23b7a1 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java @@ -40,9 +40,6 @@ public class ConfigScreenList extends ExtendedList { @Override public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - //render tmp background - //fill(ms, left, top, left + width, top + height, 0x10_000000); - UIRenderHelper.angledGradient(ms, 90, left + width / 2, top, width, 5, 0x60_000000, 0x0); UIRenderHelper.angledGradient(ms, -90, left + width / 2, bottom, width, 5, 0x60_000000, 0x0); UIRenderHelper.angledGradient(ms, 0, left, top + height / 2, height, 5, 0x60_000000, 0x0); @@ -78,7 +75,6 @@ public class ConfigScreenList extends ExtendedList { } public void tick() { - //children().forEach(Entry::tick); for(int i = 0; i < getItemCount(); ++i) { int top = this.getRowTop(i); int bot = top + itemHeight; diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java index 7bd018c84..e27502281 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java @@ -148,7 +148,7 @@ public class SubMenuConfigScreen extends ConfigScreen { new ConfirmationScreen() .at(x, y) - .withText(ITextProperties.plain("You are about to change " + changes.size() + " values. Are you sure?")) + .withText(ITextProperties.plain("You are about to change " + changes.size() + " value" + (changes.size() != 1 ? "s" : "") + ". Are you sure?")) .withAction(success -> { if (success) saveChanges(); @@ -167,7 +167,7 @@ public class SubMenuConfigScreen extends ConfigScreen { new ConfirmationScreen() .at(x, y) - .withText(ITextProperties.plain("You are about to discard " + changes.size() + " unsaved changes. Are you sure?")) + .withText(ITextProperties.plain("You are about to discard " + changes.size() + " unsaved change" + (changes.size() != 1 ? "s" : "") + ". Are you sure?")) .withAction(success -> { if (success) clearChanges(); @@ -307,7 +307,7 @@ public class SubMenuConfigScreen extends ConfigScreen { if (!changes.isEmpty() && parent instanceof BaseConfigScreen) { new ConfirmationScreen() .centered() - .addText(ITextProperties.plain("You still have " + changes.size() + " unsaved changes for this config.")) + .addText(ITextProperties.plain("You still have " + changes.size() + " unsaved change" + (changes.size() != 1 ? "s" : "") + " for this config.")) .addText(ITextProperties.plain("Leaving this screen will discard them without saving. Are you sure?")) .withAction(success -> { if (!success) @@ -331,7 +331,7 @@ public class SubMenuConfigScreen extends ConfigScreen { new ConfirmationScreen() .centered() - .addText(ITextProperties.plain("You still have " + changes.size() + " unsaved changes for this config.")) + .addText(ITextProperties.plain("You still have " + changes.size() + " unsaved change" + (changes.size() != 1 ? "s" : "") + " for this config.")) .addText(ITextProperties.plain("Leaving this screen will discard them without saving. Are you sure?")) .withAction(success -> { if (!success) diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java index 071fa001f..8cab0fe64 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java @@ -18,18 +18,10 @@ public class BooleanEntry extends ValueEntry { public BooleanEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); -// enabled = new TextStencilElement(Minecraft.getInstance().fontRenderer, "Enabled") -// .centered(true, true) -// .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height/2, height, width, 0xff_88f788, 0xff_20cc20)); -// -// disabled = new TextStencilElement(Minecraft.getInstance().fontRenderer, "Disabled") -// .centered(true, true) -// .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height/2, height, width, 0xff_f78888, 0xff_cc2020)); - enabled = AllIcons.I_CONFIRM.asStencil() .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, height, width, Theme.p(Theme.Key.BUTTON_SUCCESS))) .at(10, 0); - + disabled = AllIcons.I_DISABLE.asStencil() .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, height, width, Theme.p(Theme.Key.BUTTON_FAIL))) .at(10, 0); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java index 7e44eb10f..08d7e8288 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java @@ -78,7 +78,7 @@ public class EnumEntry extends ValueEntry> { cycleLeft.y = y + 10; cycleLeft.render(ms, mouseX, mouseY, partialTicks); - valueText.at(cycleLeft.x + cycleWidth - 8, y + 10, 200) + valueText.at(cycleLeft.x + cycleWidth - 8, y + 11, 200) .withBounds(width - getLabelWidth(width) - 2 * cycleWidth - resetWidth - 4, 16) .render(ms); diff --git a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java index 9d62f4785..e7b5b48cf 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java @@ -169,25 +169,21 @@ public class ConfirmationScreen extends AbstractSimiScreen { protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { UIRenderHelper.framebuffer.framebufferClear(Minecraft.IS_RUNNING_ON_MAC); - //UIRenderHelper.prepFramebufferSize(); ms.push(); - //ms.translate(0, 0, -50); - //ms.scale(1, 1, 0.01f); - //todo wait for jozu's framebuffer capabilities on the other branch and use them here UIRenderHelper.framebuffer.bindFramebuffer(true); source.render(ms, mouseX, mouseY, 10); UIRenderHelper.framebuffer.unbindFramebuffer(); Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); ms.pop(); + //fixme replace with glVersioned-backend calls once they are merged from jozu's branch GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, UIRenderHelper.framebuffer.framebufferObject); GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject); GL30.glBlitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL30.GL_LINEAR); mainBuffer.bindFramebuffer(true); this.fillGradient(ms, 0, 0, this.width, this.height, 0x70101010, 0x80101010); - //RenderSystem.enableAlphaTest(); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java index 2521be7c5..d7a3f5b5d 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java @@ -64,7 +64,6 @@ public class GuiGameElement { } public static abstract class GuiRenderBuilder extends RenderElement { - //double xBeforeScale, yBeforeScale, zBeforeScale = 0; double xLocal, yLocal, zLocal; double xRot, yRot, zRot; double scale = 1; @@ -78,19 +77,6 @@ public class GuiGameElement { return this; } - /*public GuiRenderBuilder at(double x, double y) { - this.xBeforeScale = x; - this.yBeforeScale = y; - return this; - } - - public GuiRenderBuilder at(double x, double y, double z) { - this.xBeforeScale = x; - this.yBeforeScale = y; - this.zBeforeScale = z; - return this; - }*/ - public GuiRenderBuilder rotate(double xRot, double yRot, double zRot) { this.xRot = xRot; this.yRot = yRot; @@ -272,23 +258,10 @@ public class GuiGameElement { @Override public void render(MatrixStack matrixStack) { prepareMatrix(matrixStack); -// matrixStack.translate(0, 80, 0); transformMatrix(matrixStack); renderItemIntoGUI(matrixStack, stack); cleanUpMatrix(matrixStack); } - /* - * public void render() { - * prepare(); - * transform(); - * RenderSystem.scaled(1, -1, 1); - * RenderSystem.translated(0, 0, -75); - * Minecraft.getInstance() - * .getItemRenderer() - * .renderItemIntoGUI(stack, 0, 0); - * cleanUp(); - * } - */ public static void renderItemIntoGUI(MatrixStack matrixStack, ItemStack stack) { ItemRenderer renderer = Minecraft.getInstance() diff --git a/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java b/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java index f2d5ff943..c5d87543c 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java @@ -56,7 +56,6 @@ public class TextStencilElement extends DelegatedStencilElement { y = height / 2f - font.FONT_HEIGHT / 2f; font.draw(ms, component, x, y, 0xff_000000); - //font.draw(ms, component, 0, 0, 0xff_000000); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java index 6930d6c87..ac4760516 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java @@ -33,25 +33,17 @@ public class UIRenderHelper { public static void init() { RenderSystem.recordRenderCall(() -> { MainWindow mainWindow = Minecraft.getInstance() - .getWindow(); + .getWindow(); framebuffer = new Framebuffer(mainWindow.getFramebufferWidth(), mainWindow.getFramebufferHeight(), true, - Minecraft.IS_RUNNING_ON_MAC); + Minecraft.IS_RUNNING_ON_MAC); framebuffer.setFramebufferColor(0, 0, 0, 0); framebuffer.enableStencil(); -// framebuffer.deleteFramebuffer(); }); } - /*public static void prepFramebufferSize() { - MainWindow window = Minecraft.getInstance().getWindow(); - if (framebuffer.framebufferWidth != window.getFramebufferWidth() || framebuffer.framebufferHeight != window.getFramebufferHeight()) { - framebuffer.func_216491_a(window.getFramebufferWidth(), window.getFramebufferHeight(), Minecraft.IS_RUNNING_ON_MAC); - } - }*/ - public static void drawFramebuffer(float alpha) { MainWindow window = Minecraft.getInstance() - .getWindow(); + .getWindow(); float vx = (float) window.getScaledWidth(); float vy = (float) window.getScaledHeight(); @@ -67,22 +59,10 @@ public class UIRenderHelper { BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEXTURE); - bufferbuilder.vertex(0, vy, 0) - .color(1, 1, 1, alpha) - .texture(0, 0) - .endVertex(); - bufferbuilder.vertex(vx, vy, 0) - .color(1, 1, 1, alpha) - .texture(tx, 0) - .endVertex(); - bufferbuilder.vertex(vx, 0, 0) - .color(1, 1, 1, alpha) - .texture(tx, ty) - .endVertex(); - bufferbuilder.vertex(0, 0, 0) - .color(1, 1, 1, alpha) - .texture(0, ty) - .endVertex(); + bufferbuilder.vertex(0, vy, 0).color(1, 1, 1, alpha).texture(0, 0).endVertex(); + bufferbuilder.vertex(vx, vy, 0).color(1, 1, 1, alpha).texture(tx, 0).endVertex(); + bufferbuilder.vertex(vx, 0, 0).color(1, 1, 1, alpha).texture(tx, ty).endVertex(); + bufferbuilder.vertex(0, 0, 0).color(1, 1, 1, alpha).texture(0, ty).endVertex(); tessellator.draw(); framebuffer.unbindFramebufferTexture(); @@ -118,7 +98,7 @@ public class UIRenderHelper { double split1 = .5; double split2 = .75; Matrix4f model = ms.peek() - .getModel(); + .getModel(); GuiUtils.drawGradientRect(model, 0, -width, 0, width, (int) (split1 * height), c1, c2); GuiUtils.drawGradientRect(model, 0, -width, (int) (split1 * height), width, (int) (split2 * height), c2, c3); GuiUtils.drawGradientRect(model, 0, -width, (int) (split2 * height), width, height, c3, c4); @@ -130,26 +110,28 @@ public class UIRenderHelper { public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int breadth, int length, Couple c) { angledGradient(ms, angle, x, y, 0, breadth, length, c); } + /** * @see #angledGradient(MatrixStack, float, int, int, int, int, int, int, int) */ public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int z, int breadth, int length, Couple c) { angledGradient(ms, angle, x, y, z, breadth, length, c.getFirst().getRGB(), c.getSecond().getRGB()); } + /** * @see #angledGradient(MatrixStack, float, int, int, int, int, int, int, int) */ public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int breadth, int length, int color1, int color2) { angledGradient(ms, angle, x, y, 0, breadth, length, color1, color2); } + /** * x and y specify the middle point of the starting edge * - * @param angle the angle of the gradient in degrees; 0° means from left to right - * @param color1 the color at the starting edge - * @param color2 the color at the ending edge + * @param angle the angle of the gradient in degrees; 0° means from left to right + * @param color1 the color at the starting edge + * @param color2 the color at the ending edge * @param breadth the total width of the gradient - * */ public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int z, int breadth, int length, int color1, int color2) { ms.push(); @@ -178,13 +160,13 @@ public class UIRenderHelper { private static void breadcrumbArrow(MatrixStack ms, int width, int height, int indent, int c1, int c2) { /* - * 0,0 x1,y1 ********************* x4,y4 ***** x7,y7 - * **** **** - * **** **** - * x0,y0 x2,y2 x5,y5 - * **** **** - * **** **** - * x3,y3 ********************* x6,y6 ***** x8,y8 + * 0,0 x1,y1 ********************* x4,y4 ***** x7,y7 + * **** **** + * **** **** + * x0,y0 x2,y2 x5,y5 + * **** **** + * **** **** + * x3,y3 ********************* x6,y6 ***** x8,y8 * */ @@ -214,69 +196,32 @@ public class UIRenderHelper { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); - Matrix4f model = ms.peek() - .getModel(); + Matrix4f model = ms.peek().getModel(); bufferbuilder.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); - bufferbuilder.vertex(model, x0, y0, 0) - .color(fc1 >> 16 & 0xFF, fc1 >> 8 & 0xFF, fc1 & 0xFF, fc1 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x1, y1, 0) - .color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x2, y2, 0) - .color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF) - .endVertex(); + bufferbuilder.vertex(model, x0, y0, 0).color(fc1 >> 16 & 0xFF, fc1 >> 8 & 0xFF, fc1 & 0xFF, fc1 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x1, y1, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x2, y2, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex(); - bufferbuilder.vertex(model, x0, y0, 0) - .color(fc1 >> 16 & 0xFF, fc1 >> 8 & 0xFF, fc1 & 0xFF, fc1 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x2, y2, 0) - .color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x3, y3, 0) - .color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF) - .endVertex(); + bufferbuilder.vertex(model, x0, y0, 0).color(fc1 >> 16 & 0xFF, fc1 >> 8 & 0xFF, fc1 & 0xFF, fc1 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x2, y2, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x3, y3, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex(); - bufferbuilder.vertex(model, x3, y3, 0) - .color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x1, y1, 0) - .color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x4, y4, 0) - .color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF) - .endVertex(); + bufferbuilder.vertex(model, x3, y3, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x1, y1, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x4, y4, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex(); - bufferbuilder.vertex(model, x3, y3, 0) - .color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x4, y4, 0) - .color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x6, y6, 0) - .color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF) - .endVertex(); + bufferbuilder.vertex(model, x3, y3, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x4, y4, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x6, y6, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex(); - bufferbuilder.vertex(model, x5, y5, 0) - .color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x4, y4, 0) - .color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x7, y7, 0) - .color(fc4 >> 16 & 0xFF, fc4 >> 8 & 0xFF, fc4 & 0xFF, fc4 >> 24 & 0xFF) - .endVertex(); + bufferbuilder.vertex(model, x5, y5, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x4, y4, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x7, y7, 0).color(fc4 >> 16 & 0xFF, fc4 >> 8 & 0xFF, fc4 & 0xFF, fc4 >> 24 & 0xFF).endVertex(); - bufferbuilder.vertex(model, x6, y6, 0) - .color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x5, y5, 0) - .color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF) - .endVertex(); - bufferbuilder.vertex(model, x8, y8, 0) - .color(fc4 >> 16 & 0xFF, fc4 >> 8 & 0xFF, fc4 & 0xFF, fc4 >> 24 & 0xFF) - .endVertex(); + bufferbuilder.vertex(model, x6, y6, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x5, y5, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex(); + bufferbuilder.vertex(model, x8, y8, 0).color(fc4 >> 16 & 0xFF, fc4 >> 8 & 0xFF, fc4 & 0xFF, fc4 >> 24 & 0xFF).endVertex(); tessellator.draw(); RenderSystem.shadeModel(GL11.GL_FLAT); @@ -288,7 +233,7 @@ public class UIRenderHelper { //just like AbstractGui#drawTexture, but with a color at every vertex public static void drawColoredTexture(MatrixStack ms, Color c, int x, int y, int tex_left, int tex_top, int width, int height) { - drawColoredTexture(ms, c, x, y, 0, (float)tex_left, (float)tex_top, width, height, 256, 256); + drawColoredTexture(ms, c, x, y, 0, (float) tex_left, (float) tex_top, width, height, 256, 256); } public static void drawColoredTexture(MatrixStack ms, Color c, int x, int y, int z, float tex_left, float tex_top, int width, int height, int sheet_width, int sheet_height) { @@ -296,17 +241,17 @@ public class UIRenderHelper { } private static void drawColoredTexture(MatrixStack ms, Color c, int left, int right, int top, int bot, int z, int tex_width, int tex_height, float tex_left, float tex_top, int sheet_width, int sheet_height) { - drawTexturedQuad(ms.peek().getModel(), c, left, right, top, bot, z, (tex_left + 0.0F) / (float)sheet_width, (tex_left + (float)tex_width) / (float)sheet_width, (tex_top + 0.0F) / (float)sheet_height, (tex_top + (float)tex_height) / (float)sheet_height); + drawTexturedQuad(ms.peek().getModel(), c, left, right, top, bot, z, (tex_left + 0.0F) / (float) sheet_width, (tex_left + (float) tex_width) / (float) sheet_width, (tex_top + 0.0F) / (float) sheet_height, (tex_top + (float) tex_height) / (float) sheet_height); } private static void drawTexturedQuad(Matrix4f m, Color c, int left, int right, int top, int bot, int z, float u1, float u2, float v1, float v2) { RenderSystem.enableBlend(); BufferBuilder bufferbuilder = Tessellator.getInstance().getBuffer(); - bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR_TEXTURE); - bufferbuilder.vertex(m, (float)left , (float)bot, (float)z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u1, v2).endVertex(); - bufferbuilder.vertex(m, (float)right, (float)bot, (float)z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u2, v2).endVertex(); - bufferbuilder.vertex(m, (float)right, (float)top, (float)z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u2, v1).endVertex(); - bufferbuilder.vertex(m, (float)left , (float)top, (float)z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u1, v1).endVertex(); + bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEXTURE); + bufferbuilder.vertex(m, (float) left , (float) bot, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u1, v2).endVertex(); + bufferbuilder.vertex(m, (float) right, (float) bot, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u2, v2).endVertex(); + bufferbuilder.vertex(m, (float) right, (float) top, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u2, v1).endVertex(); + bufferbuilder.vertex(m, (float) left , (float) top, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u1, v1).endVertex(); bufferbuilder.finishDrawing(); RenderSystem.enableAlphaTest(); WorldVertexBufferUploader.draw(bufferbuilder); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java index bf0d2adb7..59d350155 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java @@ -134,14 +134,14 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { // draw last screen into buffer if (lastScreen != null && lastScreen != this && !transition.settled()) { - ms.push();// 1 + ms.push(); UIRenderHelper.framebuffer.framebufferClear(Minecraft.IS_RUNNING_ON_MAC); - //UIRenderHelper.prepFramebufferSize(); - ms.push();// 2 ms.translate(0, 0, -1000); UIRenderHelper.framebuffer.bindFramebuffer(true); lastScreen.render(ms, mouseX, mouseY, partialTicks); - ms.pop();// 2 + + ms.pop(); + ms.push(); // use the buffer texture Minecraft.getInstance() @@ -157,10 +157,8 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { dpy = ((NavigatableSimiScreen) lastScreen).depthPointY; } - // transitionV is 1/-1 when the older screen is hidden - // transitionV is 0 when the older screen is still fully visible ms.translate(dpx, dpy, 0); - ms.scale((float) scale, (float) scale, 1); + ms.scale(scale, scale, 1); ms.translate(-dpx, -dpy, 0); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); @@ -168,13 +166,13 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { UIRenderHelper.drawFramebuffer(1f - Math.abs(transitionValue)); RenderSystem.disableBlend(); RenderSystem.enableAlphaTest(); - ms.pop();// 1 + ms.pop(); } // modify current screen as well scale = transitionValue > 0 ? 1 - 0.5f * (1 - transitionValue) : 1 + .5f * (1 + transitionValue); ms.translate(depthPointX, depthPointY, 0); - ms.scale((float) scale, (float) scale, 1); + ms.scale(scale, scale, 1); ms.translate(-depthPointX, -depthPointY, 0); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java index 1adeca3b8..d2c25f25f 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java @@ -2,8 +2,6 @@ package com.simibubi.create.foundation.ponder; import javax.annotation.Nonnull; -import org.antlr.v4.runtime.misc.IntegerList; - import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.gui.BoxElement; import com.simibubi.create.foundation.gui.Theme; @@ -27,20 +25,20 @@ public class PonderProgressBar extends AbstractSimiWidget { this.ponder = ponder; progress = LerpedFloat.linear() - .startWithValue(0); + .startWithValue(0); } public void tick() { progress.chase(ponder.getActiveScene() - .getSceneProgress(), .5f, LerpedFloat.Chaser.EXP); + .getSceneProgress(), .5f, LerpedFloat.Chaser.EXP); progress.tickChaser(); } @Override protected boolean clicked(double mouseX, double mouseY) { return this.active && this.visible && !ponder.getActiveScene().keyframeTimes.isEmpty() - && mouseX >= (double) this.x && mouseX < (double) (this.x + this.width + 4) && mouseY >= (double) this.y - 3 - && mouseY < (double) (this.y + this.height + 20); + && mouseX >= (double) this.x && mouseX < (double) (this.x + this.width + 4) && mouseY >= (double) this.y - 3 + && mouseY < (double) (this.y + this.height + 20); } @Override @@ -101,7 +99,6 @@ public class PonderProgressBar extends AbstractSimiWidget { .withBounds(width, height) .render(ms); - ms.push(); ms.translate(x - 2, y - 2, 150); @@ -157,7 +154,7 @@ public class PonderProgressBar extends AbstractSimiWidget { if (selected) { FontRenderer font = Minecraft.getInstance().fontRenderer; GuiUtils.drawGradientRect(ms.peek() - .getModel(), 100, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor); + .getModel(), 100, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor); ms.push(); ms.translate(0, 0, 100); String text; @@ -174,7 +171,7 @@ public class PonderProgressBar extends AbstractSimiWidget { } GuiUtils.drawGradientRect(ms.peek() - .getModel(), 500, keyframePos, -1, keyframePos + 1, 2 + height, startColor, endColor); + .getModel(), 500, keyframePos, -1, keyframePos + 1, 2 + height, startColor, endColor); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java index 3b8657ef3..7f0e951fd 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -219,7 +219,7 @@ public class PonderUI extends NavigatableSimiScreen { .showing(AllIcons.I_MTD_SLOW_MODE) .enableFade(0, 5) .withCallback(() -> setComfyReadingEnabled(!isComfyReadingEnabled()))); - + if (PonderIndex.EDITOR_MODE) { widgets.add(userMode = new PonderButton(width - 50 - 31, bY) .showing(AllIcons.I_MTD_USER_MODE) @@ -443,7 +443,6 @@ public class PonderUI extends NavigatableSimiScreen { MutableBoundingBox bounds = story.getBounds(); ms.push(); - // ms.peek().getModel().multiply(ms.peek().getModel()); // kool shadow fx { @@ -560,7 +559,6 @@ public class PonderUI extends NavigatableSimiScreen { int streakHeight = 35 - 9 + wordWrappedHeight; UIRenderHelper.streak(ms, 0, x - 4, y - 12 + streakHeight / 2, streakHeight, (int) (150 * fade)); UIRenderHelper.streak(ms, 180, x - 4, y - 12 + streakHeight / 2, streakHeight, (int) (30 * fade)); - //renderBox(ms, 21, 21, 30, 30, false); new BoxElement() .withBackground(Theme.c(Theme.Key.PONDER_BACKGROUND_FLAT)) .gradientBorder(Theme.p(Theme.Key.PONDER_IDLE)) @@ -577,7 +575,6 @@ public class PonderUI extends NavigatableSimiScreen { textRenderer.draw(ms, Lang.translate(PONDERING), x, y - 6, tooltipColor); y += 8; x += 0; - // ms.translate(0, 3 * (indexDiff), 0); ms.translate(x, y, 0); ms.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(indexDiff * -75)); ms.translate(0, 0, 5); @@ -740,22 +737,6 @@ public class PonderUI extends NavigatableSimiScreen { ms.pop(); } - /*protected void lowerButtonGroup(MatrixStack ms, int index, int mouseX, int mouseY, float fade, AllIcons icon, KeyBinding key) { - int bWidth = 20; - int bHeight = 20; - int bX = (width - bWidth) / 2 + (index - 1) * (bWidth + 8); - int bY = height - bHeight - 31; - - ms.push(); - if (fade < fadeIn.getChaseTarget()) - ms.translate(0, (1 - fade) * 5, 0); - boolean hovered = isMouseOver(mouseX, mouseY, bX, bY, bWidth, bHeight); - renderBox(ms, bX, bY, bWidth, bHeight, hovered); - icon.draw(ms, bX + 2, bY + 2); - drawCenteredText(ms, textRenderer, key.getBoundKeyLocalizedText(), bX + bWidth / 2 + 8, bY + bHeight - 6, 0xff606060); - ms.pop(); - }*/ - private void renderOverlay(MatrixStack ms, int i, float partialTicks) { if (identifyMode) return; @@ -767,23 +748,6 @@ public class PonderUI extends NavigatableSimiScreen { @Override public boolean mouseClicked(double x, double y, int button) { - /*MutableBoolean handled = new MutableBoolean(false); - widgets.forEach(w -> { - if (handled.booleanValue()) - return; - if (!w.isMouseOver(x, y)) - return; - if (w instanceof PonderButton) { - PonderButton mtdButton = (PonderButton) w; - mtdButton.runCallback(x, y); - handled.setTrue(); - return; - } - }); - - if (handled.booleanValue()) - return true;*/ - if (identifyMode && hoveredBlockPos != null && PonderIndex.EDITOR_MODE) { long handle = client.getWindow() .getHandle(); @@ -920,7 +884,6 @@ public class PonderUI extends NavigatableSimiScreen { break; } - //renderBox(ms, boxX, boxY, w, h, highlighted); new BoxElement() .withBackground(Theme.c(Theme.Key.PONDER_BACKGROUND_FLAT)) .gradientBorder(borderColors) @@ -945,21 +908,6 @@ public class PonderUI extends NavigatableSimiScreen { } - /*public static void renderBox(MatrixStack ms, int x, int y, int w, int h, int backgroundColor, int borderColorStart, - int borderColorEnd) { - int z = 100; - Matrix4f model = ms.peek().getModel(); - GuiUtils.drawGradientRect(model, z, x - 3, y - 4, x + w + 3, y - 3, backgroundColor, backgroundColor); - GuiUtils.drawGradientRect(model, z, x - 3, y + h + 3, x + w + 3, y + h + 4, backgroundColor, backgroundColor); - GuiUtils.drawGradientRect(model, z, x - 3, y - 3, x + w + 3, y + h + 3, backgroundColor, backgroundColor); - GuiUtils.drawGradientRect(model, z, x - 4, y - 3, x - 3, y + h + 3, backgroundColor, backgroundColor); - GuiUtils.drawGradientRect(model, z, x + w + 3, y - 3, x + w + 4, y + h + 3, backgroundColor, backgroundColor); - GuiUtils.drawGradientRect(model, z, x - 3, y - 3 + 1, x - 3 + 1, y + h + 3 - 1, borderColorStart, borderColorEnd); - GuiUtils.drawGradientRect(model, z, x + w + 2, y - 3 + 1, x + w + 3, y + h + 3 - 1, borderColorStart, borderColorEnd); - GuiUtils.drawGradientRect(model, z, x - 3, y - 3, x + w + 3, y - 3 + 1, borderColorStart, borderColorStart); - GuiUtils.drawGradientRect(model, z, x - 3, y + h + 2, x + w + 3, y + h + 3, borderColorEnd, borderColorEnd); - }*/ - public ItemStack getHoveredTooltipItem() { return hoveredTooltipItem; } @@ -1026,4 +974,4 @@ public class PonderUI extends NavigatableSimiScreen { AllConfigs.CLIENT.comfyReading.set(slowTextMode); } -} \ No newline at end of file +}