diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-07-08 15:30:37 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-07-08 15:30:37 +0800 |
| commit | 1189bcf3a46777239462da0dc45aa088697fec40 (patch) | |
| tree | 0987169de6fda56f3e90e55d285daceb0bc3f005 /src/main | |
| parent | 17150bedcdf80944a64e165976cf2491d409b1c0 (diff) | |
| download | RoughlyEnoughItems-1189bcf3a46777239462da0dc45aa088697fec40.tar.gz RoughlyEnoughItems-1189bcf3a46777239462da0dc45aa088697fec40.tar.bz2 RoughlyEnoughItems-1189bcf3a46777239462da0dc45aa088697fec40.zip | |
Optimise images and add warning screen for optifine.
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main')
14 files changed, 48 insertions, 0 deletions
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<ConfigObjectImpl> provider = (ConfigScreenProvider<ConfigObjectImpl>) 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 Binary files differindex 1362ea3f5..6d31efc09 100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/button.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/button.png diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png Binary files differindex a2727963e..9e53c5d0e 100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/display.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/display.png Binary files differindex b730c61e7..a5ca91a18 100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/display.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/display.png diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png Binary files differindex 950fb6afb..1a1739fa0 100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png Binary files differindex 3b00721f5..b94ae6040 100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png Binary files differindex 283666cda..773636e65 100755..100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png Binary files differindex 2c3ef6597..a20a0938f 100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png Binary files differindex 1563615f6..e7d01c952 100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png diff --git a/src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png b/src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png Binary files differindex cbb2c026e..1c369b49c 100644 --- a/src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png +++ b/src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png diff --git a/src/main/resources/icon.png b/src/main/resources/icon.png Binary files differindex bf5ad0f2c..b7a48aef0 100644 --- a/src/main/resources/icon.png +++ b/src/main/resources/icon.png |
