diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-12-11 20:24:47 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-12-11 20:24:47 +0800 |
| commit | 90b8a8181eb7e642fb88832f8bd8baa3acdcf804 (patch) | |
| tree | 85774b5a26be6a8303f99c5316aee320a737ffc8 /RoughlyEnoughItems-runtime/src/main/java/me | |
| parent | 14edd7e3f9e3716ff60e9d918760049c1313a485 (diff) | |
| download | RoughlyEnoughItems-90b8a8181eb7e642fb88832f8bd8baa3acdcf804.tar.gz RoughlyEnoughItems-90b8a8181eb7e642fb88832f8bd8baa3acdcf804.tar.bz2 RoughlyEnoughItems-90b8a8181eb7e642fb88832f8bd8baa3acdcf804.zip | |
Remove deprecated classes
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'RoughlyEnoughItems-runtime/src/main/java/me')
23 files changed, 22 insertions, 1119 deletions
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 60ff88f70..fb2728932 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -151,7 +151,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { @Override public me.shedaniel.rei.api.widgets.Slot createSlot(Point point) { - return EntryWidget.create(point); + return new EntryWidget(point); } @Override diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index bcc21caa7..c24164451 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -258,7 +258,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { ClientHelperImpl.getInstance().openRecipeViewingScreen(categoriesMap, categories.get(currentCategoryIndex).getIdentifier(), ingredientStackToNotice, resultStackToNotice); }).tooltipLine(I18n.get("text.rei.previous_category"))); widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 7), new TextComponent(selectedCategory.getCategoryName()), clickableLabelWidget -> { - ClientHelper.getInstance().executeViewAllRecipesKeyBind(); + ClientHelper.getInstance().openView(ClientHelper.ViewSearchBuilder.builder().addAllCategories().fillPreferredOpenedCategory()); }).tooltipLine(I18n.get("text.rei.view_all_categories"))); widgets.add(categoryNext = Widgets.createButton(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12), new TranslatableComponent("text.rei.right_arrow")) .onClick(button -> { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java index e8c2e615c..e72c921e1 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java @@ -29,10 +29,8 @@ import me.shedaniel.clothconfig2.api.ScissorsScreen; import me.shedaniel.math.Rectangle; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.DeathScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.TitleScreen; -import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; import org.jetbrains.annotations.Nullable; import java.util.function.BooleanSupplier; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index 36a18ac78..9eecc4616 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -241,7 +241,7 @@ public class VillagerRecipeViewingScreen extends Screen implements RecipeScreen .enabled(categories.size() > tabsPerPage)); this.widgets.add(Widgets.createClickableLabel(new Point(bounds.x + 4 + scrollListBounds.width / 2, bounds.y + 6), new TextComponent(categories.get(selectedCategoryIndex).getCategoryName()), label -> { - ClientHelper.getInstance().executeViewAllRecipesKeyBind(); + ClientHelper.getInstance().openView(ClientHelper.ViewSearchBuilder.builder().addAllCategories().fillPreferredOpenedCategory()); }).tooltipLine(I18n.get("text.rei.view_all_categories")).noShadow().color(0xFF404040, 0xFFBBBBBB).hoveredColor(0xFF0041FF, 0xFFFFBD4D)); this.children.addAll(buttonList); diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java index 31e2a3948..1d3d37014 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java @@ -309,11 +309,11 @@ public class FilteringScreen extends Screen { public void updateSearch(String searchTerm) { lastSearchArguments = SearchArgument.processSearchTerm(searchTerm); Set<EntryStack> list = Sets.newLinkedHashSet(); - for (EntryStack stack : EntryRegistry.getInstance().getStacksList()) { + EntryRegistry.getInstance().getEntryStacks().forEach(stack -> { if (canLastSearchTermsBeAppliedTo(stack)) { list.add(stack.copy().setting(EntryStack.Settings.CHECK_AMOUNT, EntryStack.Settings.FALSE).setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE)); } - } + }); entryStacks = Lists.newArrayList(list); updateEntriesPosition(); diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/modules/MenuEntry.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/modules/MenuEntry.java index 455dae30b..7a1101a9d 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/modules/MenuEntry.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/modules/MenuEntry.java @@ -29,6 +29,7 @@ import org.jetbrains.annotations.ApiStatus; @ApiStatus.Experimental @ApiStatus.Internal public abstract class MenuEntry extends Widget { + @ApiStatus.Internal @Deprecated Menu parent = null; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java index 71f6f8dfe..05a450867 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java @@ -33,10 +33,8 @@ import me.shedaniel.rei.api.favorites.FavoriteEntryType; import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.api.widgets.Panel; import me.shedaniel.rei.api.widgets.Tooltip; -import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.RecipeViewingScreen; import me.shedaniel.rei.gui.VillagerRecipeViewingScreen; -import me.shedaniel.rei.gui.widget.FavoritesListWidget; import me.shedaniel.rei.impl.ClientHelperImpl; import me.shedaniel.rei.impl.RenderingEntry; import me.shedaniel.rei.plugin.autocrafting.DefaultCategoryHandler; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java deleted file mode 100644 index 48214cda9..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.gui.widget; - -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.api.widgets.Tooltip; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.resources.sounds.SimpleSoundInstance; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.util.Mth; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @see me.shedaniel.rei.api.widgets.Widgets#createButton(me.shedaniel.math.Rectangle, Text) - */ -@Deprecated -@ApiStatus.ScheduledForRemoval -public abstract class ButtonWidget extends WidgetWithBounds { - - protected static final ResourceLocation BUTTON_LOCATION = new ResourceLocation("roughlyenoughitems", "textures/gui/button.png"); - protected static final ResourceLocation BUTTON_LOCATION_DARK = new ResourceLocation("roughlyenoughitems", "textures/gui/button_dark.png"); - public boolean enabled = true; - public boolean focused = false; - private boolean canChangeFocuses = true; - private String text; - private Rectangle bounds; - private Supplier<String> tooltipSupplier; - - protected ButtonWidget(Rectangle rectangle, Component text) { - this.bounds = Objects.requireNonNull(rectangle); - this.text = Objects.requireNonNull(text).getString(); - } - - public static ButtonWidget create(Rectangle point, String text, Consumer<ButtonWidget> onClick) { - return create(point, new TextComponent(text), onClick); - } - - public static ButtonWidget create(Rectangle point, Component text, Consumer<ButtonWidget> onClick) { - ButtonWidget[] widget = {null}; - widget[0] = new ButtonWidget(point, text) { - @Override - public void onPressed() { - onClick.accept(widget[0]); - } - }; - return widget[0]; - } - - public ButtonWidget tooltip(Supplier<String> tooltipSupplier) { - this.tooltipSupplier = tooltipSupplier; - return this; - } - - public ButtonWidget enabled(boolean enabled) { - this.enabled = enabled; - return this; - } - - public ButtonWidget canChangeFocuses(boolean canChangeFocuses) { - this.canChangeFocuses = canChangeFocuses; - return this; - } - - public boolean canChangeFocuses() { - return canChangeFocuses; - } - - @NotNull - public Rectangle getBounds() { - return bounds; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - protected int getTextureId(boolean boolean_1) { - int int_1 = 1; - if (!this.enabled) { - int_1 = 0; - } else if (boolean_1) { - int_1 = 4; // 2 is the old blue highlight, 3 is the 1.15 outline, 4 is the 1.15 online + light hover - } - - return int_1; - } - - protected void renderBackground(PoseStack matrices, int x, int y, int width, int height, int textureOffset) { - minecraft.getTextureManager().bind(REIHelper.getInstance().isDarkThemeEnabled() ? BUTTON_LOCATION_DARK : BUTTON_LOCATION); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(770, 771, 1, 0); - RenderSystem.blendFunc(770, 771); - //Four Corners - blit(matrices, x, y, getBlitOffset(), 0, textureOffset * 80, 4, 4, 512, 256); - blit(matrices, x + width - 4, y, getBlitOffset(), 252, textureOffset * 80, 4, 4, 512, 256); - blit(matrices, x, y + height - 4, getBlitOffset(), 0, textureOffset * 80 + 76, 4, 4, 512, 256); - blit(matrices, x + width - 4, y + height - 4, getBlitOffset(), 252, textureOffset * 80 + 76, 4, 4, 512, 256); - - //Sides - blit(matrices, x + 4, y, getBlitOffset(), 4, textureOffset * 80, Mth.ceil((width - 8) / 2f), 4, 512, 256); - blit(matrices, x + 4, y + height - 4, getBlitOffset(), 4, textureOffset * 80 + 76, Mth.ceil((width - 8) / 2f), 4, 512, 256); - blit(matrices, x + 4 + Mth.ceil((width - 8) / 2f), y + height - 4, getBlitOffset(), 252 - Mth.floor((width - 8) / 2f), textureOffset * 80 + 76, Mth.floor((width - 8) / 2f), 4, 512, 256); - blit(matrices, x + 4 + Mth.ceil((width - 8) / 2f), y, getBlitOffset(), 252 - Mth.floor((width - 8) / 2f), textureOffset * 80, Mth.floor((width - 8) / 2f), 4, 512, 256); - for (int i = y + 4; i < y + height - 4; i += 76) { - blit(matrices, x, i, getBlitOffset(), 0, 4 + textureOffset * 80, Mth.ceil(width / 2f), Mth.clamp(y + height - 4 - i, 0, 76), 512, 256); - blit(matrices, x + Mth.ceil(width / 2f), i, getBlitOffset(), 256 - Mth.floor(width / 2f), 4 + textureOffset * 80, Mth.floor(width / 2f), Mth.clamp(y + height - 4 - i, 0, 76), 512, 256); - } - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height; - renderBackground(matrices, x, y, width, height, this.getTextureId(isHovered(mouseX, mouseY))); - - int color = 14737632; - if (!this.enabled) { - color = 10526880; - } else if (isHovered(mouseX, mouseY)) { - color = 16777120; - } - - this.drawCenteredString(matrices, font, getText(), x + width / 2, y + (height - 8) / 2, color); - - if (getTooltips().isPresent()) - if (!focused && containsMouse(mouseX, mouseY)) - Tooltip.create(Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - else if (focused) - Tooltip.create(new Point(x + width / 2, y + height / 2), Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - } - - public boolean isHovered(int mouseX, int mouseY) { - return isMouseOver(mouseX, mouseY) || focused; - } - - @Override - public boolean changeFocus(boolean boolean_1) { - if (!enabled || !canChangeFocuses) - return false; - this.focused = !this.focused; - return true; - } - - @Override - public List<? extends GuiEventListener> children() { - return Collections.emptyList(); - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (isMouseOver(mouseX, mouseY) && enabled && button == 0) { - minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - onPressed(); - return true; - } - return false; - } - - @Override - public boolean keyPressed(int int_1, int int_2, int int_3) { - if (this.enabled && focused) { - if (int_1 != 257 && int_1 != 32 && int_1 != 335) { - return false; - } else { - minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - this.onPressed(); - return true; - } - } - return false; - } - - public abstract void onPressed(); - - public Optional<String> getTooltips() { - return Optional.ofNullable(tooltipSupplier).map(Supplier::get); - } - -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java deleted file mode 100644 index e8cadf77a..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.gui.widget; - -import me.shedaniel.math.Rectangle; -import org.jetbrains.annotations.ApiStatus; - -/** - * @see me.shedaniel.rei.api.widgets.Widgets#createCategoryBase(me.shedaniel.math.Rectangle) - * @see me.shedaniel.rei.api.widgets.Widgets#createCategoryBase(me.shedaniel.math.Rectangle, int) - */ -@Deprecated -@ApiStatus.ScheduledForRemoval -public class CategoryBaseWidget extends RecipeBaseWidget { - - public CategoryBaseWidget(Rectangle bounds) { - super(bounds); - } - - @Override - protected int getYTextureOffset() { - return 66; - } - - @Override - protected boolean isRendering() { - return true; - } -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java deleted file mode 100644 index 6ec14c747..000000000 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.gui.widget; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Point; -import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.api.widgets.Tooltip; -import me.shedaniel.rei.api.widgets.Widgets; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import org.jetbrains.annotations.ApiStatus; - -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @see Widgets#createClickableLabel(Point, String, Consumer) - */ -@Deprecated -@ApiStatus.ScheduledForRemoval -public abstract class ClickableLabelWidget extends LabelWidget { - - public boolean focused; - private boolean clickable = true; - private int hoveredColor; - - @ApiStatus.Internal - protected ClickableLabelWidget(Point point, Component text) { - super(point, text); - this.hoveredColor = REIHelper.getInstance().isDarkThemeEnabled() ? -1 : 0xFF66FFCC; - } - - public LabelWidget hoveredColor(int hoveredColor) { - this.hoveredColor = hoveredColor; - return this; - } - - public LabelWidget clickable(boolean clickable) { - this.clickable = clickable; - return this; - } - - public boolean isClickable() { - return clickable; - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - int color = getDefaultColor(); - if (isClickable() && isHovered(mouseX, mouseY)) - color = getHoveredColor(); - Point pos = getLocation(); - int width = font.width(getText()); - if (isCentered()) { - if (isHasShadows()) - font.drawShadow(matrices, text.getVisualOrderText(), pos.x - width / 2f, pos.y, color); - else - font.draw(matrices, text.getVisualOrderText(), pos.x - width / 2f, pos.y, color); - } else { - if (isHasShadows()) - font.drawShadow(matrices, text.getVisualOrderText(), pos.x, pos.y, color); - else - font.draw(matrices, text.getVisualOrderText(), pos.x, pos.y, color); - } - drawTooltips(mouseX, mouseY); - } - - @Override - protected void drawTooltips(int mouseX, int mouseY) { - if (isClickable() && getTooltips().isPresent()) - if (!focused && containsMouse(mouseX, mouseY)) - Tooltip.create(Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - else if (focused) - Tooltip.create(getLocation(), Stream.of(getTooltips().get().split("\n")).map(TextComponent::new).collect(Collectors.toList())).queue(); - } - - public int getHoveredColor() { - return hoveredColor; - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (button == 0 && isClickable() && containsMouse(mouseX, mouseY)) { - onLabelClicked(); - return true; - } - return false; - } - - @Override - public boolean keyPressed(int int_1, int int_2, int int_3) { - if (!isClickable() || !focused) - return false; - if (int_1 != 257 && int_1 != 32 && int_1 != 335) - return false; - this.onLabelClicked(); - return true; - } - - @Override - public boolean changeFocus(boolean boolean_1) { - if (!isClickable()) - return false; - this.focused = !this.focused; - return true; - } - - public boolean isHovered(int mouseX, int mouseY) { - return isClickable() && (containsMouse(mouseX, mouseY) || focused); - } - - public abstract void onLabelClicked(); - -} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java index 2ca72fee7..3555ef44a 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java @@ -60,7 +60,6 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableLong; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.Comparator; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java index 9a8383391..5a820ac0e 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java @@ -69,35 +69,15 @@ public class EntryWidget extends Slot { private Rectangle bounds; private List<EntryStack> entryStacks; - protected EntryWidget(int x, int y) { + public EntryWidget(int x, int y) { this(new Point(x, y)); } - protected EntryWidget(Point point) { + public EntryWidget(Point point) { this.bounds = new Rectangle(point.x - 1, point.y - 1, 18, 18); this.entryStacks = new ArrayList<>(); } - /** - * @see me.shedaniel.rei.api.widgets.Widgets#createSlot(me.shedaniel.math.Point) - */ - @ApiStatus.ScheduledForRemoval - @Deprecated - @NotNull - public static EntryWidget create(int x, int y) { - return create(new Point(x, y)); - } - - /** - * @see me.shedaniel.rei.api.widgets.Widgets#createSlot(me.shedaniel.math.Point) - */ - @ApiStatus.ScheduledForRemoval - @Deprecated - @NotNull - public static EntryWidget create(Point point) { - return new EntryWidget(point); - } - @Override @NotNull public EntryWidget unmarkInputOrOutput() { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/Lab |
