Skip to content

Commit

Permalink
Fix cherrypick conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Nov 9, 2023
1 parent b07e1c7 commit db6b889
Show file tree
Hide file tree
Showing 25 changed files with 226 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,22 @@ public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth
{
Component subtitle = Component.translatable("config.roughlyenoughitems.configureCategories.visibility." + shown)
.withStyle(shown ? ChatFormatting.GREEN : ChatFormatting.RED);
int i = client.font.drawShadow(matrices, subtitle.getVisualOrderText(), xPos, y + 22, 8421504);
int i = graphics.drawString(client.font, subtitle.getVisualOrderText(), xPos, y + 22, 8421504);
visibilityToggleButton.getPoint().setLocation(i + 3, y + 22);
visibilityToggleButton.render(matrices, mouseX, mouseY, delta);
visibilityToggleButton.render(graphics, mouseX, mouseY, delta);
}
if (shown) {
Component subtitle = Component.translatable("config.roughlyenoughitems.filtering.filteringQuickCraftCategories.configure." + filteringQuickCraftCategories.getOrDefault(configuration.getCategoryIdentifier(), configuration.isQuickCraftingEnabledByDefault()))
.withStyle(ChatFormatting.GRAY);
int i = client.font.drawShadow(matrices, subtitle.getVisualOrderText(), xPos, y + 32, 8421504);
int i = graphics.drawString(client.font, subtitle.getVisualOrderText(), xPos, y + 32, 8421504);
quickCraftToggleButton.getPoint().setLocation(i + 3, y + 32);
quickCraftToggleButton.render(matrices, mouseX, mouseY, delta);
quickCraftToggleButton.render(graphics, mouseX, mouseY, delta);
} else {
quickCraftToggleButton.getPoint().setLocation(-12390, -12390);
}
upButton.setX(x + entryWidth - 20);
upButton.setY(y + entryHeight / 2 - 21);
upButton.render(matrices, mouseX, mouseY, delta);
upButton.render(graphics, mouseX, mouseY, delta);
downButton.setX(x + entryWidth - 20);
downButton.setY(y + entryHeight / 2 + 1);
downButton.render(graphics, mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import me.shedaniel.rei.impl.client.gui.widget.basewidgets.TextFieldWidget;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
Expand Down Expand Up @@ -137,20 +138,20 @@ public void init() {
this.widgets.add(HoleWidget.createBackground(new Rectangle(8 + sideWidth + 4, 32, width - 16 - sideWidth - 4, 20), () -> 0, 32));
TextFieldWidget textField = new TextFieldWidget(new Rectangle(8 + sideWidth + 4 + 6, 32 + 6, width - 16 - sideWidth - 4 - 10, 12)) {
@Override
protected void renderSuggestion(PoseStack matrices, int x, int y) {
protected void renderSuggestion(GuiGraphics graphics, int x, int y) {
int color;
if (containsMouse(PointHelper.ofMouse()) || isFocused()) {
color = 0xddeaeaea;
} else {
color = -6250336;
}
this.font.drawShadow(matrices, this.font.plainSubstrByWidth(this.getSuggestion(), this.getWidth()), x, y, color);
graphics.drawString(this.font, this.font.plainSubstrByWidth(this.getSuggestion(), this.getWidth()), x, y, color);
}
};
textField.setHasBorder(false);
textField.setMaxLength(9000);
this.widgets.add(textField);
this.widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
this.widgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> {
textField.setSuggestion(!textField.isFocused() && textField.getText().isEmpty() ? I18n.get("config.rei.texts.search_options") : null);
}));
this.widgets.add(ConfigSearchListWidget.create(this, this.categories, textField, new Rectangle(8, 32 + 20 + 4, width - 16, height - 32 - (32 + 20 + 4))));
Expand Down Expand Up @@ -213,13 +214,13 @@ private Widget createEntriesList(boolean singlePane, int singleSideWidth, int si
}

@Override
public void render(PoseStack poses, int mouseX, int mouseY, float delta) {
this.renderDirtBackground(poses);
super.render(poses, mouseX, mouseY, delta);
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
this.renderDirtBackground(graphics);
super.render(graphics, mouseX, mouseY, delta);
for (Widget widget : widgets) {
widget.render(poses, mouseX, mouseY, delta);
widget.render(graphics, mouseX, mouseY, delta);
}
ScreenOverlayImpl.getInstance().lateRender(poses, mouseX, mouseY, delta);
ScreenOverlayImpl.getInstance().lateRender(graphics, mouseX, mouseY, delta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.FormattedCharSequence;
Expand All @@ -47,8 +48,8 @@ public static WidgetWithBounds create(OptionCategory category, int width) {
.leftAligned();
Font font = Minecraft.getInstance().font;
MutableComponent description = category.getDescription().copy().withStyle(style -> style.withColor(0xFF909090));
Widget descriptionLabel = Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
renderTextScrolling(matrices, description, 0, 0, (int) ((width - 21 - 6) / 0.75), 0xFF909090);
Widget descriptionLabel = Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> {
renderTextScrolling(graphics, description, 0, 0, (int) ((width - 21 - 6) / 0.75), 0xFF909090);
});
Rectangle bounds = new Rectangle(0, 0, label.getBounds().getMaxX(), hasDescription ? 24 : 7 * 3);
return Widgets.concatWithBounds(
Expand All @@ -69,25 +70,25 @@ public static WidgetWithBounds createTiny(OptionCategory category) {
);
}

private static void renderTextScrolling(PoseStack poses, Component text, int x, int y, int width, int color) {
renderTextScrolling(poses, text.getVisualOrderText(), x, y, width, color);
private static void renderTextScrolling(GuiGraphics graphics, Component text, int x, int y, int width, int color) {
renderTextScrolling(graphics, text.getVisualOrderText(), x, y, width, color);
}

private static void renderTextScrolling(PoseStack poses, FormattedCharSequence text, int x, int y, int width, int color) {
try (CloseableScissors scissors = scissor(poses, new Rectangle(x, y, width, y + 9))) {
private static void renderTextScrolling(GuiGraphics graphics, FormattedCharSequence text, int x, int y, int width, int color) {
try (CloseableScissors scissors = scissor(graphics, new Rectangle(x, y, width, y + 9))) {
Font font = Minecraft.getInstance().font;
int textWidth = font.width(text);
textWidth = MatrixUtils.transform(MatrixUtils.inverse(poses.last().pose()), new Rectangle(0, 0, textWidth, 100)).width;
width = MatrixUtils.transform(MatrixUtils.inverse(poses.last().pose()), new Rectangle(0, 0, width, 100)).width;
textWidth = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose().last().pose()), new Rectangle(0, 0, textWidth, 100)).width;
width = MatrixUtils.transform(MatrixUtils.inverse(graphics.pose().last().pose()), new Rectangle(0, 0, width, 100)).width;
if (textWidth > width && !ConfigUtils.isReducedMotion()) {
poses.pushPose();
graphics.pose().pushPose();
float textX = (System.currentTimeMillis() % ((textWidth + 10) * textWidth / 3)) / (float) textWidth * 3;
poses.translate(-textX, 0, 0);
font.drawShadow(poses, text, x + width - textWidth - 10, y, color);
font.drawShadow(poses, text, x + width, y, color);
poses.popPose();
graphics.pose().translate(-textX, 0, 0);
graphics.drawString(font, text, x + width - textWidth - 10, y, color);
graphics.drawString(font, text, x + width, y, color);
graphics.pose().popPose();
} else {
font.drawShadow(poses, text, x, y, color);
graphics.drawString(font, text, x, y, color);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import me.shedaniel.rei.impl.client.gui.config.options.preview.InterfacePreviewer;
import me.shedaniel.rei.impl.client.gui.config.options.preview.TooltipPreviewer;
import me.shedaniel.rei.impl.client.gui.text.TextTransformations;
import net.minecraft.client.gui.GuiComponent;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
Expand Down Expand Up @@ -110,16 +109,16 @@ private static WidgetWithBounds _create(ConfigAccess access, OptionGroup entry,
widgets.add(WidgetComposite.of(ConfigOptionWidget.create(access, option, width)));

if (entry.getOptions().get(entry.getOptions().size() - 1) != option) {
Widget separator = Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
Widget separator = Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> {
for (int x = 0; x <= width; x += 4) {
GuiComponent.fill(matrices, Math.min(width, x), 1, Math.min(width, x + 2), 2, 0xFF757575);
graphics.fill(Math.min(width, x), 1, Math.min(width, x + 2), 2, 0xFF757575);
}
});
widgets.add(WidgetComposite.of(Widgets.withBounds(separator, new Rectangle(0, 0, 1, 7))));
}
}

widgets.add(WidgetComposite.ofNonAccounting(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
widgets.add(WidgetComposite.ofNonAccounting(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> {
recalculateHeight(widgets, i -> height[0] = i);
})));
recalculateHeight(widgets, i -> height[0] = i);
Expand Down Expand Up @@ -172,10 +171,10 @@ public enum PreviewLocation {
}

private static Widget createBackgroundSlot(Supplier<Rectangle> bounds) {
return Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
return Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> {
Rectangle rectangle = bounds.get();
GuiComponent.fill(matrices, rectangle.x, rectangle.y, rectangle.getMaxX(), rectangle.getMaxY(), 0xFF333333);
GuiComponent.fill(matrices, rectangle.x + 1, rectangle.y + 1, rectangle.getMaxX() - 1, rectangle.getMaxY() - 1, 0xFF000000);
graphics.fill(rectangle.x, rectangle.y, rectangle.getMaxX(), rectangle.getMaxY(), 0xFF333333);
graphics.fill(rectangle.x + 1, rectangle.y + 1, rectangle.getMaxX() - 1, rectangle.getMaxY() - 1, 0xFF000000);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
Expand Down Expand Up @@ -90,7 +91,7 @@ public static <T> WidgetWithBounds create(ConfigAccess access, CompositeOption<T
Label label = Widgets.createLabel(new Point(), text[0]).rightAligned()
.color(0xFFE0E0E0)
.hoveredColor(0xFFE0E0E0)
.onRender((poses, l) -> {
.onRender((graphics, l) -> {
if (MatrixUtils.transform(matrix[0], l.getBounds()).contains(PointHelper.ofMouse())) {
l.setMessage(text[0].copy().withStyle(ChatFormatting.UNDERLINE));
} else {
Expand All @@ -113,7 +114,7 @@ public static <T> WidgetWithBounds create(ConfigAccess access, CompositeOption<T

return Widgets.concatWithBounds(() -> new Rectangle(-label.getBounds().width, 0, label.getBounds().width + 8, 14),
label,
Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> matrix[0] = matrices.last().pose()),
Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> matrix[0] = graphics.pose().last().pose()),
Widgets.withTranslate(Widgets.createTexturedWidget(new ResourceLocation("roughlyenoughitems:textures/gui/config/selector.png"),
new Rectangle(1, 1, 4, 6), 0, 0, 1, 1, 1, 1), 0, 0.5, 0)
);
Expand Down Expand Up @@ -151,9 +152,9 @@ private static <T> void applyKeycode(ConfigAccess access, CompositeOption<T> opt
access.closeMenu();
access.focusKeycode((CompositeOption<ModifierKeyCode>) option);
});
BiConsumer<PoseStack, Label> render = label.getOnRender();
label.onRender((poses, $) -> {
render.accept(poses, $);
BiConsumer<GuiGraphics, Label> render = label.getOnRender();
label.onRender((graphics, $) -> {
render.accept(graphics, $);
setText.accept(((ModifierKeyCode) access.get(option)).getLocalizedName());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

package me.shedaniel.rei.impl.client.gui.config.components;

import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.clothconfig2.api.ScissorsHandler;
import me.shedaniel.clothconfig2.api.animator.NumberAnimator;
import me.shedaniel.clothconfig2.api.animator.ValueAnimator;
Expand All @@ -40,6 +39,7 @@
import me.shedaniel.rei.impl.client.gui.text.TextTransformations;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.FormattedCharSequence;
Expand Down Expand Up @@ -106,13 +106,13 @@ public Rectangle getBounds() {
}

@Override
public void render(PoseStack poses, int mouseX, int mouseY, float delta) {
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
this.previewHeight.update(delta);
if (ConfigUtils.isReducedMotion()) this.previewHeight.completeImmediately();
height[0] = stableHeight[0] + Math.round(this.previewHeight.value());

for (int i = 0; i < split.size(); i++) {
Minecraft.getInstance().font.draw(poses, split.get(i), 0, 12 + 12 * i, -1);
graphics.drawString(font, split.get(i), 0, 12 + 12 * i, -1, false);
}

if (hasPreview) {
Expand All @@ -122,12 +122,12 @@ public void render(PoseStack poses, int mouseX, int mouseY, float delta) {
this.previewLabel.setPoint(new Point(width, 12 + 12 * split.size() - 12));
}

this.previewLabel.render(poses, mouseX, mouseY, delta);
this.previewLabel.render(graphics, mouseX, mouseY, delta);

if (this.preview != null && this.previewHeight.value() > 0.1f) {
ScissorsHandler.INSTANCE.scissor(MatrixUtils.transform(poses.last().pose(), new Rectangle(0, 24 + 12 * split.size() - (nextLinePreview ? 0 : 12), width, this.previewHeight.value())));
ScissorsHandler.INSTANCE.scissor(MatrixUtils.transform(graphics.pose().last().pose(), new Rectangle(0, 24 + 12 * split.size() - (nextLinePreview ? 0 : 12), width, this.previewHeight.value())));
this.previewTranslation = new Matrix4f().translate(0, 12 + 12 * split.size(), 100);
this.preview.render(poses, mouseX, mouseY, delta);
this.preview.render(graphics, mouseX, mouseY, delta);
ScissorsHandler.INSTANCE.removeLastScissor();
}
}
Expand Down
Loading

0 comments on commit db6b889

Please sign in to comment.