diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-07-28 01:39:41 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-08-26 10:52:28 +0900 |
| commit | 9954713e457a5a5d80025432961b56ab0003bbb0 (patch) | |
| tree | d26b3a09f824e58edd2ad7df39e6c4f48fcc6bb9 /runtime/src/main/java/me | |
| parent | c85b3d49f6d88e7e92b06bacca1ce93db7b75fd0 (diff) | |
| download | RoughlyEnoughItems-9954713e457a5a5d80025432961b56ab0003bbb0.tar.gz RoughlyEnoughItems-9954713e457a5a5d80025432961b56ab0003bbb0.tar.bz2 RoughlyEnoughItems-9954713e457a5a5d80025432961b56ab0003bbb0.zip | |
More work on config module
Diffstat (limited to 'runtime/src/main/java/me')
6 files changed, 0 insertions, 919 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java deleted file mode 100644 index 45ab4ef4e..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.config.entries; - -import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; -import me.shedaniel.rei.RoughlyEnoughItemsCore; -import me.shedaniel.rei.RoughlyEnoughItemsCoreClient; -import me.shedaniel.rei.api.client.search.SearchProvider; -import me.shedaniel.rei.api.common.plugins.PluginManager; -import me.shedaniel.rei.impl.client.gui.screen.ConfigReloadingScreen; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; -import net.minecraft.client.gui.components.AbstractWidget; -import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.narration.NarratableEntry; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.util.Unit; -import org.jetbrains.annotations.ApiStatus; - -import java.util.List; -import java.util.Optional; - -@ApiStatus.Internal -public class ReloadPluginsEntry extends AbstractConfigListEntry<Unit> { - private int width; - private AbstractWidget reloadPluginsButton = new Button(0, 0, 0, 20, NarratorChatListener.NO_TITLE, button -> { - RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.clear(); - RoughlyEnoughItemsCoreClient.reloadPlugins(null, null); - }) { - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - if (PluginManager.areAnyReloading()) { - Screen screen = Minecraft.getInstance().screen; - Minecraft.getInstance().setScreen(new ConfigReloadingScreen(new TranslatableComponent("text.rei.config.is.reloading"), PluginManager::areAnyReloading, () -> Minecraft.getInstance().setScreen(screen))); - } else { - super.render(matrices, mouseX, mouseY, delta); - } - } - }; - private AbstractWidget reloadSearchButton = new Button(0, 0, 0, 20, NarratorChatListener.NO_TITLE, button -> { - SearchProvider.getInstance().clearCache(); - }); - private List<AbstractWidget> children = ImmutableList.of(reloadPluginsButton, reloadSearchButton); - - public ReloadPluginsEntry(int width) { - super(NarratorChatListener.NO_TITLE, false); - this.width = width; - reloadPluginsButton.setMessage(new TranslatableComponent("text.rei.reload_config")); - reloadSearchButton.setMessage(new TranslatableComponent("text.rei.reload_search")); - } - - @Override - public Unit getValue() { - return Unit.INSTANCE; - } - - @Override - public Optional<Unit> getDefaultValue() { - return Optional.of(Unit.INSTANCE); - } - - @Override - public void save() { - - } - - @Override - public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { - super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isSelected, delta); - Window window = Minecraft.getInstance().getWindow(); - this.reloadPluginsButton.active = this.isEditable(); - this.reloadPluginsButton.y = y; - this.reloadPluginsButton.setWidth(width / 2 - 2); - this.reloadPluginsButton.x = x + entryWidth / 2 - width / 2; - this.reloadPluginsButton.render(matrices, mouseX, mouseY, delta); - this.reloadSearchButton.active = this.isEditable() && SearchProvider.getInstance().hasCache(); - this.reloadSearchButton.y = y; - this.reloadSearchButton.setWidth(width / 2 - 2); - this.reloadSearchButton.x = x + entryWidth / 2 + 2; - this.reloadSearchButton.render(matrices, mouseX, mouseY, delta); - } - - @Override - public List<? extends GuiEventListener> children() { - return children; - } - - @Override - public List<? extends NarratableEntry> narratables() { - return children; - } -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/InternalTextures.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/InternalTextures.java deleted file mode 100644 index 4823008b6..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/InternalTextures.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.gui; - -import net.minecraft.resources.ResourceLocation; - -public class InternalTextures { - public static final ResourceLocation ARROW_LEFT_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_left.png"); - public static final ResourceLocation ARROW_RIGHT_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_right.png"); - public static final ResourceLocation ARROW_LEFT_SMALL_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_left_small.png"); - public static final ResourceLocation ARROW_RIGHT_SMALL_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_right_small.png"); - public static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); - public static final ResourceLocation CHEST_GUI_TEXTURE_DARK = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer_dark.png"); -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java deleted file mode 100644 index 9a576014c..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.gui.credits; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.clothconfig2.gui.widget.DynamicSmoothScrollingEntryListWidget; -import me.shedaniel.rei.impl.client.gui.text.TextTransformations; -import net.minecraft.ChatFormatting; -import net.minecraft.Util; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.client.gui.narration.NarratableEntry; -import net.minecraft.client.resources.sounds.SimpleSoundInstance; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.util.FormattedCharSequence; -import org.jetbrains.annotations.ApiStatus; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.List; - -@ApiStatus.Internal -public class CreditsEntryListWidget extends DynamicSmoothScrollingEntryListWidget<CreditsEntryListWidget.CreditsItem> { - private boolean inFocus; - - public CreditsEntryListWidget(Minecraft client, int width, int height, int startY, int endY) { - super(client, width, height, startY, endY, GuiComponent.BACKGROUND_LOCATION); - } - - @Override - public boolean changeFocus(boolean boolean_1) { - if (!this.inFocus && this.getItemCount() == 0) { - return false; - } else { - this.inFocus = !this.inFocus; - if (this.inFocus && this.getFocused() == null && this.getItemCount() > 0) { - this.moveSelection(1); - } else if (this.inFocus && this.getFocused() != null) { - this.moveSelection(0); - } - - return this.inFocus; - } - } - - public void creditsClearEntries() { - clearItems(); - } - - private CreditsItem rei_getEntry(int index) { - return this.children().get(index); - } - - public void creditsAddEntry(CreditsItem entry) { - addItem(entry); - } - - @Override - public int getItemWidth() { - return width - 80; - } - - @Override - protected int getScrollbarPosition() { - return width - 40; - } - - public static abstract class CreditsItem extends DynamicSmoothScrollingEntryListWidget.Entry<CreditsItem> { - @Override - public List<? extends NarratableEntry> narratables() { - return Collections.emptyList(); - } - } - - public static class TextCreditsItem extends CreditsItem { - private Component text; - - public TextCreditsItem(Component text) { - this.text = text; - } - - @Override - public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { - Minecraft.getInstance().font.drawShadow(matrices, text.getVisualOrderText(), x + 5, y + 5, -1); - } - - @Override - public int getItemHeight() { - return 12; - } - - @Override - public boolean changeFocus(boolean boolean_1) { - return false; - } - } - - public static class TranslationCreditsItem extends CreditsItem { - private Component language; - private List<FormattedCharSequence> translators; - private int maxWidth; - - public TranslationCreditsItem(Component language, Component translators, int width, int maxWidth) { - this.language = language; - this.translators = Minecraft.getInstance().font.split(translators, width); - this.maxWidth = maxWidth; - } - - @Override - public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { - Minecraft.getInstance().font.drawShadow(matrices, language.getVisualOrderText(), x + 5, y + 5, -1); - int yy = y + 5; - for (FormattedCharSequence translator : translators) { - Minecraft.getInstance().font.drawShadow(matrices, translator, x + 5 + maxWidth, yy, -1); - yy += 12; - } - } - - @Override - public int getItemHeight() { - return 12 * translators.size(); - } - - @Override - public boolean changeFocus(boolean boolean_1) { - return false; - } - } - - public static class LinkItem extends CreditsItem { - private Component text; - private List<FormattedCharSequence> textSplit; - private String link; - private boolean contains; - private boolean rainbow; - - public LinkItem(Component text, String link, int width, boolean rainbow) { - this.text = text; - this.textSplit = Minecraft.getInstance().font.split(text, width); - this.link = link; - this.rainbow = rainbow; - } - - @Override - public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { - contains = mouseX >= x && mouseX <= x + entryWidth && mouseY >= y && mouseY <= y + entryHeight; - if (contains) { - Minecraft.getInstance().screen.renderTooltip(matrices, new TextComponent("Click to open link."), mouseX, mouseY); - int yy = y; - for (FormattedCharSequence textSp : textSplit) { - FormattedCharSequence underlined = characterVisitor -> { - return textSp.accept((charIndex, style, codePoint) -> characterVisitor.accept(charIndex, style.applyFormat(ChatFormatting.UNDERLINE), codePoint)); - }; - if (rainbow) underlined = TextTransformations.applyRainbow(underlined, x + 5, yy); - Minecraft.getInstance().font.drawShadow(matrices, underlined, x + 5, yy, 0xff1fc3ff); - yy += 12; - } - } else { - int yy = y; - for (FormattedCharSequence textSp : textSplit) { - if (rainbow) textSp = TextTransformations.applyRainbow(textSp, x + 5, yy); - Minecraft.getInstance().font.drawShadow(matrices, textSp, x + 5, yy, 0xff1fc3ff); - yy += 12; - } - } - } - - @Override - public int getItemHeight() { - return 12 * textSplit.size(); - } - - @Override - public boolean changeFocus(boolean boolean_1) { - return false; - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (contains && button == 0) { - Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - try { - Util.getPlatform().openUri(new URI(link)); - return true; - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - return false; - } - } -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java deleted file mode 100644 index 8ca4fe7ef..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.gui.credits; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.PoseStack; -import dev.architectury.platform.Platform; -import me.shedaniel.rei.api.common.util.ImmutableTextComponent; -import me.shedaniel.rei.impl.client.gui.credits.CreditsEntryListWidget.TextCreditsItem; -import me.shedaniel.rei.impl.client.gui.credits.CreditsEntryListWidget.TranslationCreditsItem; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; -import net.minecraft.client.gui.components.AbstractButton; -import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.util.Tuple; -import org.jetbrains.annotations.ApiStatus; - -import java.lang.reflect.InvocationTargetException; -import java.util.List; -import java.util.Locale; -import java.util.stream.Collectors; - -@ApiStatus.Internal -public class CreditsScreen extends Screen { - private Screen parent; - private AbstractButton buttonDone; - private CreditsEntryListWidget entryListWidget; - - public CreditsScreen(Screen parent) { - super(new TextComponent("")); - this.parent = parent; - } - - @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - if (keyCode == 256 && this.shouldCloseOnEsc()) { - openPrevious(); - return true; - } - return super.keyPressed(keyCode, scanCode, modifiers); - } - - public static class TranslatorEntry { - private final String name; - private final boolean proofreader; - - public TranslatorEntry(String name) { - this(name, false); - } - - public TranslatorEntry(String name, boolean proofreader) { - this.name = name; - this.proofreader = proofreader; - } - - public String getName() { - return name; - } - } - - @Override - public void init() { - addWidget(entryListWidget = new CreditsEntryListWidget(minecraft, width, height, 32, height - 32)); - entryListWidget.creditsClearEntries(); - List<Tuple<String, List<TranslatorEntry>>> translators = Lists.newArrayList(); - Exception[] exception = {null}; - fillTranslators(exception, translators); - List<Tuple<String, List<TranslatorEntry>>> translatorsMapped = translators.stream().map(pair -> { - return new Tuple<>( - " " + (I18n.exists("language.roughlyenoughitems." + pair.getA().toLowerCase(Locale.ROOT).replace(' ', '_')) ? I18n.get("language.roughlyenoughitems." + pair.getA().toLowerCase(Locale.ROOT).replace(' ', '_')) : pair.getA()), - pair.getB() - ); - }).collect(Collectors.toList()); - int i = width - 80 - 6; - for (String line : String.format("§lRoughly Enough Items (v%s)\n§7Originally a fork for Almost Enough Items.\n\n§lLanguage Translation\n%s\n\n§lLicense\n§7Roughly Enough Items is licensed under MIT.", Platform.getMod("roughlyenoughitems").getVersion(), "%translators%").split("\n")) - if (line.equalsIgnoreCase("%translators%")) { - if (exception[0] != null) { - entryListWidget.creditsAddEntry(new TextCreditsItem(new ImmutableTextComponent("Failed to get translators: " + exception[0].toString()))); - for (StackTraceElement traceElement : exception[0].getStackTrace()) - entryListWidget.creditsAddEntry(new TextCreditsItem(new ImmutableTextComponent(" at " + traceElement))); - } else { - int maxWidth = translatorsMapped.stream().mapToInt(pair -> font.width(pair.getA())).max().orElse(0) + 5; - for (Tuple<String, List<TranslatorEntry>> pair : translatorsMapped) { - MutableComponent text = new TextComponent(""); - boolean isFirst = true; - for (TranslatorEntry entry : pair.getB()) { - if (!isFirst) { - text = text.append(new TextComponent(", ")); - } - isFirst = false; - MutableComponent component = new TextComponent(entry.getName()); - if (entry.proofreader) - component = component.withStyle(ChatFormatting.GOLD); - text = text.append(component); - } - entryListWidget.creditsAddEntry(new TranslationCreditsItem(new TranslatableComponent(pair.getA()), text, i - maxWidth - 10, maxWidth)); - } - } - } else entryListWidget.creditsAddEntry(new TextCreditsItem(new ImmutableTextComponent(line))); - entryListWidget.creditsAddEntry(new TextCreditsItem(NarratorChatListener.NO_TITLE)); - entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(new ImmutableTextComponent("Visit the project at GitHub."), "https://www.github.com/shedaniel/RoughlyEnoughItems", entryListWidget.getItemWidth(), false)); - entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(new ImmutableTextComponent("Visit the project page at CurseForge."), "https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items", entryListWidget.getItemWidth(), false)); - entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(new ImmutableTextComponent("Support the project via Patreon!"), "https://patreon.com/shedaniel", entryListWidget.getItemWidth(), true)); - entryListWidget.creditsAddEntry(new TextCreditsItem(NarratorChatListener.NO_TITLE)); - addRenderableWidget(buttonDone = new Button(width / 2 - 100, height - 26, 200, 20, new TranslatableComponent("gui.done"), button -> openPrevious())); - } - - private static void fillTranslators(Exception[] exception, List<Tuple<String, List<TranslatorEntry>>> translators) { - try { - Class.forName("me.shedaniel.rei.impl.client.gui.credits.%s.CreditsScreenImpl".formatted(Platform.isForge() ? "forge" : "fabric")) - .getDeclaredMethod("fillTranslators", Exception[].class, List.class) - .invoke(null, exception, translators); - } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) { - throw new RuntimeException(e); - } - } - - private void openPrevious() { - Minecraft.getInstance().setScreen(parent); - } - - @Override - public boolean mouseScrolled(double mouseX, double mouseY, double amount) { - if (entryListWidget.mouseScrolled(mouseX, mouseY, amount)) - return true; - return super.mouseScrolled(mouseX, mouseY, amount); - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - this.renderDirtBackground(0); - this.entryListWidget.render(matrices, mouseX, mouseY, delta); - drawCenteredString(matrices, this.font, I18n.get("text.rei.credits"), this.width / 2, 16, 16777215); - super.render(matrices, mouseX, mouseY, delta); - } - -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java deleted file mode 100644 index 3d3895880..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.gui.screen; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.Util; -import net.minecraft.client.gui.chat.NarratorChatListener; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.Component; -import org.jetbrains.annotations.ApiStatus; - -import java.util.function.BooleanSupplier; - -@ApiStatus.Internal -public class ConfigReloadingScreen extends Screen { - private final Component title; - private final BooleanSupplier predicate; - private Runnable parent; - - public ConfigReloadingScreen(Component title, BooleanSupplier predicate, Runnable parent) { - super(NarratorChatListener.NO_TITLE); - this.title = title; - this.predicate = predicate; - this.parent = parent; - } - - @Override - public boolean shouldCloseOnEsc() { - return false; - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - this.renderDirtBackground(0); - if (!predicate.getAsBoolean()) { - parent.run(); - return; - } - drawCenteredString(matrices, this.font, title, this.width / 2, this.height / 2 - 50, 16777215); - String text; - switch ((int) (Util.getMillis() / 300L % 4L)) { - case 0: - default: - text = "O o o"; - break; - case 1: - case 3: - text = "o O o"; - break; - case 2: - text = "o o O"; - } - drawCenteredString(matrices, this.font, text, this.width / 2, this.height / 2 - 41, 8421504); - super.render(matrices, mouseX, mouseY, delta); - } -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java deleted file mode 100644 index 8dc417dd5..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.gui.screen; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import dev.architectury.platform.Platform; -import it.unimi.dsi.fastutil.booleans.BooleanConsumer; -import me.shedaniel.clothconfig2.api.ScissorsHandler; -import me.shedaniel.clothconfig2.api.animator.NumberAnimator; -import me.shedaniel.clothconfig2.api.animator.ValueAnimator; -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.RoughlyEnoughItemsCore; -import me.shedaniel.rei.RoughlyEnoughItemsCoreClient; -import me.shedaniel.rei.api.client.ClientHelper; -import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.config.ConfigObject; -import me.shedaniel.rei.api.client.gui.config.DisplayScreenType; -import me.shedaniel.rei.api.client.gui.widgets.Button; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -import me.shedaniel.rei.api.client.gui.widgets.Widgets; -import me.shedaniel.rei.api.common.util.ImmutableTextComponent; -import me.shedaniel.rei.impl.ClientInternals; -import me.shedaniel.rei.impl.client.config.ConfigManagerInternal; -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; -import net.minecraft.util.Mth; -import org.jetbrains.annotations.ApiStatus; - -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -@ApiStatus.Internal -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; - private boolean isSet; - private boolean original; - private double frame = 0; - private double target = 0; - private BooleanConsumer callback; - private Button button; - private Screen parent; - private Widget slider; - private boolean showTips; - public NumberAnimator<Double> scroll = ValueAnimator.ofDouble(); - private List<String> allModsUsingJEI = null; - private boolean jeiEnabled = false; - - public UncertainDisplayViewingScreen(Screen parent, DisplayScreenType type, boolean showTips, BooleanConsumer callback) { - super(ImmutableTextComponent.EMPTY); - this.widgets = Lists.newArrayList(); - if (type == DisplayScreenType.UNSET) { - this.isSet = false; - this.original = true; - } else { - this.isSet = true; |
