From 1189bcf3a46777239462da0dc45aa088697fec40 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 8 Jul 2020 15:30:37 +0800 Subject: Optimise images and add warning screen for optifine. Signed-off-by: shedaniel --- gradle.properties | 2 +- .../java/me/shedaniel/rei/api/ConfigManager.java | 3 ++ .../me/shedaniel/rei/api/TextRepresentable.java | 3 ++ .../me/shedaniel/rei/impl/ConfigManagerImpl.java | 40 +++++++++++++++++++++ .../assets/roughlyenoughitems/lang/en_us.json | 2 ++ .../roughlyenoughitems/textures/gui/button.png | Bin 25007 -> 7903 bytes .../textures/gui/button_dark.png | Bin 20499 -> 5111 bytes .../roughlyenoughitems/textures/gui/display.png | Bin 11200 -> 2124 bytes .../textures/gui/display_dark.png | Bin 9896 -> 2149 bytes .../roughlyenoughitems/textures/gui/kirb.png | Bin 5756 -> 630 bytes .../textures/gui/recipecontainer.png | Bin 8469 -> 2014 bytes .../textures/gui/recipecontainer_dark.png | Bin 7629 -> 2516 bytes .../roughlyenoughitems/textures/gui/screenshot.png | Bin 26418 -> 25515 bytes .../roughlyenoughitems/textures/gui/toasts.png | Bin 593 -> 256 bytes src/main/resources/icon.png | Bin 47308 -> 27270 bytes 15 files changed, 49 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png diff --git a/gradle.properties b/gradle.properties index fdb6dc7c8..3f397f6b4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx3G -mod_version=4.7.0 +mod_version=4.7.1 supported_version=1.16.x minecraft_version=1.16.1 yarn_version=1.16.1+build.4+legacy.20w09a+build.8 diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index b3da456da..f85d528e5 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -24,9 +24,12 @@ package me.shedaniel.rei.api; import me.shedaniel.rei.RoughlyEnoughItemsCore; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; +@Environment(EnvType.CLIENT) public interface ConfigManager { /** diff --git a/src/main/java/me/shedaniel/rei/api/TextRepresentable.java b/src/main/java/me/shedaniel/rei/api/TextRepresentable.java index 22b46f037..782ed3f40 100644 --- a/src/main/java/me/shedaniel/rei/api/TextRepresentable.java +++ b/src/main/java/me/shedaniel/rei/api/TextRepresentable.java @@ -25,11 +25,14 @@ package me.shedaniel.rei.api; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.widgets.Tooltip; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import org.jetbrains.annotations.NotNull; +@Environment(EnvType.CLIENT) public interface TextRepresentable { @NotNull default Text asFormattedText() { diff --git a/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java b/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java index e400f0392..6ffe07b06 100644 --- a/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java @@ -49,11 +49,17 @@ import me.shedaniel.rei.gui.config.entry.NoFilteringEntry; import me.shedaniel.rei.gui.config.entry.RecipeScreenTypeEntry; import me.shedaniel.rei.gui.config.entry.ReloadPluginsEntry; import me.shedaniel.rei.gui.credits.CreditsScreen; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ScreenTexts; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.InputUtil; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.math.MathHelper; import org.jetbrains.annotations.ApiStatus; @@ -66,6 +72,7 @@ import static me.sargunvohra.mcmods.autoconfig1u.util.Utils.getUnsafely; import static me.sargunvohra.mcmods.autoconfig1u.util.Utils.setUnsafely; @ApiStatus.Internal +@Environment(EnvType.CLIENT) public class ConfigManagerImpl implements ConfigManager { private boolean craftableOnly; @@ -150,6 +157,9 @@ public class ConfigManagerImpl implements ConfigManager { @Override public Screen getConfigScreen(Screen parent) { try { + if (FabricLoader.getInstance().isModLoaded("optifabric")) { + return new ConfigErrorScreen(parent, new TranslatableText("text.rei.config.optifine.title"), new TranslatableText("text.rei.config.optifine.description")); + } ConfigScreenProvider provider = (ConfigScreenProvider) AutoConfig.getConfigScreen(ConfigObjectImpl.class, parent); provider.setI13nFunction(manager -> "config.roughlyenoughitems"); provider.setOptionFunction((baseI13n, field) -> field.isAnnotationPresent(ConfigObjectImpl.DontApplyFieldName.class) ? baseI13n : String.format("%s.%s", baseI13n, field.getName())); @@ -178,4 +188,34 @@ public class ConfigManagerImpl implements ConfigManager { return null; } + public static class ConfigErrorScreen extends Screen { + private final Text message; + private final Screen parent; + + public ConfigErrorScreen(Screen parent, Text title, Text message) { + super(title); + this.parent = parent; + this.message = message; + } + + @Override + protected void init() { + super.init(); + this.addButton(new ButtonWidget(this.width / 2 - 100, 140, 200, 20, ScreenTexts.CANCEL, button -> this.client.openScreen(parent))); + } + + @Override + public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { + this.renderBackground(matrices); + this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 90, 16777215); + this.drawCenteredText(matrices, this.textRenderer, this.message, this.width / 2, 110, 16777215); + super.render(matrices, mouseX, mouseY, delta); + } + + @Override + public boolean shouldCloseOnEsc() { + return false; + } + } + } diff --git a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index 5b8b02faf..c58f37937 100755 --- a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -36,6 +36,8 @@ "text.rei.composting.page": "Page %d", "text.rei.config": "Config", "text.rei.config_tooltip": "Open Config Screen\n§7Shift-Click to toggle cheat mode", + "text.rei.config.optifine.title": "Failed to open REI config screen", + "text.rei.config.optifine.description": "The configuration screen is incompatible with OptiFine / OptiFabric.", "text.rei.cheat_items": "Gave [{item_name}§f] x{item_count} to {player_name}.", "text.rei.failed_cheat_items": "§cFailed to give items.", "ordering.rei.ascending": "Ascending", diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/button.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/button.png index 1362ea3f5..6d31efc09 100644 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/button.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/button.png differ diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png index a2727963e..9e53c5d0e 100644 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png differ diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/display.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/display.png index b730c61e7..a5ca91a18 100644 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/display.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/display.png differ diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png index 950fb6afb..1a1739fa0 100644 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png differ diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png index 3b00721f5..b94ae6040 100644 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png differ diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png old mode 100755 new mode 100644 index 283666cda..773636e65 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png differ diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png index 2c3ef6597..a20a0938f 100644 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png differ diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png index 1563615f6..e7d01c952 100644 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png differ diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png index cbb2c026e..1c369b49c 100644 Binary files a/src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png and b/src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png differ diff --git a/src/main/resources/icon.png b/src/main/resources/icon.png index bf5ad0f2c..b7a48aef0 100644 Binary files a/src/main/resources/icon.png and b/src/main/resources/icon.png differ -- cgit