aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-03-23 00:02:16 +0800
committershedaniel <daniel@shedaniel.me>2021-03-23 00:02:16 +0800
commitc027169dfe9503a9d913589eb322cc11ddad0baa (patch)
treecea2db418d26b0ba9f054445891f272264ae3d30 /runtime/src/main/java/me
parent7bbef49785f594dfe3d6eac0cfc6ee84841aae80 (diff)
downloadRoughlyEnoughItems-c027169dfe9503a9d913589eb322cc11ddad0baa.tar.gz
RoughlyEnoughItems-c027169dfe9503a9d913589eb322cc11ddad0baa.tar.bz2
RoughlyEnoughItems-c027169dfe9503a9d913589eb322cc11ddad0baa.zip
Improve UncertainDisplayViewingScreen
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'runtime/src/main/java/me')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java24
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java)4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/CompositeDisplayViewingScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java)14
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/DefaultDisplayViewingScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java)40
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/UncertainDisplayViewingScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java)137
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java12
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/widget/DefaultDisplayChoosePageWidget.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java)22
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java20
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java14
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/DynamicErrorFreeEntryListWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/widgets/PanelWidget.java4
15 files changed, 192 insertions, 113 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java
index daffac707..5cf8a567b 100644
--- a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java
@@ -45,7 +45,7 @@ import java.util.List;
import java.util.Objects;
import java.util.function.BiFunction;
-import static me.shedaniel.rei.gui.RecipeViewingScreen.CHEST_GUI_TEXTURE;
+import static me.shedaniel.rei.gui.DefaultDisplayViewingScreen.CHEST_GUI_TEXTURE;
public class FilteringRulesScreen extends Screen {
private final FilteringEntry entry;
diff --git a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java
index 3f32747e9..6da592c47 100644
--- a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java
@@ -27,8 +27,8 @@ import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.clothconfig2.gui.entries.TooltipListEntry;
-import me.shedaniel.rei.api.gui.config.RecipeScreenType;
-import me.shedaniel.rei.gui.PreRecipeViewingScreen;
+import me.shedaniel.rei.api.gui.config.DisplayScreenType;
+import me.shedaniel.rei.gui.UncertainDisplayViewingScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.client.gui.components.AbstractButton;
@@ -41,18 +41,18 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
-public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
+public class RecipeScreenTypeEntry extends TooltipListEntry<DisplayScreenType> {
private int width;
- private final RecipeScreenType original;
- private RecipeScreenType type;
- private RecipeScreenType defaultValue;
- private Consumer<RecipeScreenType> save;
+ private final DisplayScreenType original;
+ private DisplayScreenType type;
+ private DisplayScreenType defaultValue;
+ private Consumer<DisplayScreenType> save;
private final AbstractWidget buttonWidget = new AbstractButton(0, 0, 0, 20, NarratorChatListener.NO_TITLE) {
@Override
public void onPress() {
- Minecraft.getInstance().setScreen(new PreRecipeViewingScreen(getConfigScreen(), type, false, original -> {
+ Minecraft.getInstance().setScreen(new UncertainDisplayViewingScreen(getConfigScreen(), type, false, original -> {
Minecraft.getInstance().setScreen(getConfigScreen());
- type = original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER;
+ type = original ? DisplayScreenType.ORIGINAL : DisplayScreenType.COMPOSITE;
}));
}
@@ -65,7 +65,7 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
private final List<GuiEventListener> children = ImmutableList.of(buttonWidget);
@SuppressWarnings("deprecation")
- public RecipeScreenTypeEntry(int width, Component fieldName, RecipeScreenType type, RecipeScreenType defaultValue, Consumer<RecipeScreenType> save) {
+ public RecipeScreenTypeEntry(int width, Component fieldName, DisplayScreenType type, DisplayScreenType defaultValue, Consumer<DisplayScreenType> save) {
super(fieldName, null);
this.original = type;
this.width = width;
@@ -80,12 +80,12 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
}
@Override
- public RecipeScreenType getValue() {
+ public DisplayScreenType getValue() {
return type;
}
@Override
- public Optional<RecipeScreenType> getDefaultValue() {
+ public Optional<DisplayScreenType> getDefaultValue() {
return Optional.ofNullable(defaultValue);
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java
index c7fdcfc54..bfa985be7 100644
--- a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java
@@ -43,7 +43,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
-public abstract class AbstractRecipeViewingScreen extends Screen implements RecipeScreen {
+public abstract class AbstractDisplayViewingScreen extends Screen implements RecipeScreen {
protected final Map<DisplayCategory<?>, List<Display>> categoryMap;
protected final List<DisplayCategory<?>> categories;
protected EntryStack<?> ingredientStackToNotice = EntryStack.empty();
@@ -52,7 +52,7 @@ public abstract class AbstractRecipeViewingScreen extends Screen implements Reci
protected int tabsPerPage;
protected Rectangle bounds;
- protected AbstractRecipeViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable ResourceLocation category, int tabsPerPage) {
+ protected AbstractDisplayViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable ResourceLocation category, int tabsPerPage) {
super(NarratorChatListener.NO_TITLE);
this.categoryMap = categoryMap;
this.categories = Lists.newArrayList(categoryMap.keySet());
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/CompositeDisplayViewingScreen.java
index 6bdd6beee..40826d9f3 100644
--- a/runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/gui/CompositeDisplayViewingScreen.java
@@ -68,7 +68,7 @@ import java.util.Map;
import java.util.Optional;
@ApiStatus.Internal
-public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
+public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen {
private final List<Widget> widgets = Lists.newArrayList();
private final List<Button> buttonList = Lists.newArrayList();
private final List<DisplayRenderer> displayRenderers = Lists.newArrayList();
@@ -95,7 +95,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
private long scrollBarAlphaFutureTime = -1;
private int tabsPage = -1;
- public VillagerRecipeViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable ResourceLocation category) {
+ public CompositeDisplayViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable ResourceLocation category) {
super(categoryMap, category, 8);
}
@@ -138,7 +138,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
widgets.add(Widgets.createSlotBase(new Rectangle(xx - 1, yy - 1, 2 + w * 16, 2 + h * 16)));
int index = 0;
for (EntryIngredient workingStation : workstations) {
- widgets.add(new RecipeViewingScreen.WorkstationSlotWidget(xx, yy, workingStation));
+ widgets.add(new DefaultDisplayViewingScreen.WorkstationSlotWidget(xx, yy, workingStation));
index++;
xx += 16;
if (index >= ww) {
@@ -170,7 +170,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
buttonList.add(Widgets.createButton(new Rectangle(bounds.x + 5, 0, displayRenderer.getWidth(), displayRenderer.getHeight()), NarratorChatListener.NO_TITLE)
.onClick(button -> {
selectedRecipeIndex = finalIndex;
- VillagerRecipeViewingScreen.this.init();
+ CompositeDisplayViewingScreen.this.init();
})
.containsMousePredicate((button, point) -> {
return (button.getBounds().contains(point) && scrollListBounds.contains(point)) || button.isFocused();
@@ -199,7 +199,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
tabsPage--;
if (tabsPage < 0)
tabsPage = Mth.ceil(categories.size() / (float) tabsPerPage) - 1;
- VillagerRecipeViewingScreen.this.init();
+ CompositeDisplayViewingScreen.this.init();
})
.enabled(categories.size() > tabsPerPage));
this.widgets.add(Widgets.createButton(new Rectangle(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10), new TranslatableComponent("text.rei.right_arrow"))
@@ -207,7 +207,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
tabsPage++;
if (tabsPage > Mth.ceil(categories.size() / (float) tabsPerPage) - 1)
tabsPage = 0;
- VillagerRecipeViewingScreen.this.init();
+ CompositeDisplayViewingScreen.this.init();
})
.enabled(categories.size() > tabsPerPage));
@@ -305,7 +305,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
- if (ConfigObject.getInstance().doesVillagerScreenHavePermanentScrollBar()) {
+ if (ConfigObject.getInstance().isCompositeScrollBarPermanent()) {
scrollBarAlphaFutureTime = System.currentTimeMillis();
scrollBarAlphaFuture = 0;
scrollBarAlpha = 1;
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
index e466e342b..258cd52fd 100644
--- a/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
+++ b/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
@@ -600,7 +600,7 @@ public class ContainerScreenOverlay extends REIOverlay {
}
}
Screen currentScreen = Minecraft.getInstance().screen;
- if (!(currentScreen instanceof RecipeViewingScreen) || !((RecipeViewingScreen) currentScreen).choosePageActivated) {
+ if (!(currentScreen instanceof DefaultDisplayViewingScreen) || !((DefaultDisplayViewingScreen) currentScreen).choosePageActivated) {
for (Tooltip tooltip : TOOLTIPS) {
if (tooltip != null)
renderTooltip(matrices, tooltip);
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/DefaultDisplayViewingScreen.java
index 10f5f0176..67c98d0ee 100644
--- a/runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/gui/DefaultDisplayViewingScreen.java
@@ -50,7 +50,7 @@ import me.shedaniel.rei.api.util.CollectionUtils;
import me.shedaniel.rei.api.util.ImmutableLiteralText;
import me.shedaniel.rei.api.view.ViewSearchBuilder;
import me.shedaniel.rei.gui.widget.EntryWidget;
-import me.shedaniel.rei.gui.widget.RecipeChoosePageWidget;
+import me.shedaniel.rei.gui.widget.DefaultDisplayChoosePageWidget;
import me.shedaniel.rei.gui.widget.TabWidget;
import me.shedaniel.rei.impl.ClientHelperImpl;
import me.shedaniel.rei.impl.InternalWidgets;
@@ -78,7 +78,7 @@ import java.util.Optional;
import java.util.function.Supplier;
@ApiStatus.Internal
-public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
+public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
public static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png");
private final List<Widget> preWidgets = Lists.newArrayList();
private final List<Widget> widgets = Lists.newArrayList();
@@ -87,14 +87,14 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
public int page;
public int categoryPages = -1;
public boolean choosePageActivated = false;
- public RecipeChoosePageWidget recipeChoosePageWidget;
+ public DefaultDisplayChoosePageWidget choosePageWidget;
@Nullable
private Panel workingStationsBaseWidget;
private Button recipeBack, recipeNext, categoryBack, categoryNext;
private EntryStack<?> ingredientStackToNotice = EntryStack.empty();
private EntryStack<?> resultStackToNotice = EntryStack.empty();
- public RecipeViewingScreen(Map<DisplayCategory<?>, List<Display>> categoriesMap, @Nullable ResourceLocation category) {
+ public DefaultDisplayViewingScreen(Map<DisplayCategory<?>, List<Display>> categoriesMap, @Nullable ResourceLocation category) {
super(categoriesMap, category, 5);
this.bounds = new Rectangle(0, 0, 176, 150);
}
@@ -123,7 +123,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
return true;
}
if (choosePageActivated)
- return recipeChoosePageWidget.keyPressed(keyCode, scanCode, modifiers);
+ return choosePageWidget.keyPressed(keyCode, scanCode, modifiers);
else if (ConfigObject.getInstance().getNextPageKeybind().matchesKey(keyCode, scanCode)) {
if (recipeNext.isEnabled())
recipeNext.onClick();
@@ -179,7 +179,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
categoryPages--;
if (categoryPages < 0)
categoryPages = Mth.ceil(categories.size() / (float) tabsPerPage) - 1;
- RecipeViewingScreen.this.init();
+ DefaultDisplayViewingScreen.this.init();
})
.enabled(categories.size() > tabsPerPage));
this.widgets.add(Widgets.createButton(new Rectangle(bounds.x + bounds.width - 10, bounds.y - 16, 10, 10), new TranslatableComponent("text.rei.right_arrow"))
@@ -187,7 +187,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
categoryPages++;
if (categoryPages > Mth.ceil(categories.size() / (float) tabsPerPage) - 1)
categoryPages = 0;
- RecipeViewingScreen.this.init();
+ DefaultDisplayViewingScreen.this.init();
})
.enabled(categories.size() > tabsPerPage));
widgets.add(categoryBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 5, 12, 12), new TranslatableComponent("text.rei.left_arrow"))
@@ -205,11 +205,11 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
page--;
if (page < 0)
page = getCurrentTotalPages() - 1;
- RecipeViewingScreen.this.init();
+ DefaultDisplayViewingScreen.this.init();
}).tooltipLine(I18n.get("text.rei.previous_page")));
widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 21), NarratorChatListener.NO_TITLE, label -> {
- RecipeViewingScreen.this.choosePageActivated = true;
- RecipeViewingScreen.this.init();
+ DefaultDisplayViewingScreen.this.choosePageActivated = true;
+ DefaultDisplayViewingScreen.this.init();
}).onRender((matrices, label) -> {
label.setText(new ImmutableLiteralText(String.format("%d/%d", page + 1, getCurrentTotalPages())));
label.setClickable(getCurrentTotalPages() > 1);
@@ -219,7 +219,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
page++;
if (page >= getCurrentTotalPages())
page = 0;
- RecipeViewingScreen.this.init();
+ DefaultDisplayViewingScreen.this.init();
}).tooltipLine(I18n.get("text.rei.next_page")));
recipeBack.setEnabled(getCurrentTotalPages() > 1);
recipeNext.setEnabled(getCurrentTotalPages() > 1);
@@ -255,9 +255,9 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
this.widgets.add(InternalWidgets.createAutoCraftingButtonWidget(displayBounds, supplier.get().get(displayBounds), new TextComponent(supplier.get().getButtonText()), displaySupplier, setupDisplay, getSelectedCategory()));
}
if (choosePageActivated)
- recipeChoosePageWidget = new RecipeChoosePageWidget(this, page, getCurrentTotalPages());
+ choosePageWidget = new DefaultDisplayChoosePageWidget(this, page, getCurrentTotalPages());
else
- recipeChoosePageWidget = null;
+ choosePageWidget = null;
workingStationsBaseWidget = null;
List<EntryIngredient> workstations = CategoryRegistry.getInstance().get(getCurrentCategory()).getWorkstations();
@@ -374,7 +374,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
setBlitOffset(500);
this.fillGradient(matrices, 0, 0, this.width, this.height, -1072689136, -804253680);
setBlitOffset(0);
- recipeChoosePageWidget.render(matrices, mouseX, mouseY, delta);
+ choosePageWidget.render(matrices, mouseX, mouseY, delta);
}
}
@@ -404,7 +404,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
@Override
public boolean charTyped(char char_1, int int_1) {
if (choosePageActivated) {
- return recipeChoosePageWidget.charTyped(char_1, int_1);
+ return choosePageWidget.charTyped(char_1, int_1);
}
for (GuiEventListener listener : children())
if (listener.charTyped(char_1, int_1))
@@ -415,7 +415,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
@Override
public boolean mouseDragged(double double_1, double double_2, int int_1, double double_3, double double_4) {
if (choosePageActivated) {
- return recipeChoosePageWidget.mouseDragged(double_1, double_2, int_1, double_3, double_4);
+ return choosePageWidget.mouseDragged(double_1, double_2, int_1, double_3, double_4);
}
for (GuiEventListener entry : children())
if (entry.mouseDragged(double_1, double_2, int_1, double_3, double_4))
@@ -426,7 +426,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
if (choosePageActivated) {
- return recipeChoosePageWidget.mouseReleased(mouseX, mouseY, button);
+ return choosePageWidget.mouseReleased(mouseX, mouseY, button);
} else {
ModifierKeyCode export = ConfigObject.getInstance().getExportImageKeybind();
if (export.matchesMouse(button)) {
@@ -473,8 +473,8 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (choosePageActivated) {
- if (recipeChoosePageWidget.containsMouse(mouseX, mouseY)) {
- return recipeChoosePageWidget.mouseClicked(mouseX, mouseY, button);
+ if (choosePageWidget.containsMouse(mouseX, mouseY)) {
+ return choosePageWidget.mouseClicked(mouseX, mouseY, button);
} else {
choosePageActivated = false;
init();
@@ -495,7 +495,7 @@ public class RecipeViewingScreen extends AbstractRecipeViewingScreen {
@Override
public GuiEventListener getFocused() {
if (choosePageActivated)
- return recipeChoosePageWidget;
+ return choosePageWidget;
return super.getFocused();
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/UncertainDisplayViewingScreen.java
index 21551702f..d2664bb4f 100644
--- a/runtime/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/gui/UncertainDisplayViewingScreen.java
@@ -25,22 +25,32 @@ package me.shedaniel.rei.gui;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.math.Matrix4f;
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
+import me.shedaniel.architectury.platform.Platform;
+import me.shedaniel.clothconfig2.api.ScissorsHandler;
import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget;
import me.shedaniel.clothconfig2.impl.EasingMethod;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.api.ClientHelper;
import me.shedaniel.rei.api.REIHelper;
-import me.shedaniel.rei.api.gui.config.RecipeScreenType;
+import me.shedaniel.rei.api.gui.config.DisplayScreenType;
+import me.shedaniel.rei.api.gui.widgets.Button;
import me.shedaniel.rei.api.gui.widgets.Widget;
import me.shedaniel.rei.api.gui.widgets.WidgetWithBounds;
import me.shedaniel.rei.api.gui.widgets.Widgets;
+import me.shedaniel.rei.api.util.ImmutableLiteralText;
+import me.shedaniel.rei.impl.Animator;
+import me.shedaniel.rei.impl.Internals;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.AbstractSliderButton;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
+import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
@@ -48,12 +58,15 @@ import net.minecraft.util.Mth;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
@ApiStatus.Internal
-public class PreRecipeViewingScreen extends Screen {
- private static final ResourceLocation IDENTIFIER = new ResourceLocation("roughlyenoughitems", "textures/gui/screenshot.png");
+public class UncertainDisplayViewingScreen extends Screen {
+ private static final ResourceLocation DEFAULT = new ResourceLocation("roughlyenoughitems", "textures/gui/screenshot_default.png");
+ private static final ResourceLocation COMPOSITE = new ResourceLocation("roughlyenoughitems", "textures/gui/screenshot_composite.png");
private final List<Widget> widgets;
protected long start;
protected long duration;
@@ -62,23 +75,34 @@ public class PreRecipeViewingScreen extends Screen {
private double frame = 0;
private double target = 0;
private BooleanConsumer callback;
+ private Button button;
private Screen parent;
+ private Widget slider;
private boolean showTips;
+ private Animator scroll = new Animator();
+ private List<String> allModsUsingJEI = new ArrayList<>();
- public PreRecipeViewingScreen(Screen parent, RecipeScreenType type, boolean showTips, BooleanConsumer callback) {
- super(new TranslatableComponent("text.rei.recipe_screen_type.selection"));
+ public UncertainDisplayViewingScreen(Screen parent, DisplayScreenType type, boolean showTips, BooleanConsumer callback) {
+ super(ImmutableLiteralText.EMPTY);
this.widgets = Lists.newArrayList();
- if (type == RecipeScreenType.UNSET) {
+ if (type == DisplayScreenType.UNSET) {
this.isSet = false;
this.original = true;
} else {
this.isSet = true;
- this.original = type == RecipeScreenType.ORIGINAL;
+ this.original = type == DisplayScreenType.ORIGINAL;
moveFrameTo(original ? 0 : 1, false, 0);
}
+ this.scroll.setAs(0);
this.callback = callback;
this.parent = parent;
this.showTips = showTips;
+ if (showTips && Platform.isForge()) {
+ allModsUsingJEI = Internals.getJeiCompatMods().stream()
+ .distinct()
+ .map(ClientHelper.getInstance()::getModFromModId)
+ .collect(Collectors.toList());
+ }
}
public final double clamp(double v) {
@@ -95,55 +119,107 @@ public class PreRecipeViewingScreen extends Screen {
if (animated) {
start = System.currentTimeMillis();
this.duration = duration;
- } else
+ } else {
frame = target;
+ }
}
@Override
public void init() {
this.children.clear();
this.widgets.clear();
- this.widgets.add(Widgets.createButton(new Rectangle(width / 2 - 100, height - 40, 200, 20), NarratorChatListener.NO_TITLE)
+ this.children.add(button = Widgets.createButton(new Rectangle(width / 2 - 100, height - 40, 200, 20), NarratorChatListener.NO_TITLE)
.onRender((matrices, button) -> {
button.setEnabled(isSet);
- button.setText(isSet ? new TranslatableComponent("text.rei.select") : new TranslatableComponent("config.roughlyenoughitems.recipeScreenType.unset"));
+ if (scroll.target() != 0 && allModsUsingJEI != null) {
+ button.setText(new TranslatableComponent("gui.done"));
+ } else {
+ button.setText(isSet ? new TranslatableComponent("text.rei.select") : new TranslatableComponent("config.roughlyenoughitems.recipeScreenType.unset"));
+ }
})
- .onClick(button -> callback.accept(original)));
- this.widgets.add(new ScreenTypeSelection(width / 2 - 200 - 5, height / 2 - 112 / 2 - 10, 0));
- this.widgets.add(Widgets.createLabel(new Point(width / 2 - 200 - 5 + 104, height / 2 - 112 / 2 + 115), new TranslatableComponent("config.roughlyenoughitems.recipeScreenType.original")).noShadow().color(-1124073473));
- this.widgets.add(new ScreenTypeSelection(width / 2 + 5, height / 2 - 112 / 2 - 10, 112));
- this.widgets.add(Widgets.createLabel(new Point(width / 2 + 5 + 104, height / 2 - 112 / 2 + 115), new TranslatableComponent("config.roughlyenoughitems.recipeScreenType.villager")).noShadow().color(-1124073473));
+ .onClick(button -> {
+ if (scroll.target() == 0 && allModsUsingJEI != null) {
+ scroll.setTo(200, 450);
+ } else {
+ callback.accept(original);
+ }
+ }));
+ this.widgets.add(transformScroll(new ScreenTypeSelection(width / 2 - 200 - 5, height / 2 - 112 / 2 - 10, DisplayScreenType.ORIGINAL)));
+ this.widgets.add(transformScroll(Widgets.createLabel(new Point(width / 2 - 200 - 5 + 104, height / 2 - 112 / 2 + 115), new TranslatableComponent("config.roughlyenoughitems.recipeScreenType.original")).noShadow().color(-1124073473)));
+ this.widgets.add(transformScroll(new ScreenTypeSelection(width / 2 + 5, height / 2 - 112 / 2 - 10, DisplayScreenType.COMPOSITE)));
+ this.widgets.add(transformScroll(Widgets.createLabel(new Point(width / 2 + 5 + 104, height / 2 - 112 / 2 + 115), new TranslatableComponent("config.roughlyenoughitems.recipeScreenType.composite")).noShadow().color(-1124073473)));
+ this.widgets.add(slider = transformScroll(Widgets.wrapVanillaWidget(new AbstractSliderButton(width / 2 - 100, height * 2 - 64, 200, 20, new TranslatableComponent("text.rei.jei_compat.false"), 0) {
+ @Override
+ protected void updateMessage() {
+ setMessage(new TranslatableComponent("text.rei.jei_compat." + (value == 1f)));
+ }
+
+ @Override
+ protected void applyValue() {
+
+ }
+
+ @Override
+ public void renderButton(PoseStack poseStack, int i, int j, float f) {
+ y = UncertainDisplayViewingScreen.this.height * 2 - 64;
+ super.renderButton(poseStack, i, j, f);
+ y = UncertainDisplayViewingScreen.this.height * 2 - 64 - (int) (scroll.floatValue() / 200f * height);
+ }
+ })));
this.children.addAll(widgets);
}
+ private Widget transformScroll(Widget widget) {
+ return Widgets.withTranslate(widget, () -> Matrix4f.createTranslateMatrix(0, -(scroll.floatValue() / 200f * height), 0));
+ }
+
@Override
public void render(PoseStack matrices, int int_1, int int_2, float float_1) {
+ scroll.update(float_1);
if (this.minecraft.level != null) {
this.fillGradient(matrices, 0, 0, this.width, this.height, -1072689136, -804253680);
} else {
this.fillGradient(matrices, 0, 0, this.width, this.height, -16777216, -16777216);
}
- drawCenteredString(matrices, this.font, this.title, this.width / 2, 20, 16777215);
+ if (scroll.target() == 0) {
+ drawCenteredString(matrices, this.font, new TranslatableComponent("text.rei.recipe_screen_type.selection"), this.width / 2, 20, 16777215);
+ } else {
+ drawCenteredString(matrices, this.font, new TranslatableComponent("text.rei.jei_compat"), this.width / 2, 20, 16777215);
+ }
+ ScissorsHandler.INSTANCE.scissor(new Rectangle(0, 20 + font.lineHeight + 2, width, height - 42));
if (showTips) {
- int i = 30;
+ float i = 32 - (scroll.floatValue() / 200f * height);
for (FormattedCharSequence s : this.font.split(new TranslatableComponent("text.rei.recipe_screen_type.selection.sub").withStyle(ChatFormatting.GRAY), width - 30)) {
font.drawShadow(matrices, s, width / 2 - font.width(s) / 2, i, -1);
i += 10;
}
+ if (allModsUsingJEI != null) {
+ i = 32 + height - (scroll.floatValue() / 200f * height);
+ for (FormattedCharSequence s : this.font.split(new TranslatableComponent("text.rei.jei_compat.sub", new TranslatableComponent("text.rei.jei_compat.sub.stability"),
+ new TextComponent(String.join(", ", allModsUsingJEI))).withStyle(ChatFormatting.GRAY), width - 30)) {
+ font.drawShadow(matrices, s, width / 2 - font.width(s) / 2, i, -1);
+ i += 10;
+ }
+ }
}
super.render(matrices, int_1, int_2, float_1);
for (Widget widget : widgets) {
widget.render(matrices, int_1, int_2, float_1);
}
if (isSet) {
+ matrices.pushPose();
+ matrices.translate(0, -(scroll.floatValue() / 200f * height), 0);
updateFramePosition(float_1);
int x = (int) (width / 2 - 205 + (210 * frame));
int y = height / 2 - 112 / 2 - 10;
fillGradient(matrices, x - 2, y - 4, x - 6 + 208, y - 4 + 2, -1778384897, -1778384897);
- fillGradient(matrices, x - 2, y - 4 + 120 - 2, x - 6 + 208, y - 4 + 120, -1778384897, -1778384897);
- fillGradient(matrices, x - 4, y - 4, x - 4 + 2, y - 4 + 120, -1778384897, -1778384897);
- fillGradient(matrices, x - 4 + 208 - 2, y - 4, x - 4 + 208, y - 4 + 120, -1778384897, -1778384897);
+ fillGradient(matrices, x - 2, y - 4 + 126 - 2, x - 6 + 208, y - 4 + 126, -1778384897, -1778384897);
+ fillGradient(matrices, x - 4, y - 4, x - 4 + 2, y - 4 + 126, -1778384897, -1778384897);
+ fillGradient(matrices, x - 4 + 208 - 2, y - 4, x - 4 + 208, y - 4 + 126, -1778384897, -1778384897);
+ matrices.popPose();
}
+ ScissorsHandler.INSTANCE.removeLastScissor();
+ button.render(matrices, int_1, int_2, float_1);
}
private void updateFramePosition(float delta) {
@@ -170,15 +246,18 @@ public class PreRecipeViewingScreen extends Screen {
return super.keyPressed(int_1, int_2, int_3);
}
+ @Override
+ public boolean mouseDragged(double d, double e, int i, double f, double g) {
+ return slider.mouseDragged(d, e, i, f, g) || super.mouseDragged(d, e, i, f, g);
+ }
+
public class ScreenTypeSelection extends WidgetWithBounds {
-
+ private final DisplayScreenType type;