diff options
6 files changed, 14 insertions, 235 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java index ae813ad4b..b1d3c0bd9 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Label.java @@ -146,53 +146,17 @@ public abstract class Label extends WidgetWithBounds { /** * @return the tooltip from the current tooltip function, null if no tooltip. - * @deprecated use {@link #getTooltipLines} - */ - @Nullable - @Deprecated - @ApiStatus.ScheduledForRemoval - public String getTooltip() { - Component[] lines = getTooltipLines(); - String tooltip = null; - if(lines != null) { - StringBuilder tooltipBuilder = new StringBuilder(); - for (Component line:lines) { - tooltipBuilder.append(line.getContents()).append("\n"); - } - tooltip = tooltipBuilder.toString(); - } - return tooltip; - } - - /** - * @return the tooltip from the current tooltip function, null if no tooltip. */ @Nullable public abstract Component[] getTooltipLines(); - - /** - * Sets the tooltip function used to get the tooltip. - * - * @param tooltip the tooltip function used to get the tooltip. - * @deprecated use {@link #setTooltipFunction(Function)} - */ - @Deprecated - @ApiStatus.ScheduledForRemoval - public void setTooltip(@Nullable Function<Label, @Nullable String> tooltip) { - if(tooltip != null) setTooltipFunction((label) -> { - String text = tooltip.apply(label); - if(text != null) return Stream.of(text.split("\n")).map(Component::literal).toArray(Component[]::new); - return null; - }); - } - + /** * Sets the tooltip function used to get the tooltip. * * @param tooltip the tooltip function used to get the tooltip. */ public abstract void setTooltipFunction(@Nullable Function<Label, @Nullable Component[]> tooltip); - + /** * Sets the tooltip. * @@ -201,76 +165,17 @@ public abstract class Label extends WidgetWithBounds { public void setTooltip(Component... tooltip) { setTooltipFunction((label) -> tooltip); } - - /** - * Sets the tooltip. - * - * @param tooltip the tooltip. - */ - public void setTooltip(String... tooltip) { - setTooltipFunction((label) -> Stream.of(tooltip).map(Component::literal).toArray(Component[]::new)); - } /** * Sets the tooltip. * * @param tooltip the lines of tooltip. * @return the label itself. - * @deprecated use {@link #tooltip(String...)} - */ - @Deprecated - @ApiStatus.ScheduledForRemoval - public final Label tooltipLines(String... tooltip) { - return tooltip(tooltip); - } - - /** - * Sets the tooltip. - * - * @param tooltip the line of tooltip. - * @return the label itself. - * @deprecated use {@link #tooltip(String...)} - */ - @Deprecated - @ApiStatus.ScheduledForRemoval - public final Label tooltipLine(String tooltip) { - return tooltip(tooltip); - } - - /** - * Sets the tooltip. - * - * @param tooltip the lines of tooltip. - * @return the label itself. - */ - public final Label tooltip(String... tooltip) { - return tooltipFunction(label -> Stream.of(tooltip).map(Component::literal).toArray(Component[]::new)); - } - - /** - * Sets the tooltip. - * - * @param tooltip the lines of tooltip. - * @return the label itself. */ public final Label tooltip(Component... tooltip) { return tooltipFunction(label -> tooltip); } - - /** - * Sets the tooltip function. - * - * @param tooltip the tooltip function used to get the tooltip. - * @return the label itself. - * @deprecated use {@link #tooltipFunction} - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "8.0.0") - public final Label tooltipSupplier(@Nullable Function<Label, @Nullable String> tooltip) { - setTooltip(tooltip); - return this; - } - + /** * Sets the tooltip function. * diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java index 0a5c1062d..a9caf9577 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java @@ -48,14 +48,6 @@ public interface Tooltip { return ClientInternals.createTooltipEntry(text); } - @Deprecated - @ApiStatus.ScheduledForRemoval - static Tooltip.Entry entry(ClientTooltipComponent text) { - return ClientInternals.createTooltipEntry(text); - } - - @Deprecated - @ApiStatus.ScheduledForRemoval static Tooltip.Entry entry(TooltipComponent text) { return ClientInternals.createTooltipEntry(text); } @@ -98,14 +90,6 @@ public interface Tooltip { List<Entry> entries(); - @Deprecated - @ApiStatus.ScheduledForRemoval - List<TooltipComponent> components(); - - @Deprecated - @ApiStatus.ScheduledForRemoval - Tooltip add(ClientTooltipComponent component); - Tooltip add(Component text); Tooltip add(TooltipComponent component); @@ -117,15 +101,6 @@ public interface Tooltip { return this; } - @Deprecated - @ApiStatus.ScheduledForRemoval - default Tooltip addAll(ClientTooltipComponent... components) { - for (ClientTooltipComponent component : components) { - add(component); - } - return this; - } - default Tooltip addAll(Component... text) { for (Component component : text) { add(component); @@ -140,15 +115,6 @@ public interface Tooltip { return this; } - @Deprecated - @ApiStatus.ScheduledForRemoval - default Tooltip addAllComponents(Iterable<ClientTooltipComponent> text) { - for (ClientTooltipComponent component : text) { - add(component); - } - return this; - } - default Tooltip addAllTexts(Iterable<Component> text) { for (Component component : text) { add(component); @@ -175,9 +141,5 @@ public interface Tooltip { Component getAsText(); TooltipComponent getAsTooltipComponent(); - - @Deprecated - @ApiStatus.ScheduledForRemoval - ClientTooltipComponent getAsComponent(); } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java index ad79d1d92..bfb63808d 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java @@ -65,14 +65,6 @@ public interface TransferHandler extends Comparable<TransferHandler> { return Double.compare(getPriority(), o.getPriority()); } - @Deprecated - @Environment(EnvType.CLIENT) - @Nullable - @ApiStatus.ScheduledForRemoval - default TransferHandlerErrorRenderer provideErrorRenderer(Context context, Object data) { - return null; - } - @ApiStatus.NonExtendable interface Result { /** @@ -132,12 +124,6 @@ public interface TransferHandler extends Comparable<TransferHandler> { */ Result color(int color); - /** - * Sets the error data, to be passed to {@link TransferHandler#provideErrorRenderer(Context, Object)}. - */ - @Deprecated - Result errorRenderer(Object data); - Result renderer(TransferHandlerRenderer renderer); @ApiStatus.Experimental @@ -191,12 +177,6 @@ public interface TransferHandler extends Comparable<TransferHandler> { @ApiStatus.NonExtendable interface Context { - @Deprecated - @ApiStatus.ScheduledForRemoval - static Context create(boolean actuallyCrafting, @Nullable AbstractContainerScreen<?> containerScreen, Display display) { - return create(actuallyCrafting, Screen.hasShiftDown(), containerScreen, display); - } - static Context create(boolean actuallyCrafting, boolean stackedCrafting, @Nullable AbstractContainerScreen<?> containerScreen, Display display) { return new ContextImpl(actuallyCrafting, stackedCrafting, containerScreen, () -> display); } @@ -229,7 +209,7 @@ public interface TransferHandler extends Comparable<TransferHandler> { final class ResultImpl implements Result { private boolean successful, applicable, returningToScreen, blocking; private Component error; - private Object errorRenderer; + private TransferHandlerRenderer renderer; private BiConsumer<Point, TooltipSink> tooltipRenderer; private int color; @@ -272,14 +252,8 @@ public interface TransferHandler extends Comparable<TransferHandler> { } @Override - public Result errorRenderer(Object data) { - this.errorRenderer = data; - return this; - } - - @Override public Result renderer(TransferHandlerRenderer renderer) { - this.errorRenderer = renderer; + this.renderer = renderer; return this; } @@ -316,11 +290,7 @@ public interface TransferHandler extends Comparable<TransferHandler> { @Override public TransferHandlerRenderer getRenderer(TransferHandler handler, Context context) { - if (errorRenderer == null) return null; - if (errorRenderer instanceof TransferHandlerRenderer) return (TransferHandlerRenderer) errorRenderer; - if (isSuccessful()) return null; - TransferHandlerErrorRenderer renderer = handler.provideErrorRenderer(context, this.errorRenderer); - return renderer == null ? null : renderer.asNew(); + return renderer; } @Override diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerErrorRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerErrorRenderer.java deleted file mode 100644 index 6c890f8fc..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerErrorRenderer.java +++ /dev/null @@ -1,44 +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.api.client.registry.transfer; - -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.common.display.Display; -import org.jetbrains.annotations.ApiStatus; - -import java.util.List; - -@ApiStatus.Experimental -@FunctionalInterface -@Deprecated -@ApiStatus.ScheduledForRemoval -public interface TransferHandlerErrorRenderer { - void render(PoseStack matrices, int mouseX, int mouseY, float delta, List<Widget> widgets, Rectangle bounds, Display display); - - default TransferHandlerRenderer asNew() { - return this::render; - } -} diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplImpl.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplImpl.java index caf42161f..5a2841f58 100644 --- a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplImpl.java +++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplImpl.java @@ -48,8 +48,6 @@ public class ScreenOverlayImplImpl { Stream<FormattedCharSequence> sequenceStream = texts.isEmpty() ? Stream.of(component.getAsText().getVisualOrderText()) : texts.stream().map(Language.getInstance()::getVisualOrder); return sequenceStream.map(ClientTooltipComponent::create); - } else if (!component.isTooltipComponent()) { - return Stream.of(component.getAsComponent()); } else { return Stream.empty(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/QueuedTooltip.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/QueuedTooltip.java index 5c992d197..27cf89f09 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/QueuedTooltip.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/QueuedTooltip.java @@ -78,23 +78,12 @@ public class QueuedTooltip implements Tooltip { } @Override - public List<TooltipComponent> components() { - return CollectionUtils.filterAndMap(entries, TooltipEntryImpl::isTooltipComponent, TooltipEntryImpl::getAsTooltipComponent); - } - - @Override public Tooltip add(Component text) { entries.add(new TooltipEntryImpl(text)); return this; } @Override - public Tooltip add(ClientTooltipComponent component) { - entries.add(new TooltipEntryImpl(component)); - return this; - } - - @Override public Tooltip add(TooltipComponent component) { entries.add(new TooltipEntryImpl(component)); return this; @@ -124,6 +113,14 @@ public class QueuedTooltip implements Tooltip { } public record TooltipEntryImpl(Object obj) implements Tooltip.Entry { + public TooltipEntryImpl(Object obj) { + this.obj = obj; + + if (!(obj instanceof Component) && !(obj instanceof TooltipComponent)) { + throw new IllegalArgumentException("obj must be a Component or TooltipComponent"); + } + } + @Override public Component getAsText() { return (Component) obj; @@ -146,14 +143,5 @@ public class QueuedTooltip implements Tooltip { public TooltipComponent getAsTooltipComponent() { return (TooltipComponent) obj; } - - @Override - public ClientTooltipComponent getAsComponent() { - if (isTooltipComponent()) { - return ClientTooltipComponent.create((TooltipComponent) obj); - } - - return (ClientTooltipComponent) obj; - } } } |
