diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java index 11fbe4a37..e7b35df05 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java @@ -280,7 +280,11 @@ default boolean isLeftHandSidePanel() { @ApiStatus.Experimental boolean doDisplayIMEHints(); - + + boolean doesPartialRecipesWarning(); + + void setDoesPartialRecipesWarning(boolean showWarning); + boolean doesFastEntryRendering(); boolean doesCacheEntryRendering(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java index 4b500fa1f..bd8c7ab05 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java @@ -293,7 +293,16 @@ public boolean doDisplayIMEHints() { public void setDoDisplayIMEHints(boolean displayIMEHints) { advanced.tooltips.displayIMEHints = displayIMEHints; } - + + @Override + public boolean doesPartialRecipesWarning() { + return advanced.doesPartialRecipesWarning; + } + + public void setDoesPartialRecipesWarning(boolean showWarning) { + advanced.doesPartialRecipesWarning = showWarning; + } + @Override public boolean doesFastEntryRendering() { return advanced.miscellaneous.newFastEntryRendering; @@ -672,7 +681,9 @@ public static class Advanced { public Commands commands = new Commands(); public Miscellaneous miscellaneous = new Miscellaneous(); public Filtering filtering = new Filtering(); - + + public boolean doesPartialRecipesWarning = true; + public static class Tooltips { @Comment("Declares whether REI should append mod names to entries.") public boolean appendModNames = true; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java index bdb5a8168..f5b86139e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java @@ -40,6 +40,7 @@ static OptionGroup make(String id) { .add(APPEND_MOD_NAMES) .add(APPEND_FAVORITES_HINT); OptionGroup APPEARANCE_ADVANCED = make("appearance.advanced") + .add(PARTIAL_RECIPES_WARNING) .add(RAINBOW); OptionGroup INPUT_KEYBINDS = make("input.keybinds") .add(RECIPE_KEYBIND) diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java index 30a673e38..169d8b7a8 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java @@ -78,6 +78,8 @@ static ComparableValue[] doubleRange(double start, double end, double st CompositeOption RECIPE_LOOKUP_STYLE = make("appearance.recipe_lookup_style", i -> i.appearance.recipeScreenType, (i, v) -> i.appearance.recipeScreenType = v) .options(DisplayScreenType.ORIGINAL, DisplayScreenType.COMPOSITE) .defaultValue(() -> DisplayScreenType.ORIGINAL); + CompositeOption PARTIAL_RECIPES_WARNING = make("appearance.partial_recipes_warning", i -> i.advanced.doesPartialRecipesWarning, (i, v) -> i.advanced.doesPartialRecipesWarning = v) + .enabledDisabled(); CompositeOption RAINBOW = make("appearance.rainbow", i -> i.appearance.rainbow, (i, v) -> i.appearance.rainbow = v) .enabledDisabled(); CompositeOption APPEND_MOD_NAMES = make("appearance.append_mod_names", i -> i.advanced.tooltips.appendModNames, (i, v) -> i.advanced.tooltips.appendModNames = v) diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java index 66daf5c3f..3fa196f1e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java @@ -26,6 +26,8 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.RoughlyEnoughItemsCoreClient; import me.shedaniel.rei.api.client.ClientHelper; +import me.shedaniel.rei.api.client.config.ConfigManager; +import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.config.DisplayPanelLocation; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.gui.widgets.Widgets; @@ -50,7 +52,8 @@ public class ImportantWarningsWidget extends WidgetWithBounds { private static boolean dirty = false; private boolean visible; private final Rectangle bounds; - private final Rectangle buttonBounds = new Rectangle(); + private final Rectangle okayButtonBounds = new Rectangle(); + private final Rectangle doNotShowButtonBounds = new Rectangle(); private List texts; public ImportantWarningsWidget() { @@ -66,7 +69,7 @@ public ImportantWarningsWidget() { dirty = dirty && !ClientHelper.getInstance().canUseMovePackets(); } - this.visible = dirty; + this.visible = dirty && ConfigObject.getInstance().doesPartialRecipesWarning(); this.texts = List.of( Component.translatable("text.rei.recipes.not.full.title").withStyle(ChatFormatting.RED), Component.translatable("text.rei.recipes.not.full.desc", Component.translatable("text.rei.recipes.not.full.desc.command").withStyle(ChatFormatting.AQUA, ChatFormatting.UNDERLINE)).withStyle(ChatFormatting.GRAY) @@ -102,23 +105,46 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { y += Minecraft.getInstance().font.wordWrapHeight(text, bounds.width * 2) / 2 + 5; graphics.pose().popPose(); } - + + MutableComponent doNotShowText = Component.translatable("text.rei.recipes.not.full.button.do_not_show_again"). + withStyle(ChatFormatting.RED); MutableComponent okayText = Component.translatable("text.rei.recipes.not.full.button.okay"); + int doNotShowTextWidth = Minecraft.getInstance().font.width(doNotShowText); + int okayTextWidth = Minecraft.getInstance().font.width(okayText); + int boundsMaxY = bounds.getMaxY(); + graphics.pose().pushPose(); - graphics.pose().translate(bounds.x + bounds.width / 2 - Minecraft.getInstance().font.width(okayText) * 0.75 / 2, bounds.getMaxY() - 9, 0); + graphics.pose().translate(bounds.x, boundsMaxY - 9, 0); graphics.pose().scale(0.75f, 0.75f, 1); - this.buttonBounds.setBounds(bounds.x, bounds.getMaxY() - 20, bounds.width, 20); - graphics.drawString(Minecraft.getInstance().font, okayText, 0, 0, - buttonBounds.contains(mouseX, mouseY) ? 0xfffff8de : 0xAAFFFFFF); + + int textHeight = 10; + int buttonSpacingGap = 6; + int doNotShowButtonAlignCenter = (int) (bounds.x + bounds.width / 2.0 - Minecraft.getInstance().font.width(doNotShowText) * 0.75 / 2); + int okayButtonAlignCenter = (int) (bounds.x + bounds.width / 2.0 - Minecraft.getInstance().font.width(okayText) * 0.75 / 2); + + this.doNotShowButtonBounds.setBounds(bounds.x, boundsMaxY - (textHeight * 2), + bounds.getMaxX(), textHeight); + this.okayButtonBounds.setBounds(bounds.x, boundsMaxY - textHeight + buttonSpacingGap, + bounds.getMaxX(), textHeight - buttonSpacingGap); + + graphics.drawString(Minecraft.getInstance().font, doNotShowText, + doNotShowButtonAlignCenter, -textHeight, + doNotShowButtonBounds.contains(mouseX, mouseY) ? 0xfffff8de : 0xAAFFFFFF); + graphics.drawString(Minecraft.getInstance().font, okayText, + okayButtonAlignCenter, buttonSpacingGap, + okayButtonBounds.contains(mouseX, mouseY) ? 0xfffff8de : 0xAAFFFFFF); graphics.pose().popPose(); graphics.pose().popPose(); } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (this.visible && button == 0 && buttonBounds.contains(mouseX, mouseY)) { + if ((this.visible && button == 0) && (okayButtonBounds.contains(mouseX, mouseY) || doNotShowButtonBounds.contains(mouseX, mouseY))) { dirty = false; this.visible = false; + if (doNotShowButtonBounds.contains(mouseX, mouseY)) { + ConfigObject.getInstance().setDoesPartialRecipesWarning(false); + } Widgets.produceClickSound(); return true; } diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index d6c807650..5ceae6663 100755 --- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -24,6 +24,7 @@ "text.rei.recipes.not.full.title": "Partial Recipes Data Warning", "text.rei.recipes.not.full.desc": "REI does not have access to all recipes data!\nHere's what you can do:\n• If you are on a vanilla server and have operator permissions, running %s will unlock some recipes.\n• If you are on a modded server, ask the server owner to install REI on the server.", "text.rei.recipes.not.full.desc.command": "/recipe give @p *", + "text.rei.recipes.not.full.button.do_not_show_again": "Do not show again", "text.rei.recipes.not.full.button.okay": "Okay, I understand!", "text.rei.config.menu.dark_theme": "Dark Theme", "text.rei.config.menu.reduced_motion": "Reduced Motion", @@ -280,6 +281,8 @@ "config.rei.options.appearance.append_favorites_hint": "Append Favorites Hint", "config.rei.options.appearance.append_favorites_hint.desc": "Shows a hint on how to favorite an entry, or a recipe.", "config.rei.options.groups.appearance.advanced": "Advanced", + "config.rei.options.appearance.partial_recipes_warning": "Partial Recipes Warning", + "config.rei.options.appearance.partial_recipes_warning.desc": "Whether to show partial recipes warning or not.", "config.rei.options.appearance.rainbow": "Rainbow o(〒﹏〒)o", "config.rei.options.groups.input.keybinds": "Keybinds", "config.rei.options.input.recipe": "View Recipes", diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json index 620a65f86..0f367d5cb 100644 --- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json +++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json @@ -274,6 +274,8 @@ "config.rei.options.appearance.append_favorites_hint": "附加收藏夹提示:", "config.rei.options.appearance.append_favorites_hint.desc": "将在提示框中添加将项目或配方添加至收藏夹的提示。", "config.rei.options.groups.appearance.advanced": "高级", + "config.rei.options.appearance.partial_recipes_warning": "缺少配方警告", + "config.rei.options.appearance.partial_recipes_warning.desc": "决定是否显示缺少配方警告。", "config.rei.options.appearance.rainbow": "彩虹 o(〒﹏〒)o", "config.rei.options.groups.input.keybinds": "按键绑定", "config.rei.options.input.recipe": "查看食谱",